private static void SetParamsValue(tFundsRecorderInfo oEntity, SqlParameter[] sqlpmEntity) { sqlpmEntity[0].Value = oEntity.tFundsRecorder[0].id; sqlpmEntity[1].Value = oEntity.tFundsRecorder[0].IscustomerIdNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].customerId; sqlpmEntity[2].Value = oEntity.tFundsRecorder[0].IsciIdNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].ciId; sqlpmEntity[3].Value = oEntity.tFundsRecorder[0].IstuIdNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].tuId; sqlpmEntity[4].Value = oEntity.tFundsRecorder[0].paidUp; sqlpmEntity[5].Value = oEntity.tFundsRecorder[0].type; sqlpmEntity[6].Value = oEntity.tFundsRecorder[0].IscheckNoNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].checkNo; sqlpmEntity[7].Value = oEntity.tFundsRecorder[0].IsinputDateNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].inputDate; sqlpmEntity[8].Value = oEntity.tFundsRecorder[0].IsinputManNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].inputMan; sqlpmEntity[9].Value = oEntity.tFundsRecorder[0].IsinvoiceNoNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].invoiceNo; sqlpmEntity[10].Value = oEntity.tFundsRecorder[0].IsremarkNull() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].remark; sqlpmEntity[11].Value = oEntity.tFundsRecorder[0].Iscash1Null() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].cash1; sqlpmEntity[12].Value = oEntity.tFundsRecorder[0].Iscash2Null() ? (object)System.DBNull.Value : oEntity.tFundsRecorder[0].cash2; }
private void btnOK_Click(object sender, EventArgs e) { if (this.txtPayment.Text.Trim() == "") { DasherStation.HumanResource.CommUI.AlertError("本次付款不能为空!"); return; } decimal mValue; if (decimal.TryParse(this.txtPayment.Text.Trim(), out mValue) == false) { DasherStation.HumanResource.CommUI.AlertError("在本次付款中请输入数值!"); return; } if (decimal.Parse(this.txtCount2.Text) + decimal.Parse(this.txtPayment.Text) > decimal.Parse(this.txtCount1.Text)) { DasherStation.HumanResource.CommUI.AlertError("已付总额不能大于应付总额!"); return; } tFundsRecorderInfo entity = new tFundsRecorderInfo(); tFundsRecorderInfo.tFundsRecorderRow oRow = entity.tFundsRecorder.NewtFundsRecorderRow(); oRow.customerId = long.Parse(this.cboClient.SelectedValue.ToString()); oRow.paidUp = mValue; oRow.type = EnumAccountType.备品备件.ToString(); if (this.chkCheck.Checked) { oRow.checkNo = this.txtCheckNo.Text.Trim(); } if (this.chkInvoice.Checked) { oRow.invoiceNo = this.txtInvoiceNo.Text.Trim(); } oRow.inputMan = this.UserName; if (this.txtMemo.Text.Trim() != "") { oRow.remark = this.txtMemo.Text.Trim(); } oRow.cash1 = decimal.Parse(this.txtCount1.Text); oRow.cash2 = decimal.Parse(this.txtCount3.Text) - decimal.Parse(this.txtPayment.Text); entity.tFundsRecorder.AddtFundsRecorderRow(oRow); SparePartBanlanceLogic model = new SparePartBanlanceLogic(); model.AddPaid(entity); this.txtPayment.Text = ""; this.chkCheck.Checked = false; this.chkInvoice.Checked = false; this.txtCheckNo.Text = ""; this.txtInvoiceNo.Text = ""; this.txtMemo.Text = ""; this.InitForm(model); }
/// <summary> /// 新增收款/付款记录 /// </summary> /// <param name="entity"></param> public void AddPaid(tFundsRecorderInfo entity) { this.oData.InsertPaidRecord(entity); }
/// <summary> /// 新增收款/付款记录 /// </summary> /// <param name="entity"></param> public void InsertPaidRecord(tFundsRecorderInfo entity) { if (entity.tFundsRecorder[0].IsinputManNull()) { entity.tFundsRecorder[0].inputMan = "System"; } using (BalanceDataContext oContext = new BalanceDataContext(this.strConn)) { FundsRecorder linqEntity = new FundsRecorder(); if (entity.tFundsRecorder[0].IscustomerIdNull() == false) { linqEntity.customerId = entity.tFundsRecorder[0].customerId; } else if (entity.tFundsRecorder[0].IsciIdNull() == false) { linqEntity.ciid = entity.tFundsRecorder[0].ciId; } else if (entity.tFundsRecorder[0].IstuIdNull() == false) { linqEntity.tuid = entity.tFundsRecorder[0].tuId; } linqEntity.paidup = entity.tFundsRecorder[0].paidUp; linqEntity.type = entity.tFundsRecorder[0].type; if (entity.tFundsRecorder[0].IscheckNoNull() == false) { linqEntity.checkNo = entity.tFundsRecorder[0].checkNo; } if (entity.tFundsRecorder[0].IsinvoiceNoNull() == false) { linqEntity.invoiceNo = entity.tFundsRecorder[0].invoiceNo; } if (entity.tFundsRecorder[0].IsremarkNull() == false) { linqEntity.remark = entity.tFundsRecorder[0].remark; } linqEntity.cash1 = entity.tFundsRecorder[0].cash1; linqEntity.cash2 = entity.tFundsRecorder[0].cash2; linqEntity.inputMan = entity.tFundsRecorder[0].inputMan; Arrearage arrearageEntity = new Arrearage(); //欠款表 arrearageEntity.due = entity.tFundsRecorder[0].cash1; arrearageEntity.@default = entity.tFundsRecorder[0].cash2; arrearageEntity.paidUp = arrearageEntity.due - arrearageEntity.@default; arrearageEntity.inputMan = entity.tFundsRecorder[0].inputMan; AccountReceivable receiveEntity = null; //应收款表 if (entity.tFundsRecorder[0].type == EnumAccountType.付款.ToString() && entity.tFundsRecorder[0].IscustomerIdNull() == false) { //采购 arrearageEntity.piId = entity.tFundsRecorder[0].customerId; var tempEntity = (from item in oContext.Arrearage where item.piId == arrearageEntity.piId select item).FirstOrDefault(); if (tempEntity != null) { tempEntity.due = arrearageEntity.due; tempEntity.@default = arrearageEntity.@default; tempEntity.paidUp = arrearageEntity.paidUp; tempEntity.inputMan = arrearageEntity.inputMan; } else { oContext.Arrearage.InsertOnSubmit(arrearageEntity); } } else if (entity.tFundsRecorder[0].type == EnumAccountType.运输款.ToString() && entity.tFundsRecorder[0].IstuIdNull() == false) { //运输 arrearageEntity.tuId = entity.tFundsRecorder[0].tuId; var tempEntity = (from item in oContext.Arrearage where item.tuId == arrearageEntity.tuId select item).FirstOrDefault(); if (tempEntity != null) { tempEntity.due = arrearageEntity.due; tempEntity.@default = arrearageEntity.@default; tempEntity.paidUp = arrearageEntity.paidUp; tempEntity.inputMan = arrearageEntity.inputMan; } else { oContext.Arrearage.InsertOnSubmit(arrearageEntity); } } else if (entity.tFundsRecorder[0].type == EnumAccountType.备品备件.ToString() && entity.tFundsRecorder[0].IscustomerIdNull() == false) { //备品备件 arrearageEntity.piId = entity.tFundsRecorder[0].customerId; var tempEntity = (from item in oContext.Arrearage where item.piId == arrearageEntity.piId select item).FirstOrDefault(); if (tempEntity != null) { tempEntity.due = arrearageEntity.due; tempEntity.@default = arrearageEntity.@default; tempEntity.paidUp = arrearageEntity.paidUp; tempEntity.inputMan = arrearageEntity.inputMan; } else { oContext.Arrearage.InsertOnSubmit(arrearageEntity); } } else if (entity.tFundsRecorder[0].type == EnumAccountType.收款.ToString() && entity.tFundsRecorder[0].IsciIdNull() == false) { //销售 receiveEntity = new AccountReceivable(); receiveEntity.ciId = entity.tFundsRecorder[0].ciId; receiveEntity.accountReceivable1 = entity.tFundsRecorder[0].cash1; receiveEntity.@default = entity.tFundsRecorder[0].cash2; receiveEntity.accept = receiveEntity.accountReceivable1 - receiveEntity.@default; receiveEntity.inputMan = entity.tFundsRecorder[0].inputMan; var tempEntity = (from item in oContext.AccountReceivable where item.ciId == receiveEntity.ciId select item).FirstOrDefault(); if (tempEntity != null) { tempEntity.accountReceivable1 = receiveEntity.accountReceivable1; tempEntity.@default = receiveEntity.@default; tempEntity.accept = receiveEntity.accept; tempEntity.inputMan = receiveEntity.inputMan; } else { oContext.AccountReceivable.InsertOnSubmit(receiveEntity); } } oContext.FundsRecorder.InsertOnSubmit(linqEntity); oContext.SubmitChanges(); } //System.Data.SqlClient.SqlConnection sqlConn = null; //System.Data.SqlClient.SqlTransaction sqlTrans = null; //System.Data.SqlClient.SqlParameter[] sqlpmParams = GetTableParameters(); //SetParamsValue(entity, sqlpmParams); //try //{ // sqlConn = new SqlConnection(strConn); // if (sqlConn.State != ConnectionState.Open) // { // sqlConn.Open(); // } // sqlTrans = sqlConn.BeginTransaction(); // Iori.DataAccess.SQLServerDAL.SQLHelper.ExecuteNonQuery(sqlConn, CommandType.Text, INSERT_SQL, sqlpmParams); // // sqlTrans.Commit(); //} //catch (System.Data.SqlClient.SqlException) //{ // if (sqlTrans != null) // { // sqlTrans.Rollback(); // } //} //finally //{ // if (sqlConn != null && sqlConn.State != ConnectionState.Closed) // { // sqlConn.Close(); // } //} }