//2015.6增加银行代收功能后,完善用户信息 private void add_Click(object sender, EventArgs e) { Boolean success = false; success = checkInfo(); //如果验证不成功 if (success == false) { } else { Customer customer = new Customer(); Countfeeinfo countfeeinfo = new Countfeeinfo(); List<Object> list = new List<object>(); //string customerPosition1 = ""; //string customerPosition2 = ""; decimal customerPosition1 = 0; decimal customerPosition2 = 0; if (this.CustomInfoList.SelectedIndex == -1) { MessageBox.Show("选择要添加客户成员的位置"); return; } /* 计算新添加客户的位置 */ if (this.CustomInfoList.Items.Count == (this.CustomInfoList.SelectedIndex + 1)) { if (this.customerAction.getCustomerPositionById(this.CustomInfoList.SelectedItem.ToString().Split(' ')[3], ref customerPosition1) == Constant.OK) { customer.setCustomerPosition(customerPosition1 + 1); } } else { if (this.customerAction.getCustomerPositionById(this.CustomInfoList.SelectedItem.ToString().Split(' ')[3], ref customerPosition1) == Constant.OK && this.customerAction.getCustomerPositionById(this.CustomInfoList.Items[this.CustomInfoList.SelectedIndex + 1].ToString().Split(' ')[3], ref customerPosition2) == Constant.OK) { customer.setCustomerPosition((customerPosition1 + customerPosition2) / 2); } } if ("" == this.CustomerCode_1.Text.ToString().Trim()) { MessageBox.Show("请选择账本信息和所要插入的位置!"); return; } if ("" == this.CustomerCode_2.Text.ToString().Trim()) { MessageBox.Show("填写客户编码!"); return; } customer.setCustomerNo(this.CustomerCode_1.Text.ToString().Trim() + this.CustomerCode_2.Text.ToString().Trim()); if ("" == this.CustomerName.Text.ToString().Trim()) { MessageBox.Show("请输入客户名称"); return; } customer.setCustomerName(this.CustomerName.Text.ToString().Trim()); customer.setCustomerAddress(this.CustomerAddress.Text.ToString()); customer.setPhoneNum(this.txtPhoneNum.Text.ToString()); customer.setLine(this.Line.SelectedValue.ToString().Trim()); customer.setAmmeterType(this.cbxAmmeterType1.SelectedItem.ToString()); customer.setAmmeterNo(this.txtAmmeterNo1.Text.ToString()); customer.setArea(this.AreaType.SelectedItem.ToString().Trim().Split(' ')[0]); customer.setElectriCharacterName(this.ElectriType.SelectedItem.ToString().Trim()); customer.setVoltageFlag(this.VoltageFlag.SelectedItem.ToString().Trim()); customer.setInvoiceType(this.InvoiceType.SelectedItem.ToString().Trim()); //设置身份证号 customer.setIdentificationCard(this.identificationCard.Text.ToString().Trim()); //设置签约标志信息 if (this.sign.Checked) { customer.setSignFlag("1"); } else { customer.setSignFlag("0"); } customer.setOrganFlag("0"); customer.setEspecialFlag("0"); if (this.cbxSpecialFlag.Checked) { customer.setEspecialFlag("1"); } customer.setBankAccount(this.BankAccount.Text.ToString().Trim()); customer.setBankCode(this.BankCode.Text.ToString().Trim()); customer.setBankName(this.Bank.Text.ToString().Trim()); customer.setTradeCode(""); customer.setValueAddTaxNo(""); if (this.LowProtect.Checked) { customer.setLowProtectFlag("1"); } else { customer.setLowProtectFlag("0"); } if (this.BasicEFee.Checked) { customer.setTranslossOrBaseprice("1"); } else { customer.setTranslossOrBaseprice("0"); } customer.setPassword(this.CustomerCode_1.Text.ToString().Trim() + this.CustomerCode_2.Text.ToString().Trim()); countfeeinfo.setCustomerNo(customer.getCustomerNo()); if (null == this.Transformer.SelectedItem || -1 == int.Parse(this.Transformer.SelectedItem.ToString().Trim().Split(' ')[0])) { countfeeinfo.setTransformerNo("0"); } else { countfeeinfo.setTransformerNo(this.Transformer.SelectedItem.ToString().Trim().Split(' ')[0]); } countfeeinfo.setAmmeterMulti(this.Multi.Text.ToString().Trim()); countfeeinfo.setLineLoseRate(this.LineLoseRate.Text.ToString().Trim()); if ("" == this.Discount.Text.ToString().Trim()) { countfeeinfo.setDiscountRate("0"); } else { countfeeinfo.setDiscountRate(this.Discount.Text.ToString().Trim()); } list.Add((Object)customer); list.Add((Object)countfeeinfo); /* 检验该客户编号是否存在 */ bool state = false; if (Constant.OK == this.customerAction.customerNoChecking(customer.getCustomerNo(), ref state)) { if (!state) { MessageBox.Show("该编号已经存在"); return; } } else { MessageBox.Show("数据库执行出错"); return; } /* 添加电价比率信息 */ if (this.PowerPrice_1.SelectedIndex != -1) { PriceRate pr_1 = new PriceRate(); pr_1.PriceNo = int.Parse(this.PowerPrice_1.SelectedValue.ToString()); pr_1.Rate = float.Parse(this.Price1.Text.ToString().Trim()); pr_1.PriceName = customer.getCustomerNo(); list.Add((Object)pr_1); } if (this.PowerPrice_2.SelectedIndex != -1) { PriceRate pr_2 = new PriceRate(); pr_2.PriceNo = int.Parse(this.PowerPrice_2.SelectedValue.ToString()); pr_2.Rate = float.Parse(this.Price2.Text.ToString().Trim()); pr_2.PriceName = customer.getCustomerNo(); list.Add((Object)pr_2); } if (this.PowerPrice_3.SelectedIndex != -1) { PriceRate pr_3 = new PriceRate(); pr_3.PriceNo = int.Parse(this.PowerPrice_3.SelectedValue.ToString()); pr_3.Rate = float.Parse(this.Price3.Text.ToString().Trim()); pr_3.PriceName = customer.getCustomerNo(); list.Add((Object)pr_3); } if (this.PowerPrice_4.SelectedIndex != -1) { PriceRate pr_4 = new PriceRate(); pr_4.PriceNo = int.Parse(this.PowerPrice_4.SelectedValue.ToString()); pr_4.Rate = float.Parse(this.Price4.Text.ToString().Trim()); pr_4.PriceName = customer.getCustomerNo(); list.Add((Object)pr_4); } /*添加客户信息*/ if (Constant.OK == this.customerAction.addCustomerInfo(ref list)) { MessageBox.Show("客户信息添加成功"); this.init_content(); return; } else { MessageBox.Show("客户信息添加失败"); return; } /*添加客户计费信息 if (Constant.OK == this.customerAction.addCountfeeinfo(ref countfeeinfo)) { } else { } */ } }
/** * 根据customerNo获取客户计费的相关信息 * @param string customerNo:客户编号 * @param ref Countfeeinfo countfeeinfo:客户计费信息类的引用 * @return int 值为Constant.OK:执行成功,值为Constant.ERROR为执行出错 * @author Rick **/ public int getCountFeeInfoById(string customerNo, ref Countfeeinfo countfeeinfo) { string strSql = "select * from CountFeeInfo where CustomerNo = '" + customerNo + "'"; DataSet ds = null; try { ds = SQLUtl.Query(strSql); } catch (Exception) { return Constant.ERROR; } if (null != ds && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; countfeeinfo.setCustomerNo(null != dt.Rows[0].ItemArray[0] ? dt.Rows[0].ItemArray[0].ToString() : ""); //countfeeinfo.setTransformerNo(null != dt.Rows[0].ItemArray[1] && dt.Rows[0].ItemArray[1].ToString().Trim() != "0".Trim() ? dt.Rows[0].ItemArray[1].ToString() : "空"); /*查找变压器编号所对应的变压器名称*/ /* if (!(countfeeinfo.getTransformerNo().Trim() == "0".Trim() || countfeeinfo.getTransformerNo().Trim() == "空".Trim())) { string sqlForTF = "select * from TransformerInfo where TransformerNo = " + countfeeinfo.getTransformerNo().Trim() + ""; DataSet ds_tf = null; try { ds_tf = SQLUtl.Query(sqlForTF); } catch (Exception) { // } if (null != ds_tf && ds_tf.Tables[0].Rows.Count != 0) { countfeeinfo.setTransformerNo(null != ds_tf.Tables[0].Rows[0].ItemArray[1] ? ds_tf.Tables[0].Rows[0].ItemArray[1].ToString() : ""); } }*/ countfeeinfo.setTransformerNo(null != dt.Rows[0].ItemArray[1] ? dt.Rows[0].ItemArray[1].ToString() : ""); countfeeinfo.setAmmeterMulti(null != dt.Rows[0].ItemArray[2] ? dt.Rows[0].ItemArray[2].ToString() : ""); countfeeinfo.setAmmeterVolume(null != dt.Rows[0].ItemArray[3] ? dt.Rows[0].ItemArray[3].ToString() : ""); countfeeinfo.setLineLoseRate(null != dt.Rows[0].ItemArray[4] ? dt.Rows[0].ItemArray[4].ToString() : ""); countfeeinfo.setEssenceFee(null != dt.Rows[0].ItemArray[5] ? dt.Rows[0].ItemArray[5].ToString() : ""); countfeeinfo.setCountFeeInfoDate(null != dt.Rows[0].ItemArray[6] ? dt.Rows[0].ItemArray[6].ToString() : ""); countfeeinfo.setDiscountRate(null != dt.Rows[0].ItemArray[7] ? dt.Rows[0].ItemArray[7].ToString() : ""); return Constant.OK; } else { return Constant.ERROR; } }
private void addButton_Click(object sender, EventArgs e) { Customer customer = new Customer(); Countfeeinfo countfeeinfo = new Countfeeinfo(); List<Object> list = new List<object>(); /* 设置客户的位置信息 */ customer.setCustomerPosition(1); customer.setCustomerNo(this.CustomerCode_new.Text.ToString().Trim()); if ("" == this.CustomerName_new.Text.ToString().Trim()) { MessageBox.Show("请输入客户名称!"); return; } customer.setCustomerName(this.CustomerName_new.Text.ToString().Trim()); customer.setCustomerAddress(this.CustomerAddress_new.Text.ToString()); customer.setPhoneNum(this.txtPhoneNum2.Text.ToString()); customer.setLine(this.Line_new.SelectedValue.ToString().Trim()); customer.setArea(this.Area_new.SelectedItem.ToString().Trim().Split(' ')[0]); customer.setAmmeterType(this.cbxAmmeterType2.SelectedItem.ToString()); customer.setAmmeterNo(this.txtAmmeterNo2.Text.ToString()); customer.setElectriCharacterName(this.Electri_new.SelectedItem.ToString().Trim()); customer.setVoltageFlag(this.VoltageFlag_new.SelectedItem.ToString().Trim()); customer.setInvoiceType(this.InvoiceType_new.SelectedItem.ToString().Trim()); //设置身份证号 customer.setIdentificationCard(this.identificationCard.Text.ToString().Trim()); //设置签约标志信息 if (this.sign.Checked) { customer.setSignFlag("1"); } else { customer.setSignFlag("0"); } customer.setOrganFlag("0"); customer.setEspecialFlag("0"); if (this.cbxSpecialFlag.Checked) { customer.setEspecialFlag("1"); } customer.setBankAccount(this.BankAccount_new.Text.ToString().Trim()); customer.setBankCode(this.BankCode_new.Text.ToString().Trim()); customer.setBankName(this.BankName_new.Text.ToString().Trim()); customer.setTradeCode(""); customer.setValueAddTaxNo(""); customer.setPassword(this.CustomerCode_new.Text.ToString().Trim()); if (this.LowProtect.Checked) { customer.setLowProtectFlag("1"); } else { customer.setLowProtectFlag("0"); } if (this.BasicEFee.Checked) { customer.setTranslossOrBaseprice("1"); } else { customer.setTranslossOrBaseprice("0"); } countfeeinfo.setCustomerNo(customer.getCustomerNo()); if (null == this.Transformer_new.SelectedItem || -1 == int.Parse(this.Transformer_new.SelectedItem.ToString().Trim().Split(' ')[0])) { countfeeinfo.setTransformerNo("0"); } else { countfeeinfo.setTransformerNo(this.Transformer_new.SelectedItem.ToString().Trim().Split(' ')[0]); } countfeeinfo.setAmmeterMulti(this.Multip_new.Text.ToString().Trim()); countfeeinfo.setLineLoseRate(this.LineLoseRate_new.Text.ToString().Trim()); if ("" == this.Discount_new.Text.ToString().Trim()) { countfeeinfo.setDiscountRate("0"); } else { countfeeinfo.setDiscountRate(this.Discount_new.Text.ToString().Trim()); } list.Add((Object)customer); list.Add((Object)countfeeinfo); /* 检验该该账本编号是否存在 */ bool state = false; if (Constant.OK == this.customerAction.bookTypeChecking(customer.getCustomerNo(), ref state)) { if (!state) { MessageBox.Show("该账簿号已经存在"); return; } } else { MessageBox.Show("数据库执行出错"); return; } /* 添加电价比率信息 */ if (this.PowerPrice1_new.SelectedIndex != -1) { PriceRate pr_1 = new PriceRate(); pr_1.PriceNo = int.Parse(this.PowerPrice1_new.SelectedValue.ToString()); pr_1.Rate = float.Parse(this.Price1_new.Text.ToString().Trim()); pr_1.PriceName = customer.getCustomerNo(); list.Add((Object)pr_1); } if (this.PowerPrice2_new.SelectedIndex != -1) { PriceRate pr_2 = new PriceRate(); pr_2.PriceNo = int.Parse(this.PowerPrice2_new.SelectedValue.ToString()); pr_2.Rate = float.Parse(this.Price2_new.Text.ToString().Trim()); pr_2.PriceName = customer.getCustomerNo(); list.Add((Object)pr_2); } if (this.PowerPrice3_new.SelectedIndex != -1) { PriceRate pr_3 = new PriceRate(); pr_3.PriceNo = int.Parse(this.PowerPrice3_new.SelectedValue.ToString()); pr_3.Rate = float.Parse(this.Price3_new.Text.ToString().Trim()); pr_3.PriceName = customer.getCustomerNo(); list.Add((Object)pr_3); } if (this.PowerPrice4_new.SelectedIndex != -1) { PriceRate pr_4 = new PriceRate(); pr_4.PriceNo = int.Parse(this.PowerPrice4_new.SelectedValue.ToString()); pr_4.Rate = float.Parse(this.Price4_new.Text.ToString().Trim()); pr_4.PriceName = customer.getCustomerNo(); list.Add((Object)pr_4); } /*添加客户信息*/ if (Constant.OK == this.customerAction.addCustomerInfo(ref list)) { MessageBox.Show("客户信息添加成功"); this.init_content(); return; } else { MessageBox.Show("客户信息添加失败"); return; } }