using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using DSWeb.Models; using DSWeb.EntityDA; using System.Text; using DSWeb.Authority; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Xml; namespace DSWeb.CRM { public partial class CRMClientQuotationListGridSource : System.Web.UI.Page { private int iType;//费用类型 应收类型值1 人民币类型值 2 private string strHandle = "";//读取xml串方式 "init"-初始化获取所有费用信息;"add"-添加新的费用信息;"delete"-删除费用信息;"exist"查看是否有与委托相关费用 private string strUserID;//用户GID private string strCompanyID;//公司GID private string strShowName;//用户显示名 private string strDeptName;//部门名称 private string strlinkgid;//主表关联gid private string strfeegid;//feegid private int iCurrentPage; private int iShowPage; private string strType = "46";//Grid模块号 private string strOldHeader; private string strNewHeader; public string strgids = ""; public string strCLIENTGID = ""; public string strclientname = ""; public string strRange = String.Empty;//权限可视范围 public string strSearch = "";//权限可视范围 RangeDA RangeDA = new RangeDA(); protected void Page_Load(object sender, EventArgs e) { #region 判断参数是否正确 if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString(); } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); } if (Session["DEPTNAME"] != null) { strDeptName = Session["DEPTNAME"].ToString(); } // if (Request.QueryString["handle"] != null) { strHandle = Request.QueryString["handle"].ToString().Trim(); } if (Request.QueryString["linkgid"] != null) { strlinkgid = Request.QueryString["linkgid"].ToString().Trim(); } if (Request.QueryString["type"] != null) { iType = int.Parse(Request.QueryString["type"].ToString().Trim()); } if (Request.QueryString["feegid"] != null) { strfeegid = Request.QueryString["feegid"].ToString(); } if (Request.QueryString["cur_page"] != null) { iCurrentPage = int.Parse(Request.QueryString["cur_page"].ToString().Trim()); } if (Request.QueryString["show_page"] != null) { iShowPage = int.Parse(Request.QueryString["show_page"].ToString().Trim()); } if (Request.QueryString["gids"] != null && Request.QueryString["gids"].ToString().Trim() != "") { strgids = Request.QueryString["gids"].ToString().Trim(); } if (Request.QueryString["clientname"] != null && Request.QueryString["clientname"].ToString().Trim() != "") { strclientname = Request.QueryString["clientname"].ToString().Trim(); } // ViewState["hid_sel"] = ""; if (Request.QueryString["clientgid"] != null && Request.QueryString["clientgid"].ToString().Trim() != "") { strCLIENTGID = Request.QueryString["clientgid"].ToString().Trim(); ViewState["hid_sel"] = " and CLIENTGID='" + strCLIENTGID + "'"; } UnicodeEncoding unicode = new UnicodeEncoding(); if (Request.QueryString["tbname"] != null && Request.QueryString["tbname"].ToString().Trim() != "") { string strtbname = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["tbname"].ToString().Trim()))); ViewState["hid_sel"] += " and (SHORTNAME like '%" + strtbname + "%' or DESCRIPTION like '%" + strtbname + "%')"; } if (Request.QueryString["sale"] != null && Request.QueryString["sale"].ToString().Trim() != "") { string strtbname = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["sale"].ToString().Trim()))); ViewState["hid_sel"] += " and sale='" + strtbname + "'"; } // if (Request.QueryString["tbtime"] != null && Request.QueryString["tbtime"].ToString().Trim() != "") { string strtbtime = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["tbtime"].ToString().Trim()))); ViewState["hid_sel"] += " and convert(char(10),QUOTATIONDATE,20)>='" + strtbtime + "'"; } // if (Request.QueryString["tbtime1"] != null && Request.QueryString["tbtime1"].ToString().Trim() != "") { string strtbtime1 = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["tbtime1"].ToString().Trim()))); ViewState["hid_sel"] += " and convert(char(10),QUOTATIONDATE,20)<='" + strtbtime1 + "'"; } // //权限可视范围 strRange = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modCRMClientQuotationList");//往来单位列表 if (strRange.Trim().Equals("0"))//全部 { strRange = ""; } else if (strRange.Trim().Equals("1"))//分公司 { strRange = " and GID in(" + RangeDA.GetCRMClientQuotationListCompany(strUserID.Trim()) + ")"; } else if (strRange.Trim().Equals("2"))//部门 { } else if (strRange.Trim().Equals("3"))//个人 { strRange = " and GID in(" + RangeDA.GetCRMClientQuotationListPerson(strUserID.Trim()) + ")"; } else if (strRange.Trim().Equals("4"))//无 { strRange = " and 1<0"; } else//空 { strRange = " and 1<0"; } // #endregion string strJSON = ""; if (strHandle != null) { if (iType > 0 && !strHandle.Equals("")) { string strOutputXml = ""; //获取crm_quotation_detail费用信息,返回xml格式数据 strOutputXml = GetCells(iType, strHandle); //输出XML字符串 Response.ContentType = "text/xml"; strOutputXml.Replace("&", "&"); Response.Write(strOutputXml); } if (strHandle.Equals("getctn")) { Response.Write(GetUnitCells()); return; } if (strHandle.Equals("delete")) { Response.Write(Getdelete()); return; } if (strHandle.Equals("list")) { if (iCurrentPage <= 0 && iShowPage < 0) { strJSON = "-2";//提交页数参数错误 } } if (strHandle.Trim().ToLower().Equals("setting")) { Response.Write(GetUserSettingJson()); } if (strHandle.Trim().ToLower().Equals("page")) { Response.Write(GetPageInfo().ToString()); } if (strHandle.Trim().ToLower().Equals("list")) { Response.Write(GetLogContent(iShowPage, iCurrentPage)); } if (strHandle.Trim().ToLower().Equals("rename")) { if (Request.QueryString["old_header"] != null && Request.QueryString["new_header"] != null) { strOldHeader = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["old_header"].ToString()))); strNewHeader = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["new_header"].ToString()))); Response.Write(UpdateColumnHeader(strOldHeader, strNewHeader)); } else { Response.Write("-1");//GET 参数错误 } } if (strHandle.Trim().ToLower().Equals("isdel")) { Response.Write(getisdel()); return; } if (strHandle.Trim().ToLower().Equals("getshortname")) { getshortname(); return; } if (strHandle.Trim().ToLower().Equals("feeusd")) { Response.Write(GetFeeNameUSD()); return; } if (strHandle.Trim().ToLower().Equals("feermb")) { Response.Write(GetFeeNameRMB()); return; } if (strHandle.Trim().ToLower().Equals("getcontactname")) { getcontactname(); return; } } else { strJSON = "-1";//GET 参数错误 //访问参数不正确 Response.ContentType = "text/xml"; Response.Write("-2"); } } protected void getcontactname() { T_ALL_DA T_ALL_DA = new T_ALL_DA(); StringBuilder resultBuilder = new StringBuilder(); resultBuilder.Append(""); resultBuilder.AppendFormat("", ""); string str = "select SHOWNAME from [info_client_contact] where LINKID=(select gid from crm_info_client where SHORTNAME='" + strclientname + "') order by SHOWNAME"; DataSet ds = T_ALL_DA.GetAllSQL(str); if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["SHOWNAME"].ToString().Trim() != "") { resultBuilder.AppendFormat("", dr["SHOWNAME"].ToString().Trim(), dr["SHOWNAME"].ToString().Trim()); } } } resultBuilder.AppendFormat("", "", ""); resultBuilder.Append(""); string content = resultBuilder.ToString().Replace("&", "&"); XmlDocument xmldoc = new XmlDocument(); try { xmldoc.LoadXml(content); } catch (Exception) { } Response.ContentType = "text/xml"; Response.Write(xmldoc.OuterXml.ToString()); } #region 返回code_fee费用名称JSON字符串 /// /// 返回code_fee费用名称JSON字符串 /// code_fee费用名称设置 /// /// 返回code_fee费用名称JSON字符串 public string GetFeeNameUSD() { FeeCodeDA feeCodeDA = new FeeCodeDA(); DataTable sourceTable = new DataTable(); string strSql = " SELECT GID,ISNULL(FEECODE,'')+' '+ISNULL(Name,'') AS FullName,Name FROM code_fee where ISSEA=1 and DEFAULTCURR='RMB' ORDER BY FEECODE ASC "; sourceTable = feeCodeDA.GetExcuteSql(strSql).Tables[0]; //Cache.Insert("feecodes", sourceTable); StringBuilder sourceBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("feecode:["); for (int i = 0; i < sourceTable.Rows.Count; i++) { if (i == 0) { sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } else { sourceBuilder.Append(",{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } sourceBuilder.Append("\"code\":\"" + sourceTable.Rows[i][1].ToString() + "\","); sourceBuilder.Append("\"name\":\"" + sourceTable.Rows[i][2].ToString() + "\"}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion #region 返回code_fee费用名称JSON字符串 /// /// 返回code_fee费用名称JSON字符串 /// code_fee费用名称设置 /// /// 返回code_fee费用名称JSON字符串 public string GetFeeNameRMB() { FeeCodeDA feeCodeDA = new FeeCodeDA(); DataTable sourceTable = new DataTable(); string strSql = " SELECT GID,ISNULL(FEECODE,'')+' '+ISNULL(Name,'') AS FullName,Name FROM code_fee where ISSEA=1 and DEFAULTCURR='RMB' ORDER BY FEECODE ASC "; //if (Cache["feecodes"] != null) //{ // sourceTable = (DataTable)Cache["feecodes"]; //} //else //{ sourceTable = feeCodeDA.GetExcuteSql(strSql).Tables[0]; //Cache.Insert("feecodes", sourceTable); //} StringBuilder sourceBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("feecode:["); for (int i = 0; i < sourceTable.Rows.Count; i++) { if (i == 0) { sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } else { sourceBuilder.Append(",{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } sourceBuilder.Append("\"code\":\"" + sourceTable.Rows[i][1].ToString() + "\","); sourceBuilder.Append("\"name\":\"" + sourceTable.Rows[i][2].ToString() + "\"}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion protected void getshortname() { StringBuilder resultBuilder = new StringBuilder(); resultBuilder.Append(""); resultBuilder.AppendFormat("", ""); string str = "select CODENAME,SHORTNAME from [crm_info_client] order by SHORTNAME"; T_ALL_DA T_ALL_DA = new T_ALL_DA(); DataSet ds = T_ALL_DA.GetAllSQL(str); if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr["CODENAME"].ToString().Trim() != "" || dr["SHORTNAME"].ToString().Trim() != "") { string js = dr["CODENAME"].ToString().Trim() + " | " + dr["SHORTNAME"].ToString().Trim(); resultBuilder.AppendFormat("", dr["CODENAME"].ToString().Trim(), js); } } } resultBuilder.AppendFormat("", "", ""); resultBuilder.Append(""); string content = resultBuilder.ToString().Replace("&", "&"); XmlDocument xmldoc = new XmlDocument(); try { xmldoc.LoadXml(content); } catch (Exception) { } Response.ContentType = "text/xml"; Response.Write(xmldoc.OuterXml.ToString()); } //protected string getisdel() //{ // if (strgids.Trim() != "") // { // CRMInfoClientDA CRMInfoClientDA = new CRMInfoClientDA(); // bool bl = CRMInfoClientDA.DeleteList(strgids.Trim()); // if (bl) // { // //Response.Write(""); // } // else // { // //Response.Write(""); // return "删除失败!"; // } // } // return ""; //} protected string getisdel() { T_ALL_DA T_ALL_DA = new T_ALL_DA(); if (strgids.Trim() != "") { strgids = strgids.Replace(",", "','"); strgids = "'" + strgids + "'"; CRMClientQuotationDA CRMClientQuotationDA = new CRMClientQuotationDA(); int iResult = CRMClientQuotationDA.Deletes(strgids.Trim()); if (iResult > 0) { //Response.Write(""); } else { //Response.Write(""); return "删除失败!"; } } return ""; } private int UpdateColumnHeader(string tempOldHeader, string tempNewHeader) { int iResult = 0; UserSettingDA userSettingDA = new UserSettingDA(); UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType); GridEntity gridEntity = null; if (userSettingEntity != null) { if (userSettingEntity.GID != null) { gridEntity = GetSettingXml(userSettingEntity.Xml); foreach (GridColumnEntity column in gridEntity.Columns) { if (column.Description.Equals(tempOldHeader)) { column.Description = tempNewHeader; break; } } userSettingEntity.Xml = GetUserSettingXml(gridEntity).OuterXml; iResult = userSettingDA.UpdateUserSetting(userSettingEntity); } else { iResult = -3;//没有相关用户Grid设置记录 } } else { iResult = -3;//没有相关用户Grid设置记录 } return iResult; } private string GetUserSettingJson() { UserSettingDA userSettingDA = new UserSettingDA(); UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType); GridEntity gridEntity = null; StringBuilder settingBuilder = new StringBuilder(); if (userSettingEntity != null) { if (userSettingEntity.GID != null) { gridEntity = GetSettingXml(userSettingEntity.Xml); settingBuilder.Append("{"); settingBuilder.Append("\"show\":" + gridEntity.PagePreCount + ","); settingBuilder.Append("\"columns\":"); int i = 0; StringBuilder columnGroupBuilder = new StringBuilder(); while (gridEntity.Columns.Count > i) { foreach (GridColumnEntity column in gridEntity.Columns) { if (column.Index == i) { StringBuilder columnBuilder = new StringBuilder(); columnBuilder.Append("{\"name\":\"" + column.Name + "\","); columnBuilder.Append("\"description\":\"" + column.Description + "\","); columnBuilder.Append("\"index\":" + column.Index.ToString() + ","); columnBuilder.Append("\"width\":" + column.Width.ToString() + ","); columnBuilder.Append("\"visible\":" + column.VisibleState.ToString()); columnGroupBuilder.Append(columnBuilder.ToString() + "},"); break; } } i++; } string strGroup = columnGroupBuilder.ToString().Trim(); if (strGroup.EndsWith(",")) { strGroup = strGroup.Substring(0, strGroup.Length - 1); } strGroup = "[" + strGroup + "]"; settingBuilder.Append(strGroup); settingBuilder.Append("}"); } else { settingBuilder.Append("-3");//没有相关用户Grid设置记录 } } else { settingBuilder.Append("-3");//没有相关用户Grid设置记录 } return settingBuilder.ToString(); } private GridEntity GetSettingXml(string strXml) { XmlDocument xmlSettingDoc = new XmlDocument(); GridEntity gridEntity = new GridEntity(); try { xmlSettingDoc.LoadXml(strXml); gridEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[0].InnerText.Trim(); gridEntity.UserID = xmlSettingDoc.ChildNodes[0].ChildNodes[1].InnerText.Trim(); gridEntity.CreateTime = DateTime.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[2].InnerText.Trim()); IList columnsEntities = new List(); int iColCount = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes.Count; for (int i = 0; i < iColCount; i++) { GridColumnEntity columnEntity = new GridColumnEntity(); //columnEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[0].ToString(); columnEntity.Name = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[0].InnerText.Trim(); columnEntity.Description = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[1].InnerText.Trim(); columnEntity.Index = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[2].InnerText.Trim()); columnEntity.Width = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[3].InnerText.Trim()); columnsEntities.Add(columnEntity); } gridEntity.Columns = columnsEntities; gridEntity.GroupBy = xmlSettingDoc.ChildNodes[0].ChildNodes[4].InnerText.Trim(); gridEntity.DefaultPrePageCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[0].InnerText.Trim()); gridEntity.PagePreCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[1].InnerText.Trim()); } catch (Exception error) { throw (error); } return gridEntity; } private int GetPageInfo() { LogDA logDA = new LogDA(); StringBuilder logBuilder = new StringBuilder(); string strSql = String.Format("SELECT COUNT(*) FROM crm_quotation WHERE 1=1 " + strRange + ViewState["hid_sel"].ToString().Trim()); int iTotal = logDA.GetPageTotal(strSql); return iTotal; } private string GetLogContent(int tempShowPage, int tempCurPage) { LogDA logDA = new LogDA(); StringBuilder logBuilder = new StringBuilder(); string strSql = ""; string strTopInclude = ""; string strTopNotInclude = ""; if (tempShowPage > 0 && tempCurPage > 0) { if (tempCurPage == 1) { strSql = String.Format("SELECT {0} GID,SHORTNAME,CONTACTNAME,SALE,convert(char(10),QUOTATIONDATE,20) QUOTATIONDATE,PORTLOAD,PORTDISCHARGE,LANE,CARRIER,convert(char(10),ETD,20) ETD,ENTREPORT,TT,GOODSNAME,REMARK FROM crm_quotation WHERE 1=1 " + ViewState["hid_sel"].ToString().Trim() + strRange + " ORDER BY QUOTATIONDATE DESC", "top " + tempShowPage);//,CLIENTGID } else { strTopNotInclude = "top " + (tempShowPage * (tempCurPage - 1));//RowCount*PageNum strTopInclude = "top " + tempShowPage;//RowCount*PageNum strSql = String.Format("SELECT GID,SHORTNAME,CONTACTNAME,SALE,convert(char(10),QUOTATIONDATE,20) QUOTATIONDATE,PORTLOAD,PORTDISCHARGE,LANE,CARRIER,convert(char(10),ETD,20) ETD,ENTREPORT,TT,GOODSNAME,REMARK FROM (SELECT {1} * FROM crm_quotation WHERE GID NOT IN (SELECT {0} GID FROM crm_quotation where 1=1 " + ViewState["hid_sel"].ToString().Trim() + strRange + " ORDER BY QUOTATIONDATE desc) " + ViewState["hid_sel"].ToString().Trim() + strRange + " ORDER BY QUOTATIONDATE desc) AS A", strTopNotInclude, strTopInclude);//,OPNAME=(select top 1 SHOWNAME from [user] where gid=crm_quotation.OPNAME and isnull(ISDELETED,0)=0) } } else { strSql = " SELECT GID,SHORTNAME,CONTACTNAME,SALE,convert(char(10),QUOTATIONDATE,20) QUOTATIONDATE,PORTLOAD,PORTDISCHARGE,LANE,CARRIER,convert(char(10),ETD,20) ETD,ENTREPORT,TT,GOODSNAME,REMARK FROM crm_quotation WHERE 1>1 " + ViewState["hid_sel"].ToString().Trim() + strRange + " ORDER BY QUOTATIONDATE desc";//,OPNAME=(select top 1 SHOWNAME from [user] where gid=crm_quotation.OPNAME and isnull(ISDELETED,0)=0) } DataTable logTable = GetSqlDataIndex(logDA.GetExcuteSql(strSql).Tables[0]); logBuilder.Append("{"); logBuilder.Append("rows:["); for (int i = 0; i < logTable.Rows.Count; i++) { logBuilder.Append("{id:\"" + logTable.Rows[i][0].ToString() + "\","); logBuilder.Append("data:["); logBuilder.Append("\"0\","); for (int j = 1; j < logTable.Columns.Count; j++) { if (j == 6 || j == 9) { string ls = logTable.Rows[i][j].ToString().Trim().Replace("\r\n", " "); logBuilder.Append("\"" + ls + "\","); } else if (j == logTable.Columns.Count - 1) { logBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\""); } else { logBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\","); } } if (i == logTable.Rows.Count - 1) { logBuilder.Append("]}"); } else { logBuilder.Append("]},"); } } logBuilder.Append("]"); logBuilder.Append("}"); return logBuilder.ToString(); } private string GetSeaExPKGSInfoBusinessListGridSource() { //GetLogGridSource LogDA logDA = new LogDA(); StringBuilder logBuilder = new StringBuilder(); StringBuilder userdateBuilder = new StringBuilder(); StringBuilder dataBuilder = new StringBuilder(); string strSql = String.Format("SELECT COUNT(*) FROM crm_quotation WHERE 1=1 " + strRange + ViewState["hid_sel"].ToString().Trim()); DataTable logTable = logDA.GetExcuteSql(strSql).Tables[0]; logBuilder.Append("{"); logBuilder.Append("rows:["); for (int i = 0; i < logTable.Rows.Count; i++) { logBuilder.Append("{id:\"" + logTable.Rows[i][0].ToString() + "\","); userdateBuilder.Append("userdata:{"); dataBuilder.Append("data:["); for (int j = 1; j < logTable.Columns.Count; j++) { if (j == logTable.Columns.Count - 1) { userdateBuilder.Append("\"" + logTable.Columns[j].ColumnName + "\":\"" + logTable.Rows[i][j].ToString() + "\""); dataBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\""); } else { userdateBuilder.Append("\"" + logTable.Columns[j].ColumnName + "\":\"" + logTable.Rows[i][j].ToString() + "\","); dataBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\","); } } userdateBuilder.Append("}"); dataBuilder.Append("]"); logBuilder.Append(userdateBuilder.ToString() + ","); logBuilder.Append(dataBuilder); if (i == logTable.Rows.Count - 1) { logBuilder.Append("}"); } else { logBuilder.Append("},"); } } logBuilder.Append("]"); logBuilder.Append("}"); return logBuilder.ToString(); //return logBuilder.ToString(); } private DataTable GetSqlDataIndex(DataTable tempTable) { UserSettingDA userSettingDA = new UserSettingDA(); UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType); GridEntity gridEntity = null; StringBuilder settingBuilder = new StringBuilder(); DataTable dataTable = new DataTable(); if (userSettingEntity != null) { if (userSettingEntity.GID != null) { gridEntity = GetSettingXml(userSettingEntity.Xml); int i = 0; StringBuilder columnGroupBuilder = new StringBuilder(); dataTable.Columns.Add(tempTable.Columns[0].ColumnName, tempTable.Columns[0].DataType); for (int k = 0; k < tempTable.Rows.Count; k++) { DataRow newRow = dataTable.NewRow(); newRow[tempTable.Columns[0].ColumnName] = tempTable.Rows[k][tempTable.Columns[0].ColumnName].ToString(); dataTable.Rows.Add(newRow); } while (gridEntity.Columns.Count > i) { foreach (GridColumnEntity column in gridEntity.Columns) { if (column.Index == i) { for (int j = 1; j < tempTable.Columns.Count; j++) { if (tempTable.Columns[j].ColumnName.Equals(column.Name)) { dataTable.Columns.Add(tempTable.Columns[j].ColumnName, tempTable.Columns[j].DataType); for (int k = 0; k < tempTable.Rows.Count; k++) { dataTable.Rows[k][tempTable.Columns[j].ColumnName] = tempTable.Rows[k][tempTable.Columns[j].ColumnName].ToString(); } break; } } break; } } i++; } } else { return tempTable; } } else { return tempTable; } return dataTable; } private XmlDocument GetUserSettingXml(GridEntity gridEntity) { XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("user-settings"); //xmlDoc.AppendChild(root); XmlElement xGID = xmlDoc.CreateElement("GID"); xGID.InnerText = gridEntity.GID; root.AppendChild(xGID); XmlElement xUserID = xmlDoc.CreateElement("userid"); xUserID.InnerText = gridEntity.UserID; root.AppendChild(xUserID); XmlElement xCreateTime = xmlDoc.CreateElement("create-time"); xCreateTime.InnerText = gridEntity.CreateTime.ToString(); root.AppendChild(xCreateTime); XmlElement xColumns = xmlDoc.CreateElement("columns"); foreach (GridColumnEntity column in gridEntity.Columns) { XmlElement xColumn = xmlDoc.CreateElement("column"); XmlElement nName = xmlDoc.CreateElement("name"); nName.InnerText = column.Name; xColumn.AppendChild(nName); XmlElement nDescription = xmlDoc.CreateElement("description"); nDescription.InnerText = column.Description; xColumn.AppendChild(nDescription); XmlElement nIndex = xmlDoc.CreateElement("index"); nIndex.InnerText = column.Index.ToString(); xColumn.AppendChild(nIndex); XmlElement nWidth = xmlDoc.CreateElement("width"); nWidth.InnerText = column.Width.ToString(); xColumn.AppendChild(nWidth); XmlElement nVisible = xmlDoc.CreateElement("visible"); nVisible.InnerText = column.VisibleState.ToString(); xColumn.AppendChild(nVisible); xColumns.AppendChild(xColumn); } root.AppendChild(xColumns); XmlElement xGroupBy = xmlDoc.CreateElement("group-by"); xGroupBy.InnerText = gridEntity.GroupBy; root.AppendChild(xGroupBy); XmlElement xPage = xmlDoc.CreateElement("page"); XmlElement nPageDefault = xmlDoc.CreateElement("page-default"); nPageDefault.InnerText = gridEntity.DefaultPrePageCount.ToString(); xPage.AppendChild(nPageDefault); XmlElement nPagePre = xmlDoc.CreateElement("page-pre"); nPagePre.InnerText = gridEntity.PagePreCount.ToString(); xPage.AppendChild(nPagePre); root.AppendChild(xPage); xmlDoc.AppendChild(root); return xmlDoc; } private int Getdelete() { int iResult = 0; CRMClientQuotationDetailDA CRMClientQuotationDetailDA = new CRMClientQuotationDetailDA(); iResult = CRMClientQuotationDetailDA.Delete(strfeegid); return iResult; } #region 获取crm_quotation_detail费用信息,返回xml格式数据 /// /// 获取crm_quotation_detail费用信息 /// /// 返回xml格式数据 private string GetCells(int Type, string strHandle) { CRMClientQuotationDetailEntity CRMClientQuotationDetailEntity = new CRMClientQuotationDetailEntity(); CRMClientQuotationDetailDA CRMClientQuotationDetailDA = new CRMClientQuotationDetailDA(); CRMClientQuotationDetailEntity existCRMClientQuotationDetailEntity = new CRMClientQuotationDetailEntity(); if (!strlinkgid.Equals("")) { existCRMClientQuotationDetailEntity = CRMClientQuotationDetailDA.GetModelLINKGID(strlinkgid); } //通过委托编号clientgid与费用类型(1应收2人民币)获取费用信息,返回CRMClientQuotationDetailEntity if (existCRMClientQuotationDetailEntity != null && !strHandle.Equals("exist")) { //获取所有费用信息,用做Grid显示 DataTable feeTable = new DataTable(); string strSql = ""; if (iType == 1) { if (!strlinkgid.Equals("")) { //费用状态,海运费及附加费名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID //费用名称,船公司,箱型,报价,备注 strSql = "SELECT GID,FEENAME,CARRIER,UNIT,UNITPRICE,REMARK FROM crm_quotation_detail WHERE LINKGID='" + strlinkgid + "' and FEETYPE='海运费及附加费'"; } else { strSql = "SELECT GID,FEENAME,CARRIER,UNIT,UNITPRICE,REMARK FROM crm_quotation_detail WHERE 1< 0"; } } else { if (!strlinkgid.Equals("")) { //费用状态,海运费及附加费名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID //费用名称,箱型,报价,备注 strSql = "SELECT GID,FEENAME,'',UNIT,UNITPRICE,REMARK FROM crm_quotation_detail WHERE LINKGID='"+strlinkgid+"' and FEETYPE='人民币费用'"; } else { strSql = "SELECT GID,FEENAME,'',UNIT,UNITPRICE,REMARK FROM crm_quotation_detail WHERE 1< 0"; } } feeTable = CRMClientQuotationDetailDA.GetExcuteSql(strSql).Tables[0]; //编排字符串 xml串 StringBuilder dataBuilder = new StringBuilder(); dataBuilder.Append(""); dataBuilder.Append(""); int iCount = feeTable.Rows.Count; for (int i = 0; i < iCount; i++) { int jCount = feeTable.Columns.Count; dataBuilder.Append(""); dataBuilder.Append("0"); for (int j = 1; j < jCount; j++) { switch (j) { case 1://FEENAME dataBuilder.Append(GetFeeCodeCells(feeTable.Rows[i][j].ToString().Trim())); break; case 2://CUSTOMERNAME if (iType == 1) { dataBuilder.Append(GetCRMClientCells(feeTable.Rows[i][j].ToString().Trim())); } break; case 3: dataBuilder.Append(GetUnitCells(feeTable.Rows[i][j].ToString().Trim())); break; case 4: dataBuilder.Append("" + feeTable.Rows[i][j].ToString() + ""); break; case 5: dataBuilder.Append("" + feeTable.Rows[i][j].ToString() + ""); break; } } dataBuilder.Append(""); } dataBuilder.Append(""); return dataBuilder.ToString(); } else if (existCRMClientQuotationDetailEntity != null && strHandle.Equals("exist")) { return "1";//存在费用 } else if (existCRMClientQuotationDetailEntity == null && strHandle.Equals("add")) { StringBuilder dataBuilder = new StringBuilder(); dataBuilder.Append(""); dataBuilder.Append(""); dataBuilder.Append(""); dataBuilder.Append(GetFeeCodeCells("")); if (iType == 1) { dataBuilder.Append(GetCRMClientCells("")); } dataBuilder.Append(GetUnitCells("")); dataBuilder.Append("0.00"); dataBuilder.Append(""); dataBuilder.Append(""); dataBuilder.Append(""); return dataBuilder.ToString(); } else { return "-3";//没有相关的费用 } } #endregion #region 获取CRM系统客户信息下拉列表 /// /// 获取CRM系统客户信息下拉列表 /// /// 当前列表客户信息值 /// public string GetCRMClientCells(string strClientValue) { CRMClientDA crmClientDA = new CRMClientDA(); //DataTable clientTable = crmClientDA.GetCRMClientQuotationList().Tables[0]; StringBuilder clientBuilder = new StringBuilder(); clientBuilder.Append("" + strClientValue); //for (int i = 0; i < clientTable.Rows.Count; i++) //{ // if (!clientTable.Rows[i]["SHORTNAME"].ToString().Trim().Equals("")) // { // clientBuilder.Append(""); // } //} clientBuilder.Append(""); return clientBuilder.ToString(); } #endregion #region 获取币别信息下拉列表 /// /// 获取币别信息下拉列表 /// /// public string GetCurrencyCells(string strCurrencyValue) { CurrencyDA currencyDA = new CurrencyDA(); //DataTable currencyTable = currencyDA.GetCurrencyList().Tables[0]; StringBuilder currencyBuilder = new StringBuilder(); currencyBuilder.Append("" + strCurrencyValue); //for (int i = 0; i < currencyTable.Rows.Count; i++) //{ // if (!currencyTable.Rows[i]["DESCRIPTION"].ToString().Trim().Equals("")) // { // currencyBuilder.Append(""); // } //} currencyBuilder.Append(""); return currencyBuilder.ToString(); } #endregion #region 获取费用代码信息下拉列表 /// /// 获取费用代码信息下拉列表 /// /// /// public string GetFeeCodeCells(string strFeeCodeValue) { FeeCodeDA feeCodeDA = new FeeCodeDA(); //DataTable feeCodeTable = feeCodeDA.GetFeeCodeList().Tables[0]; StringBuilder feeCodeBuilder = new StringBuilder(); feeCodeBuilder.Append("" + strFeeCodeValue); //for (int i = 0; i < feeCodeTable.Rows.Count; i++) //{ // if (!feeCodeTable.Rows[i]["NAME"].ToString().Trim().Equals("")) // { // feeCodeBuilder.Append(""); // } //} feeCodeBuilder.Append(""); return feeCodeBuilder.ToString(); } #endregion #region 获取集装箱信息下拉列表 /// /// 获取集装箱信息下拉列表 /// /// /// public string GetUnitCells(string strUnitValue) { StringBuilder unitBuilder = new StringBuilder(); unitBuilder.Append("" + strUnitValue); //unitBuilder.Append(""); //unitBuilder.Append(""); //unitBuilder.Append(""); //unitBuilder.Append(""); //unitBuilder.Append(""); unitBuilder.Append(""); return unitBuilder.ToString(); } #endregion #region 集装箱(op_ctn)信息,返回JSON数据源 /// /// 集装箱(op_ctn)信息,返回JSON数据源 /// /// 返回JSON数据源 private string GetUnitCells() { //获取op_ctn信息TopCtnEntity集 IList CodeCtnSetEntities = new List(); CodeCtnSetDA CodeCtnSetDA = new CodeCtnSetDA(); CodeCtnSetEntities = CodeCtnSetDA.GetAllCodeCtnSet(); StringBuilder sourceBuilder = new StringBuilder(); StringBuilder itemBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("ctns:["); if (CodeCtnSetEntities.Count > 0) { foreach (CodeCtnSetEntity ctnEntity in CodeCtnSetEntities) { itemBuilder.Append("{name:\"" + ctnEntity.CTN + "\","); itemBuilder.Append("num:" + ctnEntity.CTNSIZE + ""); itemBuilder.Append("},"); } if (itemBuilder.ToString().EndsWith(",")) { sourceBuilder.Append(itemBuilder.ToString().Trim().Substring(0, itemBuilder.ToString().Trim().Length - 1)); } else { sourceBuilder.Append(itemBuilder.ToString()); } } else { itemBuilder.Append("{name:\"\","); itemBuilder.Append("num:0"); itemBuilder.Append("}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion #region 返回info_client的船公司JSON字符串 /// /// 返回info_client的船公司JSON字符串 /// /// 返回info_client的船公司JSON字符串 public string GetCRMClientCells() { CurrencyDA currencyDA = new CurrencyDA(); DataTable sourceTable; string strSql = "SELECT GID,CODENAME,SHORTNAME FROM info_client where ISCARRIER=1 ORDER BY CODENAME ASC"; sourceTable = currencyDA.GetExcuteSql(strSql).Tables[0]; StringBuilder sourceBuilder = new StringBuilder(); sourceBuilder.Append("{"); sourceBuilder.Append("customer:["); for (int i = 0; i < sourceTable.Rows.Count; i++) { if (i == 0) { sourceBuilder.Append("{id:\"\","); sourceBuilder.Append("\"code\":\"\","); sourceBuilder.Append("\"name\":\"\"},"); sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } else { sourceBuilder.Append(",{id:\"" + sourceTable.Rows[i][0].ToString() + "\","); } sourceBuilder.Append("\"code\":\"" + sourceTable.Rows[i][1].ToString() + "\","); sourceBuilder.Append("\"name\":\"" + sourceTable.Rows[i][2].ToString() + "\"}"); } sourceBuilder.Append("]"); sourceBuilder.Append("}"); return sourceBuilder.ToString(); } #endregion // } }