private void txtCustomer_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtCustomer.Text.Trim()) && !string.IsNullOrEmpty(this.txtReported.Text.Trim())) { BaseCustomerReportedTable CustomerReportedCode = new BaseCustomerReportedTable(); CustomerReportedCode = bCustomerReported.GetModel(txtCustomer.Text, txtReported.Text); if (CustomerReportedCode != null) { txtCustomer.Text = ""; txtReported.Text = ""; txtCustomer.Focus(); MessageBox.Show("代理店与报备名称已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } //if (!string.IsNullOrEmpty(txtCustomer.Text.Trim())) //{ // BaseMaster baseMaster = bCommon.GetBaseMaster("CUSTOMER", txtCustomer.Text.Trim()); // if (baseMaster != null) // { // txtCustomer.Text = baseMaster.Code; // txtCustomerName.Text = baseMaster.Name; // } // else // { // MessageBox.Show("代理店不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); // txtCustomer.Text = ""; // txtCustomerName.Text = ""; // txtCustomer.Focus(); // } //} //else //{ // txtCustomerName.Text = ""; //} string customerCode = txtCustomer.Text.Trim(); if (customerCode != "") { BaseMaster baseMaster = bCommon.GetBaseMaster("CUSTOMER", customerCode, "TYPE = 1"); if (baseMaster != null) { txtCustomer.Text = baseMaster.Code; txtCustomerName.Text = baseMaster.Name; } else { MessageBox.Show("代理店不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCustomer.Text = ""; txtCustomerName.Text = ""; txtCustomer.Focus(); } } else { txtCustomerName.Text = ""; } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string ccode = dgvData.SelectedRows[0].Cells[0].Value.ToString(); string rcode = dgvData.SelectedRows[0].Cells[2].Value.ToString(); if (ccode != "" && rcode != "") { _currentCustomerReportedTable = bCustomerReported.GetModel(ccode, rcode); } } catch (Exception ex) { } if (_currentCustomerReportedTable == null || _currentCustomerReportedTable.CUSTOMER_CODE == null || "".Equals(_currentCustomerReportedTable.CUSTOMER_CODE)) { _currentCustomerReportedTable = null; } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentCustomerReportedTable != null) { FrmCustomerReportedDialog frm = new FrmCustomerReportedDialog(); frm.UserInfo = _userInfo; frm.CurrentCustomerReportedtTable = _currentCustomerReportedTable; frm.Mode = mode; DialogResult resule = frm.ShowDialog(this); if (resule == DialogResult.OK && isSearch) { Search(this.pgControl.GetCurrentPage()); } frm.Dispose(); } else { //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentCustomerReportedTable = null; }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentCustomerReportedTable == null) { _currentCustomerReportedTable = new BaseCustomerReportedTable(); } _currentCustomerReportedTable.CUSTOMER_CODE = txtCustomer.Text.Trim(); _currentCustomerReportedTable.CUSTOMER_REPORTED_CODE = txtReported.Text.Trim(); _currentCustomerReportedTable.REPORTED_DATE = ReportedDate.Value; _currentCustomerReportedTable.EFFECTIVE_DATE = EffectiveDate.Value; _currentCustomerReportedTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bCustomerReported.Exists(txtCustomer.Text.Trim(), txtReported.Text.Trim())) { bCustomerReported.Update(_currentCustomerReportedTable); } else { _currentCustomerReportedTable.CREATE_USER = _userInfo.CODE; bCustomerReported.Add(_currentCustomerReportedTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
/// <summary> /// 删除 /// </summary> private void MasterToolBar_DoDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK) { try { GetCurrentSelectedTable(); if (_currentCustomerReportedTable != null) { bCustomerReported.Delete(_currentCustomerReportedTable.CUSTOMER_CODE, _currentCustomerReportedTable.CUSTOMER_REPORTED_CODE); Search(this.pgControl.GetCurrentPage()); } else { MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentCustomerReportedTable = null; } }
public override string[] doUpdateDB() { BaseCustomerReportedTable CustomerReportedTable = null; BCustomerReported bCustomerReported = new BCustomerReported(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //客户编号 str.Append(CheckCustomer(CConvert.ToString(GetValue(dr, "CUSTOMER_CODE")), "客户编号")); //报备客户名称 str.Append(CheckCustomer(CConvert.ToString(GetValue(dr, "CUSTOMER_REPORTED_CODE")), "报备客户名称")); //报备日期 str.Append(CheckDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now), "报备日期")); //有效日期 str.Append(CheckDateTime(GetValue(dr, "EFFECTIVE_DATE", DateTime.Now.AddMonths(3)), "有效日期")); //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { CustomerReportedTable = new BaseCustomerReportedTable(); CustomerReportedTable.CUSTOMER_CODE = CConvert.ToString(GetValue(dr, "CUSTOMER_CODE")); CustomerReportedTable.CUSTOMER_REPORTED_CODE = CConvert.ToString(GetValue(dr, "CUSTOMER_REPORTED_CODE")); CustomerReportedTable.REPORTED_DATE = CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now)); CustomerReportedTable.CREATE_USER = _userInfo.CODE; CustomerReportedTable.LAST_UPDATE_USER = _userInfo.CODE; if (CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now)) != DateTime.Now) { CustomerReportedTable.EFFECTIVE_DATE = CConvert.ToDateTime(GetValue(dr, "REPORTED_DATE", DateTime.Now)).AddMonths(3); } else { CustomerReportedTable.EFFECTIVE_DATE = CConvert.ToDateTime(GetValue(dr, "EFFECTIVE_DATE", DateTime.Now.AddMonths(3))); } CustomerReportedTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); if (!bCustomerReported.Exists(CustomerReportedTable.CUSTOMER_CODE, CustomerReportedTable.CUSTOMER_REPORTED_CODE)) { bCustomerReported.Add(CustomerReportedTable); } else { bCustomerReported.Update(CustomerReportedTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseCustomerReportedTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseCustomerReportedTable model) { return(dal.Add(model)); }