private void buttonDelete_Click(object sender, EventArgs e) { //Xóa Đối tượng được lựa chọn if (temp != null) { if (MessageBox.Show("Bạn có chắc chắn muốn xóa Khách Hàng này ? ", "Thông Báo", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } else { try { GlobalConfig.Connection.DeleteCustomer(temp); MessageBox.Show("Xóa Thành Công", "Thông Báo", MessageBoxButtons.OK); temp = null; ClearData(); WireData(); } catch { MessageBox.Show("Có lỗi Xóa không thành công ", "Thông Báo", MessageBoxButtons.OK); } } } else { MessageBox.Show("Hãy chọn 1 hàng trên danh sách ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 停用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmDisable_Click(object sender, EventArgs e) { //获取选中的整行数据 Model_Customer editCustomer = dataGridView1.SelectedRows[0].Tag as Model_Customer; editCustomer.Activedk__BackingField = Enum_Active.Disable; try { ResultModelOfModel_Customerd4FqxSXX customer = cs.EditCustomer(editCustomer); if (customer.Code != 0) { MessageBox.Show(customer.Message); } else { MessageBox.Show("操作成功"); //customerLoad(); AvGue(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 检测顶级企业的登陆用户是否存在 /// </summary> /// <param name="userName">登陆名</param> /// <param name="password">登陆密码</param> /// <returns></returns> public static Model_Customer CheckCustomerUser(string userName, string password) { string sql = "select * from customer where role = 1 and actived = 0 limit 1;"; Model_Customer customer = _SqlHelp.ExecuteObject <Model_Customer>(sql); if (customer == null) { throw new Exception("顶级企业不存在!"); } sql = "select * from customer_users where userName=?p1 and customerId = ?p2 limit 1;"; MySqlParameter[] p = new MySqlParameter[2]; p[0] = new MySqlParameter("p1", userName); p[1] = new MySqlParameter("p2", customer.Id); Model_CustomerUser user = _SqlHelp.ExecuteObject <Model_CustomerUser>(sql, p); if (user == null) { throw new Exception(string.Format("用户名'{0}'不存在!", userName)); } if (user.Password.ToUpper() != MyTool.UserMd5(password).ToUpper()) { throw new Exception("密码不正确!"); } if (user.Actived == Model.MyEnum.Enum_Active.Disable) { throw new Exception("用户已停用"); } return(customer); }
/// <summary> /// 模糊 /// </summary> /// <param name="customer"></param> /// <param name="pageIndexAndCount"></param> /// <returns></returns> public static List <Model_Customer> GetCustomerVageue(Model_Customer customer, string pageIndexAndCount) { if (customer == null) { throw new Exception("没有客户信息"); } string sql = "select * from customer where role = 3 "; if (customer.ProvinceId != 0 && customer.CityId != 0) { sql += " and provinceId=?provinceId and cityId=?cityId "; } if (customer.FullName != null) { sql += " and fullName like '%" + customer.FullName + "%'"; } if (pageIndexAndCount != null) { //截取当前页数 string page = pageIndexAndCount.Substring(0, pageIndexAndCount.LastIndexOf(".")); //截取每页显示记录数 string size = pageIndexAndCount.Substring(pageIndexAndCount.LastIndexOf(".") + 1, pageIndexAndCount.Length - (pageIndexAndCount.LastIndexOf(".") + 1)); sql += " order by createAt desc limit " + ((Convert.ToInt32(page) - 1) * Convert.ToInt32(size)) + "," + size + ";"; } sql += " ;"; MySqlParameter[] para = new MySqlParameter[2]; para[0] = new MySqlParameter("provinceId", customer.ProvinceId); para[1] = new MySqlParameter("cityId", customer.CityId); List <Model_Customer> cust = _SqlHelp.ExecuteObjects <Model_Customer>(sql, para); return(cust); }
/// <summary> /// 根据省市县或是客户名称查询收货单位 /// </summary> /// <param name="customer"></param> /// <param name="pageIndexAndCount"></param> /// <returns></returns> public static List <Model_Customer> GetConsigneeCounty(Model_Customer customer, string pageIndexAndCount) { if (customer == null) { throw new Exception("没有客户信息"); } string sql = "select id,fullName,contactperson,contactTel,contactAddress," + "provinceId,provinceName,cityId,cityName,countyId,countyName,account," + "role,actived,createAt,concat_ws('|',if(isnull(remark),'',remark),if(isnull(BindReceiverOrg),'',BindReceiverOrg)) remark from customer where role = 3 "; if (customer.ProvinceId != 0 && customer.CityId != 0 && customer.CountyId != 0) { sql += " and provinceId=?provinceId and cityId=?cityId and countyId=?countyId "; } if (customer.FullName != null) { sql += " and fullName like '%" + customer.FullName + "%'"; } if (pageIndexAndCount != null) { //截取当前页数 string page = pageIndexAndCount.Substring(0, pageIndexAndCount.LastIndexOf(".")); //截取每页显示记录数 string size = pageIndexAndCount.Substring(pageIndexAndCount.LastIndexOf(".") + 1, pageIndexAndCount.Length - (pageIndexAndCount.LastIndexOf(".") + 1)); sql += " order by createAt desc limit " + ((Convert.ToInt32(page) - 1) * Convert.ToInt32(size)) + "," + size + ";"; } sql += " ;"; MySqlParameter[] para = new MySqlParameter[3]; para[0] = new MySqlParameter("provinceId", customer.ProvinceId); para[1] = new MySqlParameter("cityId", customer.CityId); para[2] = new MySqlParameter("countyId", customer.CountyId); List <Model_Customer> cust = _SqlHelp.ExecuteObjects <Model_Customer>(sql, para); return(cust); }
/// <summary> /// 根据省市县或是客户名称查询收货单位总数 /// </summary> /// <param name="customer"></param> /// <returns></returns> public static int GetConsigneeCountyCount(Model_Customer customer) { if (customer == null) { throw new Exception("没有客户信息"); } string sql = "select count(*) from customer where role = 3 "; if (customer.ProvinceId != 0 && customer.CityId != 0 && customer.CountyId != 0) { sql += " and provinceId=?provinceId and cityId=?cityId and countyId=?countyId "; } if (customer.FullName != null) { sql += " and fullName like '%" + customer.FullName + "%'"; } sql += " ;"; MySqlParameter[] para = new MySqlParameter[3]; para[0] = new MySqlParameter("provinceId", customer.ProvinceId); para[1] = new MySqlParameter("cityId", customer.CityId); para[2] = new MySqlParameter("countyId", customer.CountyId); int result = Convert.ToInt32(_SqlHelp.ExecuteScalar(sql, para)); return(result); }
/// <summary> /// 加载客户名称 /// </summary> public void deliverGoods() { try { ResultModelOfArrayOfModel_Customerd4FqxSXX customername = cs.GetCustomerList(Enum_Role.Sender, true, 0, true, 0, true, 0, true, null); if (customername.Code != 0) { MessageBox.Show(customername.Message); } else { List <Model_Customer> list = new List <Model_Customer>(); Model_Customer msc = new Model_Customer(); msc.Idk__BackingField = 0; msc.FullNamek__BackingField = "全部"; list.Add(msc); foreach (Model_Customer item in customername.Data) { Model_Customer mc = new Model_Customer(); mc.Idk__BackingField = item.Idk__BackingField; mc.FullNamek__BackingField = item.FullNamek__BackingField; list.Add(mc); } cmbdeliverGoods.DisplayMember = "fullNamek__BackingField"; cmbdeliverGoods.ValueMember = "idk__BackingField"; cmbdeliverGoods.DataSource = list; } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 账号管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmAccount_Click(object sender, EventArgs e) { Model_Customer customer = dataGridView1.SelectedRows[0].Tag as Model_Customer; FrmConsigneeMaintenanceID maintenanceid = new FrmConsigneeMaintenanceID(); maintenanceid.Customers = customer; maintenanceid.ShowDialog(); }
/// <summary> /// 根据客户表的id查询,并返回值给CustomerUserServer /// </summary> /// <param name="customerId"></param> /// <returns></returns> public static Model_Customer GetQueryCustomer(int customerId) { string sql = "select * from customer where id=?id"; MySqlParameter[] para = new MySqlParameter[1]; para[0] = new MySqlParameter("id", customerId); Model_Customer customer = _SqlHelp.ExecuteObject <Model_Customer>(sql, para); return(customer); }
/// <summary> /// Xóa Khách hàng /// </summary> public void DeleteCustomer(Model_Customer model) { DynamicParameters p = new DynamicParameters(); p.Add("@CustomerID", model.ID); using (IDbConnection connection = new SqlConnection(GlobalConfig.ConnectionString("Clothes"))) { connection.Execute("Delete_Customer", p, commandType: CommandType.StoredProcedure); } }
public static Model_Customer GetAccount(Model_Customer customer) { //查询登陆账号是否存在 string sql = "select * from customer where account=?account"; MySqlParameter[] pa = new MySqlParameter[1]; pa[0] = new MySqlParameter("account", customer.Account); Model_Customer user = _SqlHelp.ExecuteObject <Model_Customer>(sql, pa); return(user); }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmEdit_Click(object sender, EventArgs e) { Model_Customer customer = dataGridView1.SelectedRows[0].Tag as Model_Customer; FrmConsigneeMaintenanceNew maintenance = new FrmConsigneeMaintenanceNew(); maintenance.Customers = customer; maintenance._ParentMaintenace = this; maintenance.ShowDialog(); //customerLoad(); AvGue(); }
/// <summary> /// 账号管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmAccount_Click(object sender, EventArgs e) { //string Id = dataGridView1.SelectedCells[0].Value.ToString(); //string Name = dataGridView1.SelectedCells[1].Value.ToString(); Model_Customer customs = dataGridView1.SelectedRows[0].Tag as Model_Customer; FrmCooperativeClientID clientid = new FrmCooperativeClientID(); //clientid.ID = Id.Trim(); //clientid.fullName = Name.Trim(); clientid.customs = customs; clientid.ShowDialog(); }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmEdit_Click(object sender, EventArgs e) { //string id =dataGridView1.SelectedCells[0].Value.ToString(); Model_Customer cust = dataGridView1.SelectedRows[0].Tag as Model_Customer; FrmCooperativeClientNew clinetnew = new FrmCooperativeClientNew(); //clinetnew.ID = id.Trim() ; clinetnew.cust = cust; clinetnew._ParentClientList = this; clinetnew.ShowDialog(); getCustomer(); }
public void UpdateCustomer(Model_Customer model) { DynamicParameters p = new DynamicParameters(); p.Add("@CustomerID", model.ID); p.Add("@Name", model.Name); p.Add("@PhoneNumber", model.PhoneNumber); p.Add("@Address", model.Address); using (IDbConnection connection = new SqlConnection(GlobalConfig.ConnectionString("Clothes"))) { connection.Execute("UpdateCustomer", p, commandType: CommandType.StoredProcedure); } }
/// <summary> /// 停用状态修改只读状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { Model_Customer customer = dataGridView1.SelectedRows[0].Tag as Model_Customer; if (customer.Activedk__BackingField == Enum_Active.Enabled) { tsmDisable.Enabled = true; } else { tsmDisable.Enabled = false; } }
//Tạo Khách hàng mới public Model_Customer InsertNewCustomer(Model_Customer model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.ConnectionString("Clothes"))) { var p = new DynamicParameters(); p.Add("@Name", model.Name); p.Add("@Address", model.Address); p.Add("@PhoneNumber", model.PhoneNumber); p.Add("@ID", "", DbType.String, direction: ParameterDirection.Output); connection.Execute("dbo.InsertNewCustomer", p, commandType: CommandType.StoredProcedure); p.Get <string>("@ID"); return(model); } }
/// <summary> /// 编辑客户信息 /// </summary> /// <param name="customerInfo">客户信息</param> /// <returns></returns> public ResultModel <Model_Customer> EditCustomer(Model_Customer customerInfo) { ResultModel <Model_Customer> result = new ResultModel <Model_Customer>(); try { result.Data = CustomerServer.CustomerNew(customerInfo); } catch (Exception ex) { result.Code = 1; result.Message = ex.Message; } return(result); }
/// <summary> /// 根据省市县或是客户名称查询收货单位总数 /// </summary> /// <param name="customer"></param> /// <returns></returns> public ResultModel <int> GetConsigneeCountyCount(Model_Customer customer) { ResultModel <int> result = new ResultModel <int>(); try { result.Data = CustomerServer.GetConsigneeCountyCount(customer); } catch (Exception ex) { result.Code = 1; result.Message = ex.Message; } return(result); }
/// <summary> /// 根据省市县或是客户名称查询收货单位 /// </summary> /// <param name="customer"></param> /// <param name="pageIndexAndCount"></param> /// <returns></returns> public ResultModel <List <Model_Customer> > GetConsigneeCounty(Model_Customer customer, string pageIndexAndCount = null) { ResultModel <List <Model_Customer> > result = new ResultModel <List <Model_Customer> >(); try { result.Data = CustomerServer.GetConsigneeCounty(customer, pageIndexAndCount); } catch (Exception ex) { result.Code = 1; result.Message = ex.Message; } return(result); }
/// <summary> /// 新增和修改客户信息更新时间 /// </summary> /// <param name="customerInfo"></param> /// <returns></returns> public ResultModel <Model_Customer> GetCustomerUpdateTime(Model_Customer customerInfo) { ResultModel <Model_Customer> result = new ResultModel <Model_Customer>(); try { result.Data = CustomerServer.GetCustomerUpdateTime(customerInfo); } catch (Exception ex) { result.Code = 1; result.Message = ex.Message; } return(result); }
/// <summary> /// 新增或更新客户信息 /// </summary> /// <param name="customerInfo">客户信息</param> /// <param name="bindReceiverOrg">与第三方运单收货单位关联的名称</param> /// <returns></returns> public ResultModel <bool> UpdateCustomer(Model_Customer customerInfo, string bindReceiverOrg) { ResultModel <bool> result = new ResultModel <bool>(); try { result.Data = CustomerServer.UpdateCustomer(customerInfo, bindReceiverOrg); } catch (Exception ex) { result.Code = 1; result.Message = ex.Message; } return(result); }
private void buttonOK_Click(object sender, EventArgs e) { if (ValidateForm()) { Model_Customer model = new Model_Customer(textBoxName.Text, textBoxAddress.Text, textBoxPhoneNumber.Text); try { GlobalConfig.Connection.InsertNewCustomer(model); MessageBox.Show("Thêm Thành công", "Thông báo", MessageBoxButtons.OK); this.Dispose(); } catch { MessageBox.Show("Có lỗi xảy ra khi truy vấn SQL liên hệ thảo fix ", "Thông báo", MessageBoxButtons.OK); } } }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Model_Customer mcust = new Model_Customer(); mcust.Rolek__BackingField = Enum_Role.Administrator; // mcust.Idk__BackingField = cus.Idk__BackingField; mcust.FullNamek__BackingField = cus.FullNamek__BackingField; // FrmAccountsEdit edit = new FrmAccountsEdit(); edit._ParentFrm = this; //edit.ID =cumerid.ToString(); //edit.UserName = cumername; edit.mcust = mcust; edit.ShowDialog(); getCustomerLoad(); }
private void buttonSave_Click(object sender, EventArgs e) { Model_Customer model = new Model_Customer(textBoxName.Text, textBoxAddress.Text, textBoxPhoneNumber.Text); model.ID = textBoxID.Text; try { GlobalConfig.Connection.UpdateCustomer(model); MessageBox.Show($"Sửa thông tin khách hàng mã {model.ID} thành công", "Thông Báo", MessageBoxButtons.OK); ResetButton(); WireData(); buttonSave.Visible = false; } catch { MessageBox.Show("Có lỗi Sửa không thành công ", "Thông Báo", MessageBoxButtons.OK); } }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Model_Customer mcust = new Model_Customer(); mcust.Rolek__BackingField = Customers.Rolek__BackingField; // mcust.Idk__BackingField = Customers.Idk__BackingField; mcust.FullNamek__BackingField = Customers.FullNamek__BackingField; // FrmAccountsEdit edit = new FrmAccountsEdit(); edit._ParentMaint = this; //edit.ID = Customers.Idk__BackingField.ToString(); //edit.UserName = Customers.FullNamek__BackingField; edit.mcust = mcust; edit.ShowDialog(); CoumterUserLoad(); }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Model_Customer mcus = new Model_Customer(); mcus.Rolek__BackingField = customs.Rolek__BackingField; // mcus.Idk__BackingField = customs.Idk__BackingField; mcus.FullNamek__BackingField = customs.FullNamek__BackingField; // FrmAccountsEdit edit = new FrmAccountsEdit(); edit._ParentClient = this; //edit.UserName = fullName; //edit.ID = ID; edit.mcust = mcus; edit.ShowDialog(); CustomerUserLoad(); }
public void receivingGoodss() { try { string a = "1"; if (cmbCity.Text != string.Empty) { a = cmbCity.SelectedValue.ToString(); } ResultModelOfArrayOfModel_Customerd4FqxSXX customername = cs.GetDownstreamQZList(a); if (customername.Code != 0) { MessageBox.Show(customername.Message); } else { List <Model_Customer> list = new List <Model_Customer>(); Model_Customer msc = new Model_Customer(); msc.Idk__BackingField = 0; msc.FullNamek__BackingField = "全部"; list.Add(msc); foreach (Model_Customer item in customername.Data) { Model_Customer mc = new Model_Customer(); mc.Idk__BackingField = item.Idk__BackingField; mc.FullNamek__BackingField = item.FullNamek__BackingField; list.Add(mc); } funll = new Dictionary <int, string>(); foreach (Model_Customer item in list) { funll.Add(item.Idk__BackingField, item.FullNamek__BackingField); } cmbReceivingGoods.Items.Clear(); cmbReceivingGoods.Items.AddRange(funll.Values.ToArray()); cmbReceivingGoods.Text = "全部"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 下游客户 /// </summary> public void receivingGoods() { try { ResultModelOfArrayOfModel_Customerd4FqxSXX customername = cs.GetCustomerList(Enum_Role.Receiver, true, 0, true, 0, true, 0, true, null); if (customername.Code != 0) { MessageBox.Show(customername.Message); } else { List <Model_Customer> list = new List <Model_Customer>(); Model_Customer msc = new Model_Customer(); msc.Idk__BackingField = 0; msc.FullNamek__BackingField = "全部"; list.Add(msc); foreach (Model_Customer item in customername.Data) { Model_Customer mc = new Model_Customer(); mc.Idk__BackingField = item.Idk__BackingField; mc.FullNamek__BackingField = item.FullNamek__BackingField; list.Add(mc); } //cmbReceivingGoods.DisplayMember = "fullNamek__BackingField"; //cmbReceivingGoods.ValueMember = "idk__BackingField"; //cmbReceivingGoods.DataSource = list; //fullNameList = list.Select(l => l.FullNamek__BackingField).ToList(); foreach (Model_Customer item in list) { funll.Add(item.Idk__BackingField, item.FullNamek__BackingField); } cmbReceivingGoods.Items.AddRange(funll.Values.ToArray()); cmbReceivingGoods.Text = "全部"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmEdit_Click(object sender, EventArgs e) { Model_Customer mcust = new Model_Customer(); mcust.Rolek__BackingField = Enum_Role.Administrator; // mcust.Idk__BackingField = cus.Idk__BackingField; mcust.FullNamek__BackingField = cus.FullNamek__BackingField; // Model_CustomerUser cususer = dataGridView1.SelectedRows[0].Tag as Model_CustomerUser; FrmAccountsEdit edit = new FrmAccountsEdit(); edit._ParentFrm = this; edit.customeruser = cususer; //edit.ID = cumerid.ToString(); //edit.UserName = cumername; edit.mcust = mcust; edit.ShowDialog(); getCustomerLoad(); }