public async Task <IActionResult> SaveSavingsReceipt([FromBody] SAReceiptDTO ObjSAReceiptDTO) { try { string OUTReceiptid = string.Empty; if (objSDReceipt.SaveSavingsReceipt(ObjSAReceiptDTO, Con, out OUTReceiptid)) { if (!string.IsNullOrEmpty(OUTReceiptid)) { _GeneralReceiptReportDTO = new GeneralReceiptReportDTO(); _GeneralReceiptReportDTO = await _AccountingTransactionsDAL.GetgeneralreceiptReportData1(OUTReceiptid, Con); _GeneralReceiptReportDTO.pCompanyInfoforReports = obj.GetcompanyNameandaddressDetails(Con); return(Ok(_GeneralReceiptReportDTO)); } else { return(Ok(false)); } } else { return(StatusCode(StatusCodes.Status304NotModified)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError)); throw ex; } }
public bool SaveSavingsReceipt(SAReceiptDTO ObjSAReceiptDTO, string ConnectionString, out string OUTReceiptid) { bool Issaved = false; StringBuilder sbInsert = new StringBuilder(); bool IsAccountSaved = false; try { con = new NpgsqlConnection(ConnectionString); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); if (SaveSAgenaralreceipt(ObjSAReceiptDTO, trans, out OUTReceiptid)) { IsAccountSaved = true; } else { trans.Rollback(); return(IsAccountSaved); } string Receiptno = OUTReceiptid; ObjSAReceiptDTO.pReceiptno = Receiptno; if (string.IsNullOrEmpty(ObjSAReceiptDTO.pRecordid.ToString()) || ObjSAReceiptDTO.pRecordid == 0) { sbInsert.Append("insert into Saving_Account_receipt (Trans_date, member_id, saving_account_id, received_amount, penalty_amount, mode_of_receipt, receipt_no, narration, status) values ('" + FormatDate(ObjSAReceiptDTO.pReceiptdate) + "', " + ObjSAReceiptDTO.pMemberid + ", " + ObjSAReceiptDTO.psavingaccountid + ", " + ObjSAReceiptDTO.pReceivedamount + ", " + ObjSAReceiptDTO.ppenaltyamount + ", '" + ObjSAReceiptDTO.pModeofreceipt + "', '" + ObjSAReceiptDTO.pReceiptno + "', '" + ObjSAReceiptDTO.pNarration + "', true);"); } if (!string.IsNullOrEmpty(sbInsert.ToString())) { NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, sbInsert.ToString()); } trans.Commit(); Issaved = true; } catch (Exception ex) { trans.Rollback(); throw ex; } finally { if (con.State == ConnectionState.Open) { con.Dispose(); con.Close(); con.ClearPool(); trans.Dispose(); } } return(Issaved); }
public bool SaveSAgenaralreceipt(SAReceiptDTO ObjSAReceiptDTO, NpgsqlTransaction trans, out string Receiptid) { bool IsSaved = false; StringBuilder sbQuery = new StringBuilder(); AccountingTransactionsDAL Accontstrans = new AccountingTransactionsDAL(); try { GeneralreceiptDTO Objgeneralreceipt = new GeneralreceiptDTO(); Objgeneralreceipt.preceiptid = ""; Objgeneralreceipt.ppartyid = ObjSAReceiptDTO.pConid; Objgeneralreceipt.ppartyreferenceid = ObjSAReceiptDTO.pContactid; Objgeneralreceipt.ppartyreftype = "Saving Account Receipt"; Objgeneralreceipt.ppartyname = ObjSAReceiptDTO.pMembername; Objgeneralreceipt.preceiptdate = ObjSAReceiptDTO.pReceiptdate.ToString(); Objgeneralreceipt.pmodofreceipt = ObjSAReceiptDTO.pModeofreceipt; Objgeneralreceipt.ptotalreceivedamount = Convert.ToDecimal(ObjSAReceiptDTO.pReceivedamount); Objgeneralreceipt.pnarration = ObjSAReceiptDTO.pNarration; Objgeneralreceipt.pbankname = ObjSAReceiptDTO.pBank; Objgeneralreceipt.pBankId = ObjSAReceiptDTO.pBankid; Objgeneralreceipt.pdepositbankid = ObjSAReceiptDTO.pdepositbankid; Objgeneralreceipt.pbranchname = ObjSAReceiptDTO.pBranch; Objgeneralreceipt.ptranstype = ObjSAReceiptDTO.pTranstype; Objgeneralreceipt.ptypeofpayment = ObjSAReceiptDTO.ptypeofpayment; Objgeneralreceipt.pChequenumber = ObjSAReceiptDTO.pChequenumber; if (ObjSAReceiptDTO.ptypeofpayment == "Debit Card") { Objgeneralreceipt.pchequedate = ObjSAReceiptDTO.pReceiptdate.ToString(); } else if (ObjSAReceiptDTO.ptypeofpayment == "Credit Card") { Objgeneralreceipt.pchequedate = ObjSAReceiptDTO.pReceiptdate.ToString(); } else { Objgeneralreceipt.pchequedate = ObjSAReceiptDTO.pchequedate; } Objgeneralreceipt.pCardNumber = ObjSAReceiptDTO.pCardnumber; Objgeneralreceipt.pUpiid = ObjSAReceiptDTO.pUpiid; Objgeneralreceipt.pCreatedby = ObjSAReceiptDTO.pCreatedby; string membername = ObjSAReceiptDTO.pMembername; string membercode = ObjSAReceiptDTO.pMembercode; string membernamecode = membercode + "_" + membername; List <ReceiptsDTO> preceiptslist = new List <ReceiptsDTO>(); ReceiptsDTO objpreceipts = new ReceiptsDTO(); objpreceipts.psubledgerid = ObjSAReceiptDTO.pSubledgerid; objpreceipts.pledgername = membername; objpreceipts.ptdsamountindividual = Convert.ToDecimal(ObjSAReceiptDTO.pReceivedamount); objpreceipts.pamount = Convert.ToDecimal(ObjSAReceiptDTO.pReceivedamount); preceiptslist.Add(objpreceipts); Objgeneralreceipt.preceiptslist = preceiptslist; if (Accontstrans.CallsaveGeneralReceipt(Objgeneralreceipt, trans, out Receiptid)) { IsSaved = true; } } catch (Exception ex) { throw ex; } return(IsSaved); }