/// <summary> /// Function to insert values to budgetMaster Table /// </summary> /// <param name="budgetmasterinfo"></param> /// <returns></returns> public decimal BudgetMasterAdd(BudgetMasterInfo budgetmasterinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BudgetMasterAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@budgetName", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.BudgetName; sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Type; sprmparam = sccmd.Parameters.Add("@totalDr", SqlDbType.Decimal); sprmparam.Value = budgetmasterinfo.TotalDr; sprmparam = sccmd.Parameters.Add("@totalCr", SqlDbType.Decimal); sprmparam.Value = budgetmasterinfo.TotalCr; sprmparam = sccmd.Parameters.Add("@fromDate", SqlDbType.DateTime); sprmparam.Value = budgetmasterinfo.FromDate; sprmparam = sccmd.Parameters.Add("@toDate", SqlDbType.DateTime); sprmparam.Value = budgetmasterinfo.ToDate; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decIdentity); }
/// <summary> /// Function to Update values in BudgetMaster Table /// </summary> /// <param name="budgetmasterinfo"></param> public void BudgetMasterEdit(BudgetMasterInfo budgetmasterinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BudgetMasterEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@budgetMasterId", SqlDbType.Decimal); sprmparam.Value = budgetmasterinfo.BudgetMasterId; sprmparam = sccmd.Parameters.Add("@budgetName", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.BudgetName; sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Type; sprmparam = sccmd.Parameters.Add("@totalDr", SqlDbType.Decimal); sprmparam.Value = budgetmasterinfo.TotalDr; sprmparam = sccmd.Parameters.Add("@totalCr", SqlDbType.Decimal); sprmparam.Value = budgetmasterinfo.TotalCr; sprmparam = sccmd.Parameters.Add("@fromDate", SqlDbType.DateTime); sprmparam.Value = budgetmasterinfo.FromDate; sprmparam = sccmd.Parameters.Add("@toDate", SqlDbType.DateTime); sprmparam.Value = budgetmasterinfo.ToDate; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = budgetmasterinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from BudgetMaster table based on the parameter /// </summary> /// <param name="budgetMasterId"></param> /// <returns></returns> public BudgetMasterInfo BudgetMasterView(decimal budgetMasterId) { BudgetMasterInfo budgetmasterinfo = new BudgetMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BudgetMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@budgetMasterId", SqlDbType.Decimal); sprmparam.Value = budgetMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { budgetmasterinfo.BudgetMasterId = Convert.ToDecimal(sdrreader["budgetMasterId"].ToString()); budgetmasterinfo.BudgetName = sdrreader["budgetName"].ToString(); budgetmasterinfo.Type = sdrreader["type"].ToString(); budgetmasterinfo.TotalDr = Convert.ToDecimal(sdrreader["totalDr"].ToString()); budgetmasterinfo.TotalCr = Convert.ToDecimal(sdrreader["totalCr"].ToString()); budgetmasterinfo.FromDate = DateTime.Parse(sdrreader["fromDate"].ToString()); budgetmasterinfo.ToDate = DateTime.Parse(sdrreader["toDate"].ToString()); budgetmasterinfo.Narration = sdrreader["narration"].ToString(); budgetmasterinfo.Extra1 = sdrreader["extra1"].ToString(); budgetmasterinfo.Extra2 = sdrreader["extra2"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(budgetmasterinfo); }