public SavingAccountNameandCodeDTO getSavingAccountNameandCode(string ConnectionString, Int64 SavingAccountId) { SavingAccountNameandCodeDTO objSavingAccountNameandCode = new SavingAccountNameandCodeDTO(); try { using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "select Savingconfigid,savingaccname,savingacccode,companycode,branchcode,series,savingaccnamecode,createddate,case when statusid=1 then true else false end as status from tblmstSavingAccountConfig where Savingconfigid=" + SavingAccountId + " and statusid=" + Convert.ToInt32(Status.Active) + "")) { if (dr.Read()) { objSavingAccountNameandCode = new SavingAccountNameandCodeDTO() { pSavingAccountid = Convert.ToInt64(dr["Savingconfigid"]), pSavingAccountname = Convert.ToString(dr["savingaccname"]), pSavingAccountcode = Convert.ToString(dr["savingacccode"]), pCompanycode = Convert.ToString(dr["companycode"]), pBranchcode = Convert.ToString(dr["branchcode"]), pSeries = Convert.ToString(dr["series"]), pSavingaccnamecode = Convert.ToString(dr["savingaccnamecode"]), pStatusid = Convert.ToString(dr["status"]) }; } } } catch (Exception ex) { throw ex; } return(objSavingAccountNameandCode); }
public async Task <List <SavingAccountNameandCodeDTO> > GetSavingAccountConfigData(string ConnectionString) { await Task.Run(() => { listSavingAccountNameandCodeDTO = new List <SavingAccountNameandCodeDTO>(); try { using (NpgsqlDataReader dr = NPGSqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "select Savingconfigid,savingaccname,savingaccnamecode,createddate,case when statusid=" + Convert.ToInt32(Status.Active) + " then 'Active' else 'In-Active' end as status from tblmstSavingAccountConfig where statusid=" + Convert.ToInt32(Status.Active) + " order by savingaccname")) { while (dr.Read()) { SavingAccountNameandCodeDTO _SavingAccountNameandCodeDTO = new SavingAccountNameandCodeDTO { pSavingAccountid = Convert.ToInt64(dr["Savingconfigid"]), pSavingAccountname = Convert.ToString(dr["savingaccname"]), pSavingaccnamecode = Convert.ToString(dr["savingaccnamecode"]), pStatusid = Convert.ToString(dr["status"]) }; listSavingAccountNameandCodeDTO.Add(_SavingAccountNameandCodeDTO); } } } catch (Exception ex) { throw ex; } }); return(listSavingAccountNameandCodeDTO); }
public IActionResult saveAccountConfigNameAndCode(SavingAccountNameandCodeDTO SavingAccountNameandCodelist) { int isSaved = 0; try { isSaved = objSavingAccountConfig.SaveSavingAccountNameAndCode(SavingAccountNameandCodelist, Con); } catch (Exception ex) { throw new FinstaAppException(ex.ToString()); } return(Ok(isSaved)); }
public int SaveSavingAccountNameAndCode(SavingAccountNameandCodeDTO objSavingAccountNameandCode, string connectionstring) { StringBuilder sbinsert = new StringBuilder(); int SavingConfigid = 0; try { con = new NpgsqlConnection(connectionstring); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); if (objSavingAccountNameandCode.ptypeofoperation == "CREATE") { SavingConfigid = Convert.ToInt32(NPGSqlHelper.ExecuteScalar(trans, CommandType.Text, "insert into tblmstSavingAccountConfig(savingaccname,savingacccode,companycode,branchcode,series,serieslength,savingaccnamecode,statusid,createdby,createddate)values('" + ManageQuote(objSavingAccountNameandCode.pSavingAccountname) + "','" + ManageQuote(objSavingAccountNameandCode.pSavingAccountcode.Trim()) + "','" + ManageQuote(objSavingAccountNameandCode.pCompanycode.Trim()) + "','" + ManageQuote(objSavingAccountNameandCode.pBranchcode) + "','" + ManageQuote(objSavingAccountNameandCode.pSeries) + "'," + objSavingAccountNameandCode.pSerieslength + ",'" + ManageQuote(objSavingAccountNameandCode.pSavingaccnamecode) + "'," + Convert.ToInt32(Status.Active) + "," + objSavingAccountNameandCode.pCreatedby + ",current_timestamp) returning savingconfigid")); } trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } finally { if (con.State == ConnectionState.Open) { con.Dispose(); con.Close(); con.ClearPool(); trans.Dispose(); } } return(SavingConfigid); }