/// <summary> /// 获得数据列表 /// </summary> public List <CustomerService.Model.CustomerGroup> DataTableToList(DataTable dt) { List <CustomerService.Model.CustomerGroup> modelList = new List <CustomerService.Model.CustomerGroup>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CustomerService.Model.CustomerGroup model; for (int n = 0; n < rowsCount; n++) { model = new CustomerService.Model.CustomerGroup(); if (dt.Rows[n]["GUID"] != null && dt.Rows[n]["GUID"].ToString() != "") { model.GUID = new Guid(dt.Rows[n]["GUID"].ToString()); } if (dt.Rows[n]["cName"] != null && dt.Rows[n]["cName"].ToString() != "") { model.cName = dt.Rows[n]["cName"].ToString(); } if (dt.Rows[n]["parentGUID"] != null && dt.Rows[n]["parentGUID"].ToString() != "") { model.parentGUID = new Guid(dt.Rows[n]["parentGUID"].ToString()); } if (dt.Rows[n]["createDate"] != null && dt.Rows[n]["createDate"].ToString() != "") { model.createDate = DateTime.Parse(dt.Rows[n]["createDate"].ToString()); } modelList.Add(model); } } return(modelList); }
private void 修改客户组2ToolStripMenuItem_Click(object sender, EventArgs e) { Model.CustomerGroup model = new Model.CustomerGroup(); model.GUID = new Guid(this.treeView1.SelectedNode.Name); model.cName = this.treeView1.SelectedNode.Text; frmCustomerGroup frm = new frmCustomerGroup(model); frm.ShowDialog(frmMain.Main); }
private void btnOK_Click(object sender, EventArgs e) { errorProvider1.Clear(); if (string.IsNullOrEmpty(this.txtName.Text.Trim())) { errorProvider1.SetError(txtName, "客户组名称不能为空!"); return; } if (!this.cbxTreeCustomerGroup.ValidateText()) { errorProvider1.SetError(cbxTreeCustomerGroup, "必须选择所属客户组!"); return; } BLL.CustomerGroup bll = new BLL.CustomerGroup(); Model.CustomerGroup model = new Model.CustomerGroup(); model.cName = txtName.Text.Trim(); model.parentGUID = new Guid(this.cbxTreeCustomerGroup.SelectedNode.Name); bool flg = false; try { if (this.Text == "新增客户组") { flg = bll.Add(model); } else { model.GUID = _model.GUID; flg = bll.Update(model); } } catch (Exception ex) { string error = ex.Message; MessageBox.Show("系统出错,请重试!"); return; } if (flg) { MessageBox.Show("操作成功!"); } else { MessageBox.Show("操作失败!"); } this.Close(); frmMain.Main.DockCustomerGroup.GetData(); }
/// <summary> /// 获取条件 /// </summary> /// <returns></returns> private void GetWhere(ref List <string> lst, Guid guid) { lst.Add(string.Format("'{0}'", guid)); BLL.CustomerGroup bll = new BLL.CustomerGroup(); Model.CustomerGroup model = new Model.CustomerGroup(); DataTable dt = bll.GetList(string.Format("parentGUID = '{0}'", guid)).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { GetWhere(ref lst, new Guid(dt.Rows[i][0].ToString())); } }
/// <summary> /// 获取条件 /// </summary> /// <returns></returns> private void GetWhere(ref List<string> lst, Guid guid) { lst.Add(string.Format("'{0}'", guid)); BLL.CustomerGroup bll = new BLL.CustomerGroup(); Model.CustomerGroup model = new Model.CustomerGroup(); DataTable dt = bll.GetList(string.Format("parentGUID = '{0}'", guid)).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { GetWhere(ref lst, new Guid(dt.Rows[i][0].ToString())); } }
public frmCustomerGroup(Model.CustomerGroup model) { InitializeComponent(); _model = model; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(CustomerService.Model.CustomerGroup model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(CustomerService.Model.CustomerGroup model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List<CustomerService.Model.CustomerGroup> DataTableToList(DataTable dt) { List<CustomerService.Model.CustomerGroup> modelList = new List<CustomerService.Model.CustomerGroup>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CustomerService.Model.CustomerGroup model; for (int n = 0; n < rowsCount; n++) { model = new CustomerService.Model.CustomerGroup(); if(dt.Rows[n]["GUID"]!=null && dt.Rows[n]["GUID"].ToString()!="") { model.GUID=new Guid(dt.Rows[n]["GUID"].ToString()); } if(dt.Rows[n]["cName"]!=null && dt.Rows[n]["cName"].ToString()!="") { model.cName=dt.Rows[n]["cName"].ToString(); } if(dt.Rows[n]["parentGUID"]!=null && dt.Rows[n]["parentGUID"].ToString()!="") { model.parentGUID=new Guid(dt.Rows[n]["parentGUID"].ToString()); } if(dt.Rows[n]["createDate"]!=null && dt.Rows[n]["createDate"].ToString()!="") { model.createDate=DateTime.Parse(dt.Rows[n]["createDate"].ToString()); } modelList.Add(model); } } return modelList; }