/// <summary>
 /// Function to Update values in SalesMaster Table
 /// </summary>
 /// <param name="salesmasterinfo"></param>
 public void SalesMasterEdit(SalesMasterInfo salesmasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.SalesMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = salesmasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int);
         sprmparam.Value = salesmasterinfo.CreditPeriod;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@salesAccount", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.SalesAccount;
         sprmparam = sccmd.Parameters.Add("@deliveryNoteMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.DeliveryNoteMasterId;
         sprmparam = sccmd.Parameters.Add("@orderMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.OrderMasterId;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@customerName", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.CustomerName;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@taxAmount", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.TaxAmount;
         sprmparam = sccmd.Parameters.Add("@additionalCost", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.AdditionalCost;
         sprmparam = sccmd.Parameters.Add("@billDiscount", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.BillDiscount;
         sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.GrandTotal;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.LrNo;
         sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.TransportationCompany;
         sprmparam = sccmd.Parameters.Add("@quotationMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.QuotationMasterId;
         sprmparam = sccmd.Parameters.Add("@POS", SqlDbType.Bit);
         sprmparam.Value = salesmasterinfo.POS;
         sprmparam = sccmd.Parameters.Add("@counterId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.CounterId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = salesmasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = salesmasterinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = salesmasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 /// <summary>
 /// Function for SalesMaster View By SalesMasterId
 /// </summary>
 /// <param name="salesMasterId"></param>
 /// <returns></returns>
 public SalesMasterInfo SalesMasterViewBySalesMasterId(decimal salesMasterId)
 {
     SalesMasterInfo infoSalesMaster = new SalesMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesMasterViewBySalesMasterId", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             infoSalesMaster.InvoiceNo = sdrreader["invoiceNo"].ToString();
             infoSalesMaster.VoucherNo = sdrreader["voucherNo"].ToString();
             infoSalesMaster.VoucherTypeId = Convert.ToDecimal(sdrreader["voucherTypeId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SM:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         sqlcon.Close();
     }
     return infoSalesMaster;
 }
 /// <summary>
 /// Function to get particular values from SalesMaster Table based on the parameter
 /// </summary>
 /// <param name="salesMasterId"></param>
 /// <returns></returns>
 public SalesMasterInfo SalesMasterView(string salesMasterId)
 {
     SalesMasterInfo salesmasterinfo = new SalesMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalesMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal);
         sprmparam.Value = salesMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             salesmasterinfo.SalesMasterId = decimal.Parse(sdrreader[0].ToString());
             salesmasterinfo.VoucherNo = sdrreader[1].ToString();
             salesmasterinfo.InvoiceNo = sdrreader[2].ToString();
             salesmasterinfo.VoucherTypeId = decimal.Parse(sdrreader[3].ToString());
             salesmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[4].ToString());
             salesmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString());
             salesmasterinfo.CreditPeriod = int.Parse(sdrreader[6].ToString());
             salesmasterinfo.LedgerId = decimal.Parse(sdrreader[7].ToString());
             salesmasterinfo.PricinglevelId = decimal.Parse(sdrreader[8].ToString());
             salesmasterinfo.EmployeeId = decimal.Parse(sdrreader[9].ToString());
             salesmasterinfo.SalesAccount = decimal.Parse(sdrreader[10].ToString());
             salesmasterinfo.DeliveryNoteMasterId = decimal.Parse(sdrreader[11].ToString());
             salesmasterinfo.OrderMasterId = decimal.Parse(sdrreader[12].ToString());
             salesmasterinfo.Narration = sdrreader[13].ToString();
             salesmasterinfo.CustomerName = sdrreader[14].ToString();
             salesmasterinfo.ExchangeRateId = decimal.Parse(sdrreader[15].ToString());
             salesmasterinfo.TaxAmount = decimal.Parse(sdrreader[16].ToString());
             salesmasterinfo.AdditionalCost = decimal.Parse(sdrreader[17].ToString());
             salesmasterinfo.BillDiscount = decimal.Parse(sdrreader[18].ToString());
             salesmasterinfo.GrandTotal = decimal.Parse(sdrreader[19].ToString());
             salesmasterinfo.TotalAmount = decimal.Parse(sdrreader[20].ToString());
             salesmasterinfo.UserId = decimal.Parse(sdrreader[21].ToString());
             salesmasterinfo.LrNo = sdrreader[22].ToString();
             salesmasterinfo.TransportationCompany = sdrreader[23].ToString();
             salesmasterinfo.QuotationMasterId = decimal.Parse(sdrreader[24].ToString());
             salesmasterinfo.POS = bool.Parse(sdrreader[25].ToString());
             salesmasterinfo.CounterId = decimal.Parse(sdrreader[26].ToString());
             salesmasterinfo.FinancialYearId = decimal.Parse(sdrreader[27].ToString());
             salesmasterinfo.ExtraDate = DateTime.Parse(sdrreader[28].ToString());
             salesmasterinfo.Extra1 = sdrreader[29].ToString();
             salesmasterinfo.Extra2 = sdrreader[30].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return salesmasterinfo;
 }
        public SalesMasterInfo SalesMasterViewBySalesMasterId(decimal salesMasterId)
        {
            try
            {
                InfoSalesMaster = SPSalesMaster.SalesMasterViewBySalesMasterId(salesMasterId);
            }

            catch (Exception ex)
            {
                MessageBox.Show("CB:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return InfoSalesMaster;
        }
        public void SalesMasterEdit(SalesMasterInfo salesmasterinfo)
        {
            try
            {
                SPSalesMaster.SalesMasterEdit(salesmasterinfo);
            }

            catch (Exception ex)
            {
                MessageBox.Show("CB:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 public decimal SalesMasterAdd(SalesMasterInfo salesmasterinfo)
 {
     decimal decCompanyId = 0;
     try
     {
         decCompanyId = SPSalesMaster.SalesMasterAdd(salesmasterinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CB:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return decCompanyId;
 }