/// <summary> /// Function to insert values to JournalDetails Table /// </summary> /// <param name="journaldetailsinfo"></param> /// <returns></returns> public decimal JournalDetailsAdd(JournalDetailsInfo journaldetailsinfo) { decimal decId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("JournalDetailsAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@journalMasterId", SqlDbType.Decimal); sprmparam.Value = journaldetailsinfo.JournalMasterId; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = journaldetailsinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@credit", SqlDbType.Decimal); sprmparam.Value = journaldetailsinfo.Credit; sprmparam = sccmd.Parameters.Add("@debit", SqlDbType.Decimal); sprmparam.Value = journaldetailsinfo.Debit; sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam.Value = journaldetailsinfo.ExchangeRateId; sprmparam = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar); sprmparam.Value = journaldetailsinfo.ChequeNo; sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam.Value = journaldetailsinfo.ChequeDate; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = journaldetailsinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = journaldetailsinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = journaldetailsinfo.Extra2; decId = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decId); }
/// <summary> /// Function to get particular values from JournalDetails table based on the parameter /// </summary> /// <param name="journalDetailsId"></param> /// <returns></returns> public JournalDetailsInfo JournalDetailsView(decimal journalDetailsId) { JournalDetailsInfo journaldetailsinfo = new JournalDetailsInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("JournalDetailsView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@journalDetailsId", SqlDbType.Decimal); sprmparam.Value = journalDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { journaldetailsinfo.JournalDetailsId = decimal.Parse(sdrreader[0].ToString()); journaldetailsinfo.JournalMasterId = decimal.Parse(sdrreader[1].ToString()); journaldetailsinfo.LedgerId = decimal.Parse(sdrreader[2].ToString()); journaldetailsinfo.Credit = decimal.Parse(sdrreader[3].ToString()); journaldetailsinfo.Debit = decimal.Parse(sdrreader[4].ToString()); journaldetailsinfo.ExchangeRateId = decimal.Parse(sdrreader[5].ToString()); journaldetailsinfo.ChequeNo = sdrreader[6].ToString(); journaldetailsinfo.ChequeDate = DateTime.Parse(sdrreader[7].ToString()); journaldetailsinfo.ExtraDate = DateTime.Parse(sdrreader[8].ToString()); journaldetailsinfo.Extra1 = sdrreader[9].ToString(); journaldetailsinfo.Extra2 = sdrreader[10].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(journaldetailsinfo); }