/// <summary>
 /// 
 /// </summary>
 /// <param name="infoAccountLedger"></param>
 /// <returns></returns>
 public decimal AccountLedgerAddWithIdentity(AccountLedgerInfo infoAccountLedger)
 {
     decimal decLedgerId = 0;
     try
     {
         decLedgerId = spAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return decLedgerId;
 }
 /// <summary>
 /// Account ledger edit for salesman
 /// </summary>
 /// <param name="accountledgerinfo"></param>
 public void AccountLedgerEditForSalesman(AccountLedgerInfo accountledgerinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerEditForSalesman", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@ledgerName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.LedgerName;
         sprmparam = sccmd.Parameters.Add("@openingBalance", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.OpeningBalance;
         sprmparam = sccmd.Parameters.Add("@crOrDr", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.CrOrDr;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@mailingName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.MailingName;
         sprmparam = sccmd.Parameters.Add("@address", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Address;
         sprmparam = sccmd.Parameters.Add("@phone", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Phone;
         sprmparam = sccmd.Parameters.Add("@mobile", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Mobile;
         sprmparam = sccmd.Parameters.Add("@email", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Email;
         sprmparam = sccmd.Parameters.Add("@billByBill", SqlDbType.Bit);
         sprmparam.Value = accountledgerinfo.BillByBill;
         sprmparam = sccmd.Parameters.Add("@tin", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Tin;
         sprmparam = sccmd.Parameters.Add("@cst", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Cst;
         sprmparam = sccmd.Parameters.Add("@pan", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Pan;
         sprmparam = sccmd.Parameters.Add("@RouteId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.RouteId;
         sprmparam = sccmd.Parameters.Add("@bankAccountNumber", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BankAccountNumber;
         sprmparam = sccmd.Parameters.Add("@branchName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BranchName;
         sprmparam = sccmd.Parameters.Add("@branchCode", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BranchCode;
         sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.AreaId;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = accountledgerinfo.ExtraDate;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 /// <summary>
 /// Function to insert values to account ledger table and returns the id of inserted
 /// </summary>
 /// <param name="accountledgerinfo"></param>
 /// <returns></returns>
 public decimal AccountLedgerAddWithIdentity(AccountLedgerInfo accountledgerinfo)
 {
     decimal decLedgerId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerAddWithIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@accountGroupId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.AccountGroupId;
         sprmparam = sccmd.Parameters.Add("@ledgerName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.LedgerName;
         sprmparam = sccmd.Parameters.Add("@openingBalance", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.OpeningBalance;
         sprmparam = sccmd.Parameters.Add("@crOrDr", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.CrOrDr;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@mailingName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.MailingName;
         sprmparam = sccmd.Parameters.Add("@address", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Address;
         sprmparam = sccmd.Parameters.Add("@phone", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Phone;
         sprmparam = sccmd.Parameters.Add("@mobile", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Mobile;
         sprmparam = sccmd.Parameters.Add("@email", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Email;
         sprmparam = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int);
         sprmparam.Value = accountledgerinfo.CreditPeriod;
         sprmparam = sccmd.Parameters.Add("@creditLimit", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.CreditLimit;
         sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.PricinglevelId;
         sprmparam = sccmd.Parameters.Add("@billByBill", SqlDbType.Bit);
         sprmparam.Value = accountledgerinfo.BillByBill;
         sprmparam = sccmd.Parameters.Add("@tin", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Tin;
         sprmparam = sccmd.Parameters.Add("@cst", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Cst;
         sprmparam = sccmd.Parameters.Add("@pan", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Pan;
         sprmparam = sccmd.Parameters.Add("@RouteId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.RouteId;
         sprmparam = sccmd.Parameters.Add("@bankAccountNumber", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BankAccountNumber;
         sprmparam = sccmd.Parameters.Add("@branchName", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BranchName;
         sprmparam = sccmd.Parameters.Add("@branchCode", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.BranchCode;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = accountledgerinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = accountledgerinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal);
         sprmparam.Value = accountledgerinfo.AreaId;
         sprmparam = sccmd.Parameters.Add("@isDefault", SqlDbType.Bit);
         sprmparam.Value = accountledgerinfo.IsDefault;
         object obj = sccmd.ExecuteScalar();
         if (obj != null)
         {
             decLedgerId = Convert.ToDecimal(obj.ToString());
         }
         else
         {
             decLedgerId = 0;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decLedgerId;
 }
 /// <summary>
 /// Account ledger view details for supplier
 /// </summary>
 /// <param name="ledgerId"></param>
 /// <returns></returns>
 public AccountLedgerInfo AccountLedgerViewForSupplier(decimal ledgerId)
 {
     AccountLedgerInfo accountledgerinfo = new AccountLedgerInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerViewForSupplier", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = ledgerId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             accountledgerinfo.LedgerId = Convert.ToDecimal(sdrreader[0].ToString());
             accountledgerinfo.LedgerName = sdrreader[1].ToString();
             accountledgerinfo.OpeningBalance = Convert.ToDecimal(sdrreader[2].ToString());
             accountledgerinfo.CrOrDr = sdrreader[3].ToString();
             accountledgerinfo.Narration = sdrreader[4].ToString();
             accountledgerinfo.MailingName = sdrreader[5].ToString();
             accountledgerinfo.Address = sdrreader[6].ToString();
             accountledgerinfo.Phone = sdrreader[7].ToString();
             accountledgerinfo.Mobile = sdrreader[8].ToString();
             accountledgerinfo.Email = sdrreader[9].ToString();
             accountledgerinfo.BillByBill = Convert.ToBoolean(sdrreader[10].ToString());
             accountledgerinfo.Tin = sdrreader[11].ToString();
             accountledgerinfo.Cst = sdrreader[12].ToString();
             accountledgerinfo.Pan = sdrreader[13].ToString();
             accountledgerinfo.RouteId = Convert.ToDecimal(sdrreader[14].ToString());
             accountledgerinfo.BankAccountNumber = sdrreader[15].ToString();
             accountledgerinfo.BranchName = sdrreader[16].ToString();
             accountledgerinfo.BranchCode = sdrreader[17].ToString();
             accountledgerinfo.AreaId = Convert.ToDecimal(sdrreader[18].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return accountledgerinfo;
 }
 /// <summary>
 /// Function to view the account ledger details for perticular ledgerId for edit
 /// </summary>
 /// <param name="ledgerId"></param>
 /// <returns></returns>
 public AccountLedgerInfo AccountLedgerViewForEdit(decimal ledgerId)
 {
     AccountLedgerInfo accountledgerinfo = new AccountLedgerInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerViewForEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = ledgerId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             accountledgerinfo.LedgerId = decimal.Parse(sdrreader[0].ToString());
             accountledgerinfo.AccountGroupId = decimal.Parse(sdrreader[1].ToString());
             accountledgerinfo.LedgerName = sdrreader[2].ToString();
             accountledgerinfo.OpeningBalance = decimal.Parse(sdrreader[3].ToString());
             accountledgerinfo.CrOrDr = sdrreader[4].ToString();
             accountledgerinfo.Narration = sdrreader[5].ToString();
             accountledgerinfo.MailingName = sdrreader[6].ToString();
             accountledgerinfo.Address = sdrreader[7].ToString();
             accountledgerinfo.Phone = sdrreader[8].ToString();
             accountledgerinfo.Mobile = sdrreader[9].ToString();
             accountledgerinfo.Email = sdrreader[10].ToString();
             accountledgerinfo.CreditPeriod = int.Parse(sdrreader[11].ToString());
             accountledgerinfo.CreditLimit = decimal.Parse(sdrreader[12].ToString());
             accountledgerinfo.PricinglevelId = decimal.Parse(sdrreader[13].ToString());
             accountledgerinfo.BillByBill = bool.Parse(sdrreader[14].ToString());
             accountledgerinfo.Tin = sdrreader[15].ToString();
             accountledgerinfo.Cst = sdrreader[16].ToString();
             accountledgerinfo.Pan = sdrreader[17].ToString();
             accountledgerinfo.RouteId = decimal.Parse(sdrreader[18].ToString());
             accountledgerinfo.BankAccountNumber = sdrreader[19].ToString();
             accountledgerinfo.BranchName = sdrreader[20].ToString();
             accountledgerinfo.BranchCode = sdrreader[21].ToString();
             accountledgerinfo.ExtraDate = DateTime.Parse(sdrreader[22].ToString());
             accountledgerinfo.Extra1 = sdrreader[23].ToString();
             accountledgerinfo.Extra2 = sdrreader[24].ToString();
             accountledgerinfo.AreaId = decimal.Parse(sdrreader[25].ToString());
             accountledgerinfo.IsDefault = bool.Parse(sdrreader[26].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return accountledgerinfo;
 }
 /// <summary>
 /// Account ledger details view by id
 /// </summary>
 /// <param name="ledgerId"></param>
 /// <returns></returns>
 public AccountLedgerInfo accountLedgerviewbyId(decimal ledgerId)
 {
     AccountLedgerInfo accountledgerinfo = new AccountLedgerInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = ledgerId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             accountledgerinfo.LedgerId = Convert.ToDecimal(sdrreader["ledgerId"].ToString());
             accountledgerinfo.LedgerName = sdrreader["ledgerName"].ToString();
             accountledgerinfo.CreditPeriod = Convert.ToInt32(sdrreader["creditPeriod"].ToString());
             accountledgerinfo.PricinglevelId = Convert.ToDecimal(sdrreader["pricinglevelId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return accountledgerinfo;
 }
 /// <summary>
 /// Function to get particular values from account ledger table based on the parameter
 /// </summary>
 /// <param name="ledgerId"></param>
 /// <returns></returns>
 public AccountLedgerInfo AccountLedgerView(decimal ledgerId)
 {
     AccountLedgerInfo accountledgerinfo = new AccountLedgerInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AccountLedgerView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = ledgerId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             accountledgerinfo.LedgerId = Convert.ToDecimal(sdrreader["ledgerId"].ToString());
             accountledgerinfo.AccountGroupId = Convert.ToDecimal(sdrreader["accountGroupId"].ToString());
             accountledgerinfo.LedgerName = sdrreader["ledgerName"].ToString();
             accountledgerinfo.OpeningBalance = Convert.ToDecimal(sdrreader["openingBalance"].ToString());
             accountledgerinfo.CrOrDr = sdrreader["crOrDr"].ToString();
             accountledgerinfo.Narration = sdrreader["narration"].ToString();
             accountledgerinfo.MailingName = sdrreader["mailingName"].ToString();
             accountledgerinfo.Address = sdrreader["address"].ToString();
             accountledgerinfo.Phone = sdrreader["phone"].ToString();
             accountledgerinfo.Mobile = sdrreader["mobile"].ToString();
             accountledgerinfo.Email = sdrreader["email"].ToString();
             accountledgerinfo.CreditPeriod = Convert.ToInt32(sdrreader["creditPeriod"].ToString());
             accountledgerinfo.CreditLimit = Convert.ToDecimal(sdrreader["creditLimit"].ToString());
             accountledgerinfo.PricinglevelId = Convert.ToDecimal(sdrreader["pricinglevelId"].ToString());
             accountledgerinfo.BillByBill = Convert.ToBoolean(sdrreader["billByBill"].ToString());
             accountledgerinfo.Tin = sdrreader["tin"].ToString();
             accountledgerinfo.Cst = sdrreader["cst"].ToString();
             accountledgerinfo.Pan = sdrreader["pan"].ToString();
             accountledgerinfo.RouteId = Convert.ToDecimal(sdrreader["routeId"].ToString());
             accountledgerinfo.BankAccountNumber = sdrreader["bankAccountNumber"].ToString();
             accountledgerinfo.BranchName = sdrreader["branchName"].ToString();
             accountledgerinfo.BranchCode = sdrreader["branchCode"].ToString();
             accountledgerinfo.ExtraDate = Convert.ToDateTime(sdrreader["extraDate"].ToString());
             accountledgerinfo.Extra1 = sdrreader["extra1"].ToString();
             accountledgerinfo.Extra2 = sdrreader["extra2"].ToString();
             accountledgerinfo.AreaId = Convert.ToDecimal(sdrreader["areaId"].ToString());
             accountledgerinfo.IsDefault = Convert.ToBoolean(sdrreader["isDefault"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return accountledgerinfo;
 }
 public AccountLedgerInfo AccountLedgerViewForSupplier(decimal decLedgerId)
 {
     AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
     try
     {
         infoAccountLedger = spAccountLedger.AccountLedgerViewForSupplier(decLedgerId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AL11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return infoAccountLedger;
 }
 public AccountLedgerInfo accountLedgerviewbyId(decimal decledgerId)
 {
     AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
      try
      {
          infoAccountLedger = spAccountLedger.accountLedgerviewbyId(decledgerId);
      }
      catch (Exception ex)
      {
          MessageBox.Show("AL38:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
      return infoAccountLedger;
 }
 public void AccountLedgerEditForSalesman(AccountLedgerInfo infoAccountLedger)
 {
     try
     {
         spAccountLedger.AccountLedgerEditForSalesman(infoAccountLedger);
     }
     catch(Exception ex)
     {
         MessageBox.Show("AL32:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 public void AccountLedgerEditForCustomer(AccountLedgerInfo accountledgerinfo)
 {
     try
     {
         spAccountLedger.AccountLedgerEditForCustomer(accountledgerinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AL21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }