public override void Save() { if (Check() == false) { return; } _entity = new FishEntity.CallRecordsEntity(); GetCallRecordFromUI(); _entity.createman = FishEntity.Variable.User.username; _entity.modifyman = _entity.createman; _entity.createtime = DateTime.Now; _entity.modifytime = _entity.createtime; _entity.code = FishBll.Bll.SequenceUtil.GetCallRecordSequence(); while (_bll.Exists(_entity.code)) { _entity.code = FishBll.Bll.SequenceUtil.GetCallRecordSequence(); } int id = _bll.Add(_entity); if (id > 0) { _entity.id = id; txtCode.Text = _entity.code; FishBll.Bll.CompanyBll companyBll = new FishBll.Bll.CompanyBll(); //更新 往来单位 表的 最近联系时间,下次联系时间 companyBll.UpdateCompnayLinkDate(_entity.customercode, _entity.weekestimate, _entity.monthestimate, _entity.currentdate.Value, _entity.BuyDate, _entity.nextdate.Value); FishBll.Bll.CustomerBll customerBll = new FishBll.Bll.CustomerBll(); //更新 联系人 表的 当前联系时间,下次联系时间和 通话记录ID字段 customerBll.UpdateLinkDate(_entity.linkmancode, _entity.currentdate.Value, _entity.id, _entity.nextdate.Value); AddDetail(id, true); //tmiAdd.Visible = true; //tmiModify.Visible = true; //tmiDelete.Visible = true; //tmiQuery.Visible = true; //tmiPrevious.Visible = true; //tmiPrevious.Visible = true; //tmiSave.Visible = false; //tmiCancel.Visible = false; ControlButtomRoles(); MessageBox.Show("添加成功。"); //System.Diagnostics.Process.Start("FormCallRecordsTable.cs"); if (RefreshDataEvent != null) { RefreshDataEvent(this, EventArgs.Empty); } } else { MessageBox.Show("添加失败。"); } }
protected void SetCompanyData(FishEntity.CompanyEntity company) { if (company == null) { return; } txtCompanyName.Text = company.fullname; txtCompanyCode.Text = company.code; txtCompanyCode.Tag = company.id; txtLevel.Text = company.generallevel; txtAddress.Text = company.address; txtLinkMan.Text = string.Empty; txtLinkManCode.Text = string.Empty; txtCustomerNature.Text = company.customerproperty; txtSaleman.Text = company.salesman; txttransportfee.Text = company.freight.ToString(); txtweight.Text = company.tare.ToString(); txtspecifacation.Text = company.requiredproduct; txtQuality.Text = company.productrequire; txtProducts.Text = company.products; txtcompetitors.Text = company.competitors; txtWeek.Text = company.currentweekestimate.ToString(); txtMonth.Text = company.currentmonthestimate.ToString(); FishBll.Bll.CustomerBll customerBll = new FishBll.Bll.CustomerBll(); List <FishEntity.CustomerEntity> customers = customerBll.GetCustomerOfCompany(company.id); if (customers != null && customers.Count > 0) { FishEntity.CustomerEntity customer = customers.Find((i) => { return(i.flag == 1); }); if (customer != null) { txtLinkMan.Text = customer.name; txtLinkManCode.Text = customer.code; txtLinkMan.Tag = customer.id; string phone = string.IsNullOrEmpty(customer.phone1) ? "" : customer.phone1; if (!string.IsNullOrEmpty(customer.phone2)) { phone += string.IsNullOrEmpty(phone) ? customer.phone2 : " , " + customer.phone2; } if (!string.IsNullOrEmpty(customer.phone3)) { phone += string.IsNullOrEmpty(phone) ? customer.phone3 : " , " + customer.phone3; } txtMobile.Text = phone; txtOfficeTel.Text = customer.telephone; } } }
public FormSelectCustomer(int companyId) { InitializeComponent(); this.Text = "请选择联系人"; _companyId = companyId; FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll(); List <FishEntity.CustomerEntity> list = bll.GetCustomerOfCompany(_companyId); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = list; dataGridView1.BackgroundColor = this.BackColor; }
public FormSelectCustomer(string companycode) { InitializeComponent(); ReadColumnConfig(dataGridView1, "Set_SelectCustomer"); this.Text = "请选择联系人"; _companycode = companycode; FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll(); List <FishEntity.CustomerEntity> list = bll.GetCustomerOfCompany(_companycode); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = list; dataGridView1.BackgroundColor = this.BackColor; }
private void txtCustomer_Click(object sender, EventArgs e) { FormCompanyList form = new FormCompanyList(); form.StartPosition = FormStartPosition.CenterParent; if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (form.SelectCompany == null) { return; } txtCustomer.Text = form.SelectCompany.fullname; txtCustomer.Tag = form.SelectCompany.code; FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll(); List <FishEntity.CustomerEntity> mans = bll.GetCustomerOfCompany(form.SelectCompany.id); if (mans == null) { mans = new List <FishEntity.CustomerEntity>(); } cmbTheperson.SelectedValue = form.SelectCompany.salesman; cmbTheperson.Tag = form.SelectCompany.salesmancode; panel2.Controls.Clear(); foreach (FishEntity.CustomerEntity item in mans) { CheckBox chk = new CheckBox(); chk.Text = item.name.Trim(); chk.Tag = item; chk.AutoSize = true; chk.Checked = false; chk.Dock = DockStyle.Left; panel2.Controls.Add(chk); } }
public override int Modify() { if (_entity == null) { MessageBox.Show("请先查询需要修改的记录。"); return(0); } if (Check() == false) { return(0); } GetCallRecordFromUI(); _entity.modifytime = DateTime.Now; _entity.modifyman = FishEntity.Variable.User.username; bool isok = _bll.Update(_entity); if (isok) { FishBll.Bll.CompanyBll companyBll = new FishBll.Bll.CompanyBll(); companyBll.UpdateCompnayLinkDate(_entity.customercode, _entity.weekestimate, _entity.monthestimate, _entity.currentdate.Value, _entity.BuyDate, _entity.nextdate.Value); FishBll.Bll.CustomerBll customerBll = new FishBll.Bll.CustomerBll(); customerBll.UpdateLinkDate(_entity.linkmancode, _entity.currentdate.Value, _entity.id, _entity.nextdate.Value); AddDetail(_entity.id, false); MessageBox.Show("修改成功。"); if (RefreshDataEvent != null) { RefreshDataEvent(this, EventArgs.Empty); } } else { MessageBox.Show("修改失败。"); } return(1); }
public override int Modify() { if (Check() == false) { return(0); } int sourceCompanyId = _customer.companyId; _customer.code = txtCode.Text; int companyId = 0; if (string.IsNullOrEmpty(txtCompany.Text) == false && txtCompany.Tag != null && txtCompany.Tag is FishEntity.CompanyEntity) { FishEntity.CompanyEntity company = txtCompany.Tag as FishEntity.CompanyEntity; _customer.company = company.code; companyId = company.id; _customer.companyId = company.id; } else { _customer.companyId = 0; _customer.company = string.Empty; } _customer.currentlinkDate = dtpCurrentDate.Value; _customer.department = string.Empty; _customer.email = txtEmail.Text; _customer.modifyman = FishEntity.Variable.User.username; _customer.modifytime = DateTime.Now; _customer.name = txtName.Text; _customer.phone1 = txtPhone1.Text; _customer.phone2 = txtPhone2.Text; _customer.phone3 = txtPhone3.Text; _customer.post = txtPost.Text; _customer.Department1 = txtdepartment1.Text; _customer.qq = txtQQ.Text; _customer.remark = txtRemark.Text; _customer.telephone = txtTelephone.Text; _customer.validate = cmbValidate.Text.Equals("有效")?1:0; _customer.weixin = txtWeixin.Text; _customer.homeaddress = txtHomeAddress.Text.Trim(); _customer.officeaddress = txtOfficeAddress.Text.Trim(); _customer.sex = rdbMan.Checked?"男":"女"; _customer.fox = txtfox.Text.Trim(); DateTime nextlinkDate; if (DateTime.TryParse(txtNextLinkDate.Text, out nextlinkDate)) { _customer.nextlinkdate = nextlinkDate; } else { _customer.nextlinkdate = null; } FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll(); bool isOk = bll.Update(_customer); if (isOk) { FishBll.Bll.CustomerOfCompanyBll ccBll = new FishBll.Bll.CustomerOfCompanyBll(); if (_customer.companyId == 0 && sourceCompanyId > 0) { ccBll.Delete(sourceCompanyId, _customer.id); } else if (_customer.companyId > 0 && sourceCompanyId == 0) { FishEntity.CustomerOfCompanyEntity ccEntity = new FishEntity.CustomerOfCompanyEntity(); ccEntity.companyid = _customer.companyId; ccEntity.customerid = _customer.id; ccBll.Add(ccEntity); } else if (_customer.companyId > 0 && sourceCompanyId > 0) { ccBll.Update(sourceCompanyId, _customer.id, _customer.companyId, _customer.id); } SaveHeaderPicture(_customer.id); MessageBox.Show("修改成功。"); } else { MessageBox.Show("修改失败。"); } return(1); }
public override void Save() { if (Check() == false) { return; } _customer = new FishEntity.CustomerEntity(); _customer.code = FishBll.Bll.SequenceUtil.GetCustomerSequence(); int companyId = 0; if (string.IsNullOrEmpty(txtCompany.Text) == false && txtCompany.Tag != null && txtCompany.Tag is FishEntity.CompanyEntity) { FishEntity.CompanyEntity company = txtCompany.Tag as FishEntity.CompanyEntity; _customer.company = company.code; companyId = company.id; _customer.companyId = company.id; } _customer.createman = FishEntity.Variable.User.username; _customer.createtime = DateTime.Now; _customer.currentlinkDate = dtpCurrentDate.Value; _customer.department = string.Empty; _customer.email = txtEmail.Text; _customer.isdelete = 0; _customer.modifyman = _customer.createman; _customer.modifytime = _customer.createtime; _customer.name = txtName.Text; DateTime nextlinkdate; if (DateTime.TryParse(txtNextLinkDate.Text, out nextlinkdate)) { _customer.nextlinkdate = DateTime.Parse(txtNextLinkDate.Text); } else { _customer.nextlinkdate = null; } _customer.phone1 = txtPhone1.Text; _customer.phone2 = txtPhone2.Text; _customer.phone3 = txtPhone3.Text; _customer.post = txtPost.Text; _customer.Department1 = txtdepartment1.Text; _customer.qq = txtQQ.Text; _customer.remark = txtRemark.Text; _customer.telephone = txtTelephone.Text; _customer.validate = cmbValidate.Text.Equals("有效") ? 1 : 0; _customer.weixin = txtWeixin.Text; _customer.homeaddress = txtHomeAddress.Text.Trim(); _customer.officeaddress = txtOfficeAddress.Text.Trim(); _customer.sex = rdbMan.Checked?"男":"女"; _customer.fox = txtfox.Text.Trim(); FishBll.Bll.CustomerBll bll = new FishBll.Bll.CustomerBll(); bool isok = bll.Exists(_customer.code); while (isok) { _customer.code = FishBll.Bll.SequenceUtil.GetCustomerSequence(); isok = bll.Exists(_customer.code); } bool isExistName = bll.ExistsName(_customer.name); if (isExistName) { MessageBox.Show("数据库中存在相同的联系人名称。"); } int id = bll.Add(_customer); if (id > 0) { _customer.id = id; txtCode.Text = _customer.code; FishBll.Bll.CustomerOfCompanyBll ccbll = new FishBll.Bll.CustomerOfCompanyBll(); if (false == string.IsNullOrEmpty(_customer.company)) { FishEntity.CustomerOfCompanyEntity ccEntity = new FishEntity.CustomerOfCompanyEntity(); ccEntity.companyid = companyId; ccEntity.customerid = _customer.id; ccbll.Add(ccEntity); } SaveHeaderPicture(id); tmiAdd.Visible = true; tmiModify.Visible = true; tmiQuery.Visible = true; tmiPrevious.Visible = true; tmiNext.Visible = true; tmiSave.Visible = false; tmiCancel.Visible = false; MessageBox.Show("添加成功。"); } else { txtCode.Text = string.Empty; MessageBox.Show("添加失败。"); } }