private void btn_ok_Click(object sender, EventArgs e) { string varMsg = string.Empty; if (!CheckData(out varMsg)) { new PubUtils().ShowNoteNGMsg(varMsg, 2, grade.OrdinaryError); return; } obj.SupplierCode = txt_suppliesCode.Text.Trim(); obj.SupplierName = txt_suppliesName.Text.Trim(); if (opetrationType == OperationType.Add) { if (Bll_MdcDatSuppliesManage.Query(string.Format("where SupplierCode='{0}'", SqlInput.InputString(txt_suppliesCode.Text.Trim()))).Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("供应商代码已存在", 2, grade.OrdinaryError); return; } if (Bll_MdcDatSuppliesManage.Insert(obj)) { this.DialogResult = DialogResult.OK; obj = new MdcDatSuppliesManage(); this.Close(); } else { new PubUtils().ShowNoteNGMsg("添加失败", 2, grade.OrdinaryError); return; } } else if (opetrationType == OperationType.Edit) { if (!txt_suppliesCode.Text.Trim().Equals(oldSupplierCode)) { if (Bll_MdcDatSuppliesManage.Query(string.Format("where SupplierCode='{0}'", SqlInput.InputString(txt_suppliesCode.Text.Trim()))).Rows.Count > 0) { new PubUtils().ShowNoteNGMsg("供应商代码已存在", 2, grade.OrdinaryError); return; } } if (Bll_MdcDatSuppliesManage.Update(obj, oldSupplierCode)) { this.DialogResult = DialogResult.OK; obj = new MdcDatSuppliesManage(); this.Close(); } else { new PubUtils().ShowNoteNGMsg("修改失败", 2, grade.OrdinaryError); return; } } }
private void btn_del_Click(object sender, EventArgs e) { if (dgvSupplies.CurrentRow == null || dgvSupplies.CurrentRow.Index == -1) { new PubUtils().ShowNoteNGMsg("请选中行", 2, grade.OrdinaryError); return; } if (Bll_MdcDatSuppliesManage.Delete(string.Format(" where SupplierCode='{0}'", dgvSupplies.CurrentRow.Cells["SupplierCode"].Value.ToString()))) { QueryData(); new PubUtils().ShowNoteOKMsg("删除成功"); } }
private void QueryData() { StringBuilder strbuilder = new StringBuilder(" where 1=1 "); if (!string.IsNullOrEmpty(txt_suppliesCode.Text.Trim())) { strbuilder.Append(" and SupplierCode='").Append(txt_suppliesCode.Text.Trim()).Append("'"); } if (!string.IsNullOrEmpty(txt_suppliesName.Text.Trim())) { strbuilder.Append(" and SupplierName='").Append(txt_suppliesName.Text.Trim()).Append("'"); } DataTable dtSupplyies = Bll_MdcDatSuppliesManage.Query(strbuilder.ToString()); dgvSupplies.DataSource = dtSupplyies; }