public static void Save(Entity.Accounts.PurchaseBillPayment Payment) { using (DataManager oDm = new DataManager()) { oDm.Add("@PurchaseBillPaymentId", SqlDbType.Int, ParameterDirection.Input, Payment.PurchaseBillPaymentId); oDm.Add("@SupplierLedgerId_FK", SqlDbType.Int, ParameterDirection.Input, Payment.SupplierLedgerId_FK); oDm.Add("@CashBankLedgerID", SqlDbType.Int, ParameterDirection.Input, Payment.CashBankLedgerID); oDm.Add("@TransactionType", SqlDbType.VarChar, 40, ParameterDirection.Input, Payment.TransactionType); oDm.Add("@AmountPaid", SqlDbType.Decimal, ParameterDirection.Input, Payment.AmountPaid); oDm.Add("@AmountDeducted", SqlDbType.Decimal, ParameterDirection.Input, Payment.AmountDeducted); oDm.Add("@PaymentDate", SqlDbType.DateTime, ParameterDirection.Input, Payment.PaymentDate); oDm.Add("@ModeOfPayment", SqlDbType.VarChar, 15, ParameterDirection.Input, Payment.ModeOfPayment); oDm.Add("@ChequeNo", SqlDbType.VarChar, 30, ParameterDirection.Input, Payment.ChequeNo); if (Payment.ChequeDate == null) { oDm.Add("@ChequeDate", SqlDbType.DateTime, ParameterDirection.Input, DBNull.Value); } else { oDm.Add("@ChequeDate", SqlDbType.DateTime, ParameterDirection.Input, Payment.ChequeDate); } oDm.Add("@DrawnOn", SqlDbType.VarChar, 50, ParameterDirection.Input, Payment.DrawnOn); oDm.Add("@CreatedBy", SqlDbType.Int, ParameterDirection.Input, Payment.CreatedBy); oDm.Add("@CompanyId", SqlDbType.Int, ParameterDirection.Input, Payment.CompanyId); oDm.Add("@BranchId", SqlDbType.Int, ParameterDirection.Input, Payment.BranchId); oDm.Add("@FinYrId", SqlDbType.Int, ParameterDirection.Input, Payment.FinYrId); oDm.Add("@Narration", SqlDbType.NVarChar, 500, Payment.Narration); oDm.Add("@XMLCashBankVoucherDetails", SqlDbType.Xml, ParameterDirection.Input, Payment.XMLCashBankVoucherDetails); oDm.Add("@PaymentDetailsXML", SqlDbType.Xml, ParameterDirection.Input, Payment.PaymentDetailsXML); if (Payment.DeductionDetailsXML.Trim().Length > 0) { oDm.Add("@DeductionDetailsXML", SqlDbType.Xml, ParameterDirection.Input, Payment.DeductionDetailsXML); } else { oDm.Add("@DeductionDetailsXML", SqlDbType.Xml, ParameterDirection.Input, DBNull.Value); } oDm.Add("@CBVHeaderID", SqlDbType.Int, ParameterDirection.InputOutput, 0); oDm.CommandType = CommandType.StoredProcedure; oDm.ExecuteNonQuery("usp_PurchaseBillPayment_Save"); Payment.CBVHeaderID = (int)oDm["@CBVHeaderID"].Value; } }
public void Save(Entity.Accounts.PurchaseBillPayment Payment) { DataAccess.Accounts.PurchaseBillPayment.Save(Payment); }
protected void btnSave_Click(object sender, EventArgs e) { if (Validate()) { string strValues = txtPaymentDate.Text; strValues += chr.ToString() + ""; DataSet ds_fn = gf.ExecuteSelectSP("spSelect_GetFnYear", strValues); if (ds_fn.Tables[0].Rows[0]["FinYearID"].ToString() == Session["FinYrID"].ToString().Trim()) { BusinessLayer.Accounts.PurchaseBillPayment ObjPayment = new BusinessLayer.Accounts.PurchaseBillPayment(); Entity.Accounts.PurchaseBillPayment Payment = new Entity.Accounts.PurchaseBillPayment(); Payment.PurchaseBillPaymentId = 0; Payment.SupplierLedgerId_FK = Convert.ToInt32(ddlSupplierLedger.SelectedValue.Trim()); Payment.CashBankLedgerID = Convert.ToInt32(ddlCashBankLedger.SelectedValue.Trim()); Payment.TransactionType = "PAYMENT"; Payment.AmountPaid = Convert.ToDecimal(txtTotalAmt.Text.Trim()); Payment.AmountDeducted = Convert.ToDecimal(txtTotalDeductionAmt.Text.Trim()); Payment.PaymentDate = Convert.ToDateTime(txtPaymentDate.Text.Trim() + " 00:00:00"); Payment.ModeOfPayment = ddlPaymentMode.SelectedValue.Trim(); Payment.ChequeNo = txtChequeNo.Text.Trim(); if (txtChequeDate.Text.Trim().Length == 0) { Payment.ChequeDate = null; } else { Payment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.Trim() + " 00:00:00"); } Payment.DrawnOn = txtDrawnOn.Text.Trim(); Payment.CreatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name); Payment.CompanyId = Convert.ToInt32(Session["CompanyId"].ToString()); Payment.BranchId = Convert.ToInt32(Session["BranchId"].ToString()); Payment.FinYrId = Convert.ToInt32(Session["FinYrID"].ToString()); Payment.Narration = txtNarration.Text.Trim(); //-------------------------------------------------------------------------------------// DataTable DT = new DataTable(); DT.Columns.Add("PurchaseBillId", typeof(int)); DT.Columns.Add("Amount", typeof(decimal)); DataRow DR; foreach (GridViewRow GVR in dgvBill.Rows) { if (GVR.RowType == DataControlRowType.DataRow) { TextBox txtAmount = (TextBox)GVR.FindControl("txtAmount"); decimal Amount = (txtAmount.Text.Trim().Length > 0) ? Convert.ToDecimal(txtAmount.Text.Trim()) : 0; if (Amount > 0) { DR = DT.NewRow(); DR["PurchaseBillId"] = Convert.ToInt32(dgvBill.DataKeys[GVR.RowIndex].Value.ToString()); DR["Amount"] = Amount; DT.Rows.Add(DR); DT.AcceptChanges(); } } } using (DataSet ds = new DataSet()) { ds.Tables.Add(DT); Payment.PaymentDetailsXML = ds.GetXml().Replace("Table1>", "Table>"); } //---------------------------------------------------------------------------// string DeductionDetails = ""; if (ViewState["DeductionDetails"] != null) { DT = (DataTable)ViewState["DeductionDetails"]; DT.Columns.Remove("DeductionHead"); DT.AcceptChanges(); using (DataSet ds = new DataSet()) { ds.Tables.Add(DT); DeductionDetails = ds.GetXml().Replace("Table1>", "Table>"); } } Payment.DeductionDetailsXML = DeductionDetails; Payment.XMLCashBankVoucherDetails = PrepareXMLString(); ObjPayment.Save(Payment); ClearControls(); Message.IsSuccess = true; Message.Text = "Payment Saved Successfully"; btnPrint.Attributes.Add("onclick", "javascript:window.open('RPTGridView.aspx?ID=" + Payment.CBVHeaderID + "'); return false;"); } else { Message.IsSuccess = false; Message.Text = "Please select a Date Between " + Session["SesFromDate"].ToString() + " & " + Session["SesToDate"].ToString() + ""; } } Message.Show = true; }