public void Bind() { string msg = "商城数据"; switch (BinType) { case 0: groupBox1.Text = "全部数据(" + msg + ")"; break; case 1: groupBox1.Text = "未映射数据(" + msg + ")"; break; case 2: groupBox1.Text = "已映射数据(" + msg + ")"; break; } soso.syntoolSoapClient bll = new soso.syntoolSoapClient(); var li = bll.GetShopList(PageSize, PageIndex, order, orderField, like, whereField, sqlext, BinType, Login.authKey, iden); if (BinType == 1) { dataGridViewX1.Columns["sup"].Visible = false; } else { dataGridViewX1.Columns["sup"].Visible = true; } if (li != null) { //取商品流向设置 DataTable lx = bll.GetLiuXiangList(Login.authKey); var dt = li.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { //动态添加价格类型 string ID = dt.Rows[i]["spid"].ToString(); DataTable PriceTable = bll.GetPriceByID(ID); if (PriceTable != null && PriceTable.Rows.Count > 0) { foreach (DataRow dr in PriceTable.Rows) { string tempcategory = dr["category"] == null ? string.Empty : dr["category"].ToString(); decimal tempprice = dr["price_n"] == null ? 0 : Convert.ToDecimal(dr["price_n"]); //添加新列 if (!dt.Columns.Contains(tempcategory)) { dt.Columns.Add(tempcategory, typeof(string)); if (!dataGridViewX1.Columns.Contains(tempcategory)) { dataGridViewX1.Columns.Insert(13, new DataGridViewTextBoxColumn() { HeaderText = tempcategory, DataPropertyName = tempcategory, Name = tempcategory }); } } dt.Rows[i][tempcategory] = tempprice; } } } dataGridViewX1.DataSource = dt; recordCount = int.Parse(li.Tables[1].Rows[0]["recordCount"].ToString()); pageCount = int.Parse(li.Tables[1].Rows[0]["pageCount"].ToString()); paginger(); labelX1.Text = string.Format("共{0}条记录", recordCount); } else { MessageBox.Show("您的登陆状态已经失效,请关闭后重新登陆!", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } }