C# 仓库仓位控件联动并且填充到gridview中

场景:两个buttonedit控件,仓库改变时,联动填入仓位数据,并且将gridview仓位列渲染成下列框填入仓位数据

代码:

   private void slkpWareHouseCode_EditValueChanged(object sender, EventArgs e)
        {
            if (slkpWareHouseCode.EditValue != null && slkpWareHouseCode.EditValue != DBNull.Value)
            {
                SetGridCol(slkpWareHouseCode.EditValue.ToString());
            }
        }

        private void SetGridCol(string WareHouse)
        {
            DataSet ds;
            string sql, errormsg;

            sql = "select 仓位 from PUBLIC_WAREHOUSEAREA where 仓库编码= " + "'" + WareHouse + "'";
            int ret = WcfClient.ExecuteSQLToQuery(sql, out ds, out errormsg);
            if (ret == 0 && ds.Tables.Count > 0)
            {

                DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit ra2 = new DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit();
                ra2.NullText = null;
                ra2.DataSource = ds.Tables[0];

                ra2.DisplayMember = "仓位";

                ra2.ValueMember = "仓位"; // "ColumnDesc";

               
                ra2.ImmediatePopup = true;


                ra2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;

                DevExpress.XtraGrid.Columns.GridColumn GridCol = gridView1.Columns["WareHouseAreaCode"];

                GridCol.ColumnEdit = ra2;

                for (int i = 0; i < lkpWareHouseAreaCode.Properties.Buttons.Count; i++)
                {
                    if (lkpWareHouseAreaCode.Properties.Buttons[i].Tag != null && lkpWareHouseAreaCode.Properties.Buttons[i].Tag .ToString()== "Delete")
                    {
                        lkpWareHouseAreaCode.Properties.Buttons.RemoveAt(i);
                    }
                }

                Utils.LookUpDataBind(ds, "仓位", "仓位", lkpWareHouseAreaCode);
            }

        }

你可能感兴趣的:(c#,数据库,开发语言)