public IActionResult SaveCinEntry(CinEntryDTO _CinEntryDTO) { bool isSaved = false; try { isSaved = objChallana.SaveCinEntry(_CinEntryDTO, Con); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(Ok(isSaved)); }
public bool SaveCinEntry(CinEntryDTO _CinEntryDTO, string ConnectionString) { bool isSaved = false; StringBuilder sbinsert = new StringBuilder(); try { con = new NpgsqlConnection(ConnectionString); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); string query = ""; Int64 VoucherId = Convert.ToInt64(NPGSqlHelper.ExecuteScalar(trans, CommandType.Text, "select recordid from tbltranspaymentvoucher where paymentid = '" + _CinEntryDTO.pVoucherId + "'")); if (string.IsNullOrEmpty(_CinEntryDTO.ptypeofoperation.ToString())) { _CinEntryDTO.ptypeofoperation = "CREATE"; } if (_CinEntryDTO.ptypeofoperation.ToString().ToUpper() == "CREATE") { query = "insert into cin_entry( challana_id, voucher_id, reference_no, paid_date, paid_bank,bsr_code,challana_sl_no,challana_bank,challana_date)values(" + _CinEntryDTO.pChallanaId + "," + VoucherId + ",'" + _CinEntryDTO.pReferenceNo + "','" + FormatDate(_CinEntryDTO.pPaidDate.ToString()) + "','" + _CinEntryDTO.pPaidBank + "','" + _CinEntryDTO.pBsrCode + "','" + _CinEntryDTO.pChallanaSNO + "','" + _CinEntryDTO.pChallanaBank + "','" + FormatDate(_CinEntryDTO.pChallanaDate.ToString()) + "') "; NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, query); } 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); }