public bool Update(MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT) { StringBuilder str = new StringBuilder(); str.Append("UPDATE PRESTORERUNNINGACCOUNT SET CHARGEID=@CHARGEID,WATERUSERID=@WATERUSERID,WATERUSERNO=@WATERUSERNO,WATERUSERNAME=@WATERUSERNAME,MEMO=@MEMO "); str.Append("WHERE PRESTORERUNNINGACCOUNTID=@PRESTORERUNNINGACCOUNTID"); SqlParameter[] para = { new SqlParameter("@CHARGEID", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERID", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERNO", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERNAME", SqlDbType.VarChar, 50), new SqlParameter("@MEMO", SqlDbType.VarChar, 200), new SqlParameter("@PRESTORERUNNINGACCOUNTID", SqlDbType.VarChar, 50) }; para[0].Value = MODELPRESTORERUNNINGACCOUNT.CHARGEID; para[1].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERID; para[2].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERNO; para[3].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME; para[4].Value = MODELPRESTORERUNNINGACCOUNT.MEMO; para[5].Value = MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
private void btCharge_Click(object sender, EventArgs e) { try { if (dgWaterUser.Rows.Count == 0) { mes.Show("未找到预交水费的用户信息!"); return; } if (cmbChargeType.SelectedValue == null || cmbChargeType.SelectedValue == DBNull.Value) { mes.Show("收费方式不能为空!"); cmbChargeType.Focus(); return; } if (!Information.IsNumeric(txtBCYC.Text)) { return; } else if (Convert.ToDecimal(txtBCYC.Text) <= 0) { mes.Show("预存金额不能为'0'"); txtBCYC.Focus(); return; } for (int i = 0; i < dgWaterUser.SelectedRows.Count; i++) { try { string strWaterUserID = "", strWaterUserNO = "", strWaterUserName = "", strWaterUserNameCode = "", strTelNO = "", strWaterUserPhone = "", strWaterUserAddress = "", strAreaNO = "", strPianNO = "", strDuanNO = "", strCommunityID = "", strCommunityName = "", strBuildingNO = "", strUnitNO = "", strMeterReaderID = "", strMeterReaderName = "", strMeterReaderTel = "", strChargeID = "", strChargerName = "", strWaterUserTypeID = "", strWaterUserTypeName = "", strWaterUserHouseType = "", strCreateType = "", strWaterMeterTypeID = "", strWaterMeterTypeName = "", strWaterMeterTypeClassID = "", strWaterMeterTypeClassName = ""; int intPepleCount = 1, intOrderNumber = 0; object objWaterUserID = dgWaterUser.SelectedRows[i].Cells["waterUserId"].Value; if (objWaterUserID == null || objWaterUserID == DBNull.Value) { mes.Show("第'" + (i + 1).ToString() + "行用户ID获取失败,批量收费终止!"); return; } //计算结算余额 decimal decQQYE = 0, decJSYE = 0; object objPrestore = dgWaterUser.SelectedRows[i].Cells["prestore"].Value; if (Information.IsNumeric(objPrestore)) { decQQYE = Convert.ToDecimal(objPrestore); } decJSYE = decQQYE + Convert.ToDecimal(txtBCYC.Text); #region 生成用户信息 strWaterUserID = objWaterUserID.ToString(); object objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserNO"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserNO = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserName"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserName = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserTelphoneNO"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strTelNO = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterPhone"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserPhone = objWaterUserMes.ToString(); } object objWaterUser = dgWaterUser.SelectedRows[i].Cells["areaNO"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strAreaNO = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["pianNO"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strPianNO = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["DuanNO"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strDuanNO = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["COMMUNITYID"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strCommunityID = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["COMMUNITYNAME"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strCommunityName = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["buildingNO"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strBuildingNO = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["unitNO"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strUnitNO = objWaterUser.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERUSERTYPEID"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserTypeID = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserTypeName"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserTypeName = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPEID"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterMeterTypeID = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPEVALUE"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterMeterTypeName = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPECLASSID"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterMeterTypeClassID = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERMETERTYPECLASSNAME"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterMeterTypeClassName = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserAddress"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserAddress = objWaterUserMes.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["createType"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strCreateType = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["METERREADERID"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strMeterReaderID = objWaterUser.ToString(); DataRow[] drMeterReader = dtMeterReader.Select("LOGINID='" + strMeterReaderID + "'"); object objMeterReaderTel = drMeterReader[0]["TELEPHONENO"]; if (objMeterReaderTel != null && objMeterReaderTel != DBNull.Value) { strMeterReaderTel = objMeterReaderTel.ToString(); } } objWaterUser = dgWaterUser.SelectedRows[i].Cells["meterReaderName"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strMeterReaderName = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["chargerName"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strChargerName = objWaterUser.ToString(); } objWaterUser = dgWaterUser.SelectedRows[i].Cells["CHARGERID"].Value; if (objWaterUser != null && objWaterUser != DBNull.Value) { strChargeID = objWaterUser.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["waterUserHouseTypeS"].Value; if (objWaterUserMes != null && objWaterUserMes != DBNull.Value) { strWaterUserHouseType = objWaterUserMes.ToString(); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["ordernumber"].Value; if (Information.IsNumeric(objWaterUserMes)) { intOrderNumber = Convert.ToInt16(objWaterUserMes); } objWaterUserMes = dgWaterUser.SelectedRows[i].Cells["WATERUSERPEOPLECOUNT"].Value; if (Information.IsNumeric(objWaterUserMes)) { intPepleCount = Convert.ToInt16(objWaterUserMes); } #endregion MODELWATERFEECHARGE MODELWATERFEECHARGE = new MODELWATERFEECHARGE(); MODELWATERFEECHARGE.CHARGEID = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE"); MODELWATERFEECHARGE.CHARGETYPEID = cmbChargeType.SelectedValue.ToString(); if (cmbChargeType.SelectedValue.ToString() == "2") { MODELWATERFEECHARGE.POSRUNNINGNO = txtJYLSH.Text; } MODELWATERFEECHARGE.CHARGEClASS = "2";//收费类型是水费预收 MODELWATERFEECHARGE.CHARGEBCSS = Convert.ToDecimal(txtBCYC.Text); MODELWATERFEECHARGE.CHARGEYSQQYE = decQQYE; MODELWATERFEECHARGE.CHARGEYSBCSZ = Convert.ToDecimal(txtBCYC.Text); MODELWATERFEECHARGE.CHARGEYSJSYE = decJSYE; MODELWATERFEECHARGE.CHARGEWORKERID = strLoginID; MODELWATERFEECHARGE.CHARGEWORKERNAME = strLoginName; MODELWATERFEECHARGE.CHARGEDATETIME = mes.GetDatetimeNow(); MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0"; if (chkReceipt.Checked) { MODELWATERFEECHARGE.RECEIPTPRINTCOUNT = 1; MODELWATERFEECHARGE.RECEIPTNO = txtReceiptNO.Text; } if (BLLWATERFEECHARGE.Insert(MODELWATERFEECHARGE)) { try { MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT = new MODELPRESTORERUNNINGACCOUNT(); MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT"); MODELPRESTORERUNNINGACCOUNT.WATERUSERID = strWaterUserID; MODELPRESTORERUNNINGACCOUNT.WATERUSERNO = strWaterUserNO; MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME = strWaterUserName; MODELPRESTORERUNNINGACCOUNT.WATERUSERNAMECODE = strWaterUserNameCode; MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = strTelNO; if (strWaterUserPhone != "") { if (strTelNO != "") { MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = strTelNO + ";" + strWaterUserPhone; } else { MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = strWaterUserPhone; } } MODELPRESTORERUNNINGACCOUNT.WATERUSERADDRESS = strWaterUserAddress; MODELPRESTORERUNNINGACCOUNT.WATERUSERPEOPLECOUNT = intPepleCount; MODELPRESTORERUNNINGACCOUNT.AREANO = strAreaNO; MODELPRESTORERUNNINGACCOUNT.PIANNO = strPianNO; MODELPRESTORERUNNINGACCOUNT.DUANNO = strDuanNO; MODELPRESTORERUNNINGACCOUNT.COMMUNITYID = strCommunityID; MODELPRESTORERUNNINGACCOUNT.COMMUNITYNAME = strCommunityName; MODELPRESTORERUNNINGACCOUNT.ORDERNUMBER = intOrderNumber; MODELPRESTORERUNNINGACCOUNT.BUILDINGNO = strBuildingNO; MODELPRESTORERUNNINGACCOUNT.UNITNO = strUnitNO; MODELPRESTORERUNNINGACCOUNT.METERREADERID = strMeterReaderID; MODELPRESTORERUNNINGACCOUNT.METERREADERNAME = strMeterReaderName; MODELPRESTORERUNNINGACCOUNT.CHARGERID = strLoginID; MODELPRESTORERUNNINGACCOUNT.CHARGERNAME = strLoginName; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPEID = strWaterUserTypeID; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME = strWaterUserTypeName; MODELPRESTORERUNNINGACCOUNT.waterMeterTypeId = strWaterMeterTypeID; MODELPRESTORERUNNINGACCOUNT.waterMeterTypeValue = strWaterMeterTypeName; MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSID = strWaterMeterTypeClassID; MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSNAME = strWaterMeterTypeClassName; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME = strWaterUserTypeName; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME = strWaterUserTypeName; MODELPRESTORERUNNINGACCOUNT.WATERUSERHOUSETYPE = strWaterUserHouseType; MODELPRESTORERUNNINGACCOUNT.CREATETYPE = strCreateType; MODELPRESTORERUNNINGACCOUNT.MEMO = txtMemo.Text; MODELPRESTORERUNNINGACCOUNT.CHARGEID = MODELWATERFEECHARGE.CHARGEID; if (BLLPRESTORERUNNINGACCOUNT.Insert(MODELPRESTORERUNNINGACCOUNT)) { //txtYSQQYE.Text = txtJSYE.Text; //txtWaterFeeReal.Text =( Convert.ToDecimal(txtWaterFee.Text) - Convert.ToDecimal(txtYSQQYE.Text)).ToString(); //txtBCYC.Text = "0"; //更新余额 string strUpdatePrestore = "UPDATE waterUser SET prestore=" + MODELWATERFEECHARGE.CHARGEYSJSYE + " WHERE waterUserId='" + strWaterUserID + "'"; if (!BLLwaterUser.UpdateSQL(strUpdatePrestore)) { string strError = "更新用户编号为'" + strWaterUserNO + "'的余额失败,请重新收费!"; mes.Show(strError); log.Write(strError, MsgType.Error); //回滚预存流水表 BLLPRESTORERUNNINGACCOUNT.Delete(MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID); //回滚收费记录表 BLLWATERFEECHARGE.Delete(MODELWATERFEECHARGE.CHARGEID); } else { decimal decUserArearage = 0, decWaterUserPrestore = 0; object objUserArearage = dgWaterUser.SelectedRows[i].Cells["USERAREARAGE"].Value; if (Information.IsNumeric(objUserArearage)) { decUserArearage = Convert.ToDecimal(objUserArearage); } object objUserPrestore = dgWaterUser.SelectedRows[i].Cells["prestore"].Value; if (Information.IsNumeric(objUserPrestore)) { decWaterUserPrestore = Convert.ToDecimal(objUserPrestore); } decWaterUserPrestore = decWaterUserPrestore + MODELWATERFEECHARGE.CHARGEBCSS; decUserArearage = decUserArearage + MODELWATERFEECHARGE.CHARGEBCSS; dgWaterUser.SelectedRows[i].Cells["USERAREARAGE"].Value = decUserArearage.ToString("F2"); dgWaterUser.SelectedRows[i].Cells["prestore"].Value = decWaterUserPrestore.ToString("F2"); } //如果勾选了打收据,打印收据 if (chkReceipt.Checked) { //--打印收据 #region FastReport.Report report1 = new FastReport.Report(); try { DataTable dtLastRecord = BLLwaterUser.QuerySQL("SELECT TOP 1 readMeterRecordId,readMeterRecordYearAndMonth,waterMeterLastNumber," + "(CASE chargeState WHEN 0 THEN waterMeterLastNumber " + "ELSE waterMeterEndNumber END) AS waterMeterEndNumber " + "FROM readMeterRecord " + "WHERE WATERUSERID='" + strWaterUserID + "' ORDER BY readMeterRecordYearAndMonth DESC,readMeterRecordDate DESC"); DataTable dtTemp = dtLastRecord.Clone(); dtTemp.Columns["readMeterRecordYearAndMonth"].DataType = typeof(string); if (dtLastRecord.Rows.Count > 0) { dtTemp.ImportRow(dtLastRecord.Rows[0]); object objReadMeterRecordYearAndMonth = dtTemp.Rows[0]["readMeterRecordYearAndMonth"]; if (Information.IsDate(objReadMeterRecordYearAndMonth)) { dtTemp.Rows[0]["readMeterRecordYearAndMonth"] = Convert.ToDateTime(objReadMeterRecordYearAndMonth).ToString("yyyy-MM"); } } //DataTable dtTemp = dtLastRecord.Copy(); DataSet ds = new DataSet(); dtTemp.TableName = "营业坐收收据模板"; ds.Tables.Add(dtTemp); // load the existing report report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\预存收费收据模板.frx"); (report1.FindObject("txtDateTime") as FastReport.TextObject).Text = MODELWATERFEECHARGE.CHARGEDATETIME.ToString("yyyy-MM-dd HH:mm:ss"); //if (cmbChargeType.SelectedValue.ToString() == "2") //{ // (report1.FindObject("Cell45") as FastReport.Table.TableCell).Text = txtWaterUserNO.Text + " 交易流水号:" + txtJYLSH.Text; //} //else (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text = strWaterUserNO; (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text = strWaterUserName; (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = strWaterUserAddress; (report1.FindObject("txtQQYE") as FastReport.TextObject).Text = "前期余额: " + MODELWATERFEECHARGE.CHARGEYSQQYE.ToString("F2"); string strBCSS = MODELWATERFEECHARGE.CHARGEBCSS.ToString("F2"); (report1.FindObject("txtBCJF") as FastReport.TextObject).Text = "本次预存: " + strBCSS; (report1.FindObject("txtJSYE") as FastReport.TextObject).Text = "结算余额: " + MODELWATERFEECHARGE.CHARGEYSJSYE.ToString("F2"); //if (cmbChargeType.SelectedValue.ToString() == "2") //{ // (report1.FindObject("txtPOSRUNNINGNO") as FastReport.TextObject).Text = "交易流水号: " + MODELWATERFEECHARGE.POSRUNNINGNO; //} (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strLoginName; (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text = "NO." + txtReceiptNO.Text; (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text = strMeterReaderName; (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = strMeterReaderTel; string strCapMoney = RMBToCapMoney.CmycurD(strBCSS); if (cmbChargeType.SelectedValue.ToString() == "2") { (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney + Environment.NewLine + "交易流水号:" + txtJYLSH.Text; } else { (report1.FindObject("txtCapMoney") as FastReport.TextObject).Text = "金额大写:" + strCapMoney; } // register the dataset report1.RegisterData(ds); report1.GetDataSource("营业坐收收据模板").Enabled = true; report1.PrintSettings.ShowDialog = false; report1.Prepare(); report1.Print(); //获取新的收据号码,8位收据号 if (Information.IsNumeric(txtReceiptNO.Text)) { txtReceiptNO.Text = (Convert.ToInt64(txtReceiptNO.Text) + 1).ToString().PadLeft(8, '0'); } } catch (Exception exx) { MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { // free resources used by report report1.Dispose(); } #endregion } } } catch (Exception exx) { mes.Show("插入预收流水表失败!原因:" + exx.Message); log.Write(exx.ToString(), MsgType.Error); return; } } } catch (Exception ex) { mes.Show("预收失败!原因:" + ex.Message); log.Write(ex.ToString(), MsgType.Error); return; } } btCharge.Enabled = false; //dgWaterList.DataSource = null; } catch (Exception ex) { mes.Show(ex.Message); log.Write(ex.ToString(), MsgType.Error); return; } }
public bool Insert(MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT) { StringBuilder str = new StringBuilder(); str.Append("INSERT INTO PRESTORERUNNINGACCOUNT(PRESTORERUNNINGACCOUNTID,CHARGEID,WATERUSERID,WATERUSERNO,WATERUSERNAME,WATERUSERNAMECODE,WATERUSERPHONE," + "WATERUSERADDRESS,WATERUSERPEOPLECOUNT,AREANO,PIANNO,DUANNO,ORDERNUMBER,COMMUNITYID,COMMUNITYNAME,BUILDINGNO,UNITNO,METERREADERID,METERREADERNAME," + "CHARGERID,CHARGERNAME,WATERUSERTYPEID,WATERUSERTYPENAME,WATERUSERHOUSETYPE,CREATETYPE,MEMO,waterMeterTypeId,waterMeterTypeValue," + "WATERMETERTYPECLASSID,WATERMETERTYPECLASSNAME) "); str.Append("VALUES(@PRESTORERUNNINGACCOUNTID,@CHARGEID,@WATERUSERID,@WATERUSERNO,@WATERUSERNAME,@WATERUSERNAMECODE,@WATERUSERPHONE," + "@WATERUSERADDRESS,@WATERUSERPEOPLECOUNT,@AREANO,@PIANNO,@DUANNO,@ORDERNUMBER,@COMMUNITYID,@COMMUNITYNAME,@BUILDINGNO,@UNITNO,@METERREADERID," + "@METERREADERNAME,@CHARGERID,@CHARGERNAME,@WATERUSERTYPEID,@WATERUSERTYPENAME,@WATERUSERHOUSETYPE,@CREATETYPE,@MEMO,@waterMeterTypeId," + "@waterMeterTypeValue,@WATERMETERTYPECLASSID,@WATERMETERTYPECLASSNAME) "); SqlParameter[] para = { new SqlParameter("@PRESTORERUNNINGACCOUNTID", SqlDbType.VarChar, 50), new SqlParameter("@CHARGEID", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERID", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERNO", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERNAME", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERNAMECODE", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERPHONE", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERADDRESS", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERPEOPLECOUNT", SqlDbType.Int), new SqlParameter("@AREANO", SqlDbType.VarChar, 50), new SqlParameter("@PIANNO", SqlDbType.VarChar, 50), new SqlParameter("@DUANNO", SqlDbType.VarChar, 50), new SqlParameter("@ORDERNUMBER", SqlDbType.Int), new SqlParameter("@COMMUNITYID", SqlDbType.VarChar, 50), new SqlParameter("@COMMUNITYNAME", SqlDbType.VarChar, 50), new SqlParameter("@BUILDINGNO", SqlDbType.VarChar, 50), new SqlParameter("@UNITNO", SqlDbType.VarChar, 50), new SqlParameter("@METERREADERID", SqlDbType.VarChar, 50), new SqlParameter("@METERREADERNAME", SqlDbType.VarChar, 50), new SqlParameter("@CHARGERID", SqlDbType.VarChar, 50), new SqlParameter("@CHARGERNAME", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERTYPEID", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERTYPENAME", SqlDbType.VarChar, 50), new SqlParameter("@WATERUSERHOUSETYPE", SqlDbType.VarChar, 50), new SqlParameter("@CREATETYPE", SqlDbType.VarChar, 50), new SqlParameter("@MEMO", SqlDbType.VarChar, 200), new SqlParameter("@waterMeterTypeId", SqlDbType.VarChar, 50), new SqlParameter("@waterMeterTypeValue", SqlDbType.VarChar, 50), new SqlParameter("@WATERMETERTYPECLASSID", SqlDbType.VarChar, 50), new SqlParameter("@WATERMETERTYPECLASSNAME", SqlDbType.VarChar, 50) }; para[0].Value = MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID; para[1].Value = MODELPRESTORERUNNINGACCOUNT.CHARGEID; para[2].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERID; para[3].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERNO; para[4].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME; para[5].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERNAMECODE; para[6].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE; para[7].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERADDRESS; para[8].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERPEOPLECOUNT; para[9].Value = MODELPRESTORERUNNINGACCOUNT.AREANO; para[10].Value = MODELPRESTORERUNNINGACCOUNT.PIANNO; para[11].Value = MODELPRESTORERUNNINGACCOUNT.DUANNO; para[12].Value = MODELPRESTORERUNNINGACCOUNT.ORDERNUMBER; para[13].Value = MODELPRESTORERUNNINGACCOUNT.COMMUNITYID; para[14].Value = MODELPRESTORERUNNINGACCOUNT.COMMUNITYNAME; para[15].Value = MODELPRESTORERUNNINGACCOUNT.BUILDINGNO; para[16].Value = MODELPRESTORERUNNINGACCOUNT.UNITNO; para[17].Value = MODELPRESTORERUNNINGACCOUNT.METERREADERID; para[18].Value = MODELPRESTORERUNNINGACCOUNT.METERREADERNAME; para[19].Value = MODELPRESTORERUNNINGACCOUNT.CHARGERID; para[20].Value = MODELPRESTORERUNNINGACCOUNT.CHARGERNAME; para[21].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPEID; para[22].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME; para[23].Value = MODELPRESTORERUNNINGACCOUNT.WATERUSERHOUSETYPE; para[24].Value = MODELPRESTORERUNNINGACCOUNT.CREATETYPE; para[25].Value = MODELPRESTORERUNNINGACCOUNT.MEMO; para[26].Value = MODELPRESTORERUNNINGACCOUNT.waterMeterTypeId; para[27].Value = MODELPRESTORERUNNINGACCOUNT.waterMeterTypeValue; para[28].Value = MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSID; para[29].Value = MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSNAME; if (DBUtility.DbHelperSQL.ExecuteSql(str.ToString(), para) > 0) { return(true); } else { return(false); } }
private void btCharge_Click(object sender, EventArgs e) { if (txtWaterUserID.Text.Trim() == "") { mes.Show("未找到用户ID信息,请重新查询后重试!"); txtWaterUserNOSearch.Focus(); return; } //如果用户存在欠费金额,则不允退费 object objWaterUserQF = BLLreadMeterRecord.QueryQFByWaterUser(txtWaterUserID.Text.Trim()); if (Information.IsNumeric(objWaterUserQF)) { txtWaterFee.Text = Convert.ToDecimal(objWaterUserQF).ToString("F2"); if (Convert.ToDecimal(objWaterUserQF) > 0) { mes.Show("当前用户存在欠费余额,无法执行退费操作!"); return; } } else { txtWaterFee.Text = "0"; } if (Convert.ToDecimal(txtYSQQYE.Text) <= 0) { mes.Show("用户预存余额为0,无需退费!"); txtYSQQYE.Focus(); return; } if (chkReceipt.Checked) { if (txtReceiptNO.Text.Trim() == "") { mes.Show("请输入收据号!"); txtReceiptNO.Focus(); return; } if (!Information.IsNumeric(txtReceiptNO.Text)) { mes.Show("收据号只能由数字组成!"); txtReceiptNO.SelectAll(); return; } txtReceiptNO.Text = txtReceiptNO.Text.PadLeft(8, '0'); if (BLLWATERFEECHARGE.IsExistReceiptNO(txtReceiptNO.Text)) { if (mes.ShowQ("系统检测到号码为'" + txtReceiptNO.Text + "'的收据已使用,确定使用此号码吗?") != DialogResult.OK) { txtReceiptNO.SelectAll(); return; } } } try { MODELWATERFEECHARGE MODELWATERFEECHARGE = new MODELWATERFEECHARGE(); MODELWATERFEECHARGE.CHARGEID = GETTABLEID.GetTableID(strLoginID, "WATERFEECHARGE"); MODELWATERFEECHARGE.CHARGETYPEID = "1"; MODELWATERFEECHARGE.CHARGEClASS = "6";//收费类型是用户余额退费 MODELWATERFEECHARGE.CHARGEYSQQYE = Convert.ToDecimal(txtYSQQYE.Text); MODELWATERFEECHARGE.CHARGEBCSS = 0 - MODELWATERFEECHARGE.CHARGEYSQQYE; MODELWATERFEECHARGE.CHARGEYSBCSZ = 0 - MODELWATERFEECHARGE.CHARGEYSQQYE; MODELWATERFEECHARGE.CHARGEYSJSYE = 0; MODELWATERFEECHARGE.CHARGEWORKERID = strLoginID; MODELWATERFEECHARGE.CHARGEWORKERNAME = strLoginName; MODELWATERFEECHARGE.CHARGEDATETIME = mes.GetDatetimeNow(); MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0"; if (chkReceipt.Checked) { MODELWATERFEECHARGE.RECEIPTPRINTCOUNT = 1; MODELWATERFEECHARGE.RECEIPTNO = txtReceiptNO.Text; } MODELWATERFEECHARGE.INVOICEPRINTSIGN = "0"; MODELWATERFEECHARGE.MEMO = txtMemo.Text; if (BLLWATERFEECHARGE.Insert(MODELWATERFEECHARGE)) { try { MODELPRESTORERUNNINGACCOUNT MODELPRESTORERUNNINGACCOUNT = new MODELPRESTORERUNNINGACCOUNT(); MODELPRESTORERUNNINGACCOUNT.PRESTORERUNNINGACCOUNTID = GETTABLEID.GetTableID(strLoginID, "PRESTORERUNNINGACCOUNT"); MODELPRESTORERUNNINGACCOUNT.WATERUSERID = txtWaterUserID.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERNO = txtWaterUserNO.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERNAME = txtWaterUserName.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERNAMECODE = txtNameCode.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERPHONE = txtWaterUserPhone.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERADDRESS = txtWaterUserAddress.Text; if (Information.IsNumeric(txtWaterUserPeopleCount.Text)) { MODELPRESTORERUNNINGACCOUNT.WATERUSERPEOPLECOUNT = Convert.ToInt16(txtWaterUserPeopleCount.Text); } MODELPRESTORERUNNINGACCOUNT.AREANO = txtAreaNO.Text; MODELPRESTORERUNNINGACCOUNT.PIANNO = txtPianNO.Text; MODELPRESTORERUNNINGACCOUNT.DUANNO = txtDuanNO.Text; MODELPRESTORERUNNINGACCOUNT.COMMUNITYID = txtCommunityID.Text; MODELPRESTORERUNNINGACCOUNT.COMMUNITYNAME = txtCommunity.Text; if (Information.IsNumeric(txtOrderNumber.Text)) { MODELPRESTORERUNNINGACCOUNT.ORDERNUMBER = Convert.ToInt16(txtOrderNumber.Text); } //MODELPRESTORERUNNINGACCOUNT.BUILDINGNO = txtBuildingNO.Text; //MODELPRESTORERUNNINGACCOUNT.UNITNO = txtUnitNO.Text; MODELPRESTORERUNNINGACCOUNT.METERREADERID = txtMeterReaderID.Text; MODELPRESTORERUNNINGACCOUNT.METERREADERNAME = txtMeterReader.Text; MODELPRESTORERUNNINGACCOUNT.CHARGERID = txtChargerID.Text; MODELPRESTORERUNNINGACCOUNT.CHARGERNAME = txtCharger.Text; MODELPRESTORERUNNINGACCOUNT.waterMeterTypeId = txtWaterMeterTypeID.Text; MODELPRESTORERUNNINGACCOUNT.waterMeterTypeValue = txtWaterMeterTypeValue.Text; MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSID = txtWaterMeterTypeClassID.Text; MODELPRESTORERUNNINGACCOUNT.WATERMETERTYPECLASSNAME = txtWaterMeterTypeClassName.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPEID = txtWaterUserTypeID.Text; MODELPRESTORERUNNINGACCOUNT.WATERUSERTYPENAME = txtWaterUserType.Text; //MODELPRESTORERUNNINGACCOUNT.WATERUSERHOUSETYPE = txtWaterUserHouseType.Text; //MODELPRESTORERUNNINGACCOUNT.CREATETYPE = txtCreateType.Text; //MODELPRESTORERUNNINGACCOUNT.MEMO = txtMemo.Text; MODELPRESTORERUNNINGACCOUNT.CHARGEID = MODELWATERFEECHARGE.CHARGEID; if (BLLPRESTORERUNNINGACCOUNT.Insert(MODELPRESTORERUNNINGACCOUNT)) { //txtYSQQYE.Text = txtJSYE.Text; //txtWaterFeeReal.Text =( Convert.ToDecimal(txtWaterFee.Text) - Convert.ToDecimal(txtYSQQYE.Text)).ToString(); //txtBCYC.Text = "0"; btCharge.Enabled = false; btSearchLS_Click(null, null); //更新余额 string strUpdatePrestore = "UPDATE waterUser SET prestore=" + MODELWATERFEECHARGE.CHARGEYSJSYE + " WHERE waterUserId='" + txtWaterUserID.Text + "'"; if (!BLLwaterUser.UpdateSQL(strUpdatePrestore)) { string strError = "更新用户编号为'" + txtWaterUserID.Text + "'的余额失败,请手动添加预收余额!"; mes.Show(strError); log.Write(strError, MsgType.Error); } //如果勾选了打收据,打印收据 else if (chkReceipt.Checked) { //--打印收据 #region FastReport.Report report1 = new FastReport.Report(); try { report1.Load(Application.StartupPath + @"\PRINTModel\收据模板\退费收据模板.frx"); (report1.FindObject("txtDateTime") as FastReport.TextObject).Text = MODELWATERFEECHARGE.CHARGEDATETIME.ToString("yyyy-MM-dd HH:mm:ss"); //if (cmbChargeType.SelectedValue.ToString() == "2") //{ // (report1.FindObject("Cell45") as FastReport.Table.TableCell).Text = txtWaterUserNO.Text + " 交易流水号:" + txtJYLSH.Text; //} //else (report1.FindObject("CellWaterUserNO") as FastReport.Table.TableCell).Text = txtWaterUserNO.Text; (report1.FindObject("CellWaterUserName") as FastReport.Table.TableCell).Text = txtWaterUserName.Text; (report1.FindObject("CellWaterUserAddress") as FastReport.Table.TableCell).Text = txtWaterUserAddress.Text; (report1.FindObject("txtQQYE") as FastReport.TextObject).Text = "前期余额: " + MODELWATERFEECHARGE.CHARGEYSQQYE.ToString("F2"); (report1.FindObject("txtBCTF") as FastReport.TextObject).Text = "本次退费: " + MODELWATERFEECHARGE.CHARGEYSBCSZ; (report1.FindObject("txtJSYE") as FastReport.TextObject).Text = "结算余额: " + MODELWATERFEECHARGE.CHARGEYSJSYE.ToString("F2"); //if (cmbChargeType.SelectedValue.ToString() == "2") //{ // (report1.FindObject("txtPOSRUNNINGNO") as FastReport.TextObject).Text = "交易流水号: " + MODELWATERFEECHARGE.POSRUNNINGNO; //} (report1.FindObject("txtChargeWorkerName") as FastReport.TextObject).Text = strLoginName; (report1.FindObject("txtReceiptNO") as FastReport.TextObject).Text = "NO." + txtReceiptNO.Text; (report1.FindObject("txtMeterReader") as FastReport.TextObject).Text = txtMeterReader.Text; (report1.FindObject("txtMeterReaderTel") as FastReport.TextObject).Text = txtMeterReaderTel.Text; report1.PrintSettings.ShowDialog = false; report1.Prepare(); report1.Print(); //获取新的收据号码,8位收据号 if (Information.IsNumeric(txtReceiptNO.Text)) { txtReceiptNO.Text = (Convert.ToInt64(txtReceiptNO.Text) + 1).ToString().PadLeft(8, '0'); } } catch (Exception exx) { MessageBox.Show(exx.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // free resources used by report report1.Dispose(); } #endregion } } } catch (Exception exx) { mes.Show("插入预收流水表失败!原因:" + exx.Message); log.Write(exx.ToString(), MsgType.Error); return; } } } catch (Exception ex) { mes.Show("预收失败!原因:" + ex.Message); log.Write(ex.ToString(), MsgType.Error); return; } }