public static void BindComboBox(ComboBox cmb, ParamParentCode parentCode) { if (ParamDataSet == null || ParamDataSet.Tables[0].Rows.Count == 0) { InitParamDataSet(); } cmb.Items.Clear(); Ctrls.CbbItem item; DataRow[] rows = ParamDataSet.Tables[0].Select(" pcode='" + parentCode.ToString() + "'"); foreach (DataRow dr in rows) { item = new Ctrls.CbbItem(); item.Text = dr["title"].ToString().Trim(); item.Value = dr["code"].ToString().Trim(); item.Name = dr["code"].ToString().Trim(); cmb.Items.Add(item); } }
private static void AddParam(ComboBox cmb, ParamParentCode parent, string title) { try { Hi.BLL.SysAdmin bll = new Hi.BLL.SysAdmin(); DataRow[] rows = ParamDataSet.Tables[0].Select(" pcode='" + parent.ToString() + "'", "code desc"); int count = rows.Length; int tmpCount = count; string pid = "", code = ""; foreach (DataRow dr in rows)//降次排序,取第一条记录,循环一次退出 { code = dr["code"].ToString(); pid = dr["parent_id"].ToString(); int.TryParse(code, out tmpCount); break; } if (count == tmpCount) { tmpCount++; } Hi.Model.BasParam model = new Model.BasParam(); model.Code = tmpCount.ToString(); model.ParentId = pid; model.Title = title; model.EnableFlag = "1"; bool blFlag = bll.ParamAdd(model); if (blFlag) { Ctrls.CbbItem item = new Ctrls.CbbItem(); item.Text = title; item.Name = model.Code; item.Value = model.Code; cmb.Items.Insert(0, item); InitParamDataSet(); } } catch { } }
private static void AddParam(ComboBox cmb, ParamParentCode parent, string title) { try { Hi.BLL.SysAdmin bll =new Hi.BLL.SysAdmin(); DataRow[] rows = ParamDataSet.Tables[0].Select(" pcode='" + parent.ToString() + "'", "code desc"); int count = rows.Length; int tmpCount = count; string pid = "", code = ""; foreach (DataRow dr in rows)//降次排序,取第一条记录,循环一次退出 { code = dr["code"].ToString(); pid = dr["parent_id"].ToString(); int.TryParse(code, out tmpCount); break; } if (count == tmpCount) tmpCount++; Hi.Model.BasParam model = new Model.BasParam(); model.Code = tmpCount.ToString(); model.ParentId = pid; model.Title = title; model.EnableFlag = "1"; bool blFlag = bll.ParamAdd(model); if (blFlag) { Ctrls.CbbItem item = new Ctrls.CbbItem(); item.Text = title; item.Name = model.Code; item.Value = model.Code; cmb.Items.Insert(0, item); InitParamDataSet(); } } catch { } }