public void AdvancePaymentAdd(AdvancePaymentInfo advancepaymentinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AdvancePaymentAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         //sprmparam = sccmd.Parameters.Add("@advancePaymentId", SqlDbType.Decimal);
         //sprmparam.Value = advancepaymentinfo.AdvancePaymentId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.Date;
         sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.Amount;
         sprmparam = sccmd.Parameters.Add("@salaryMonth", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.SalaryMonth;
         sprmparam = sccmd.Parameters.Add("@chequenumber", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Chequenumber;
         sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.ChequeDate;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.FinancialYearId;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 public void AdvancePaymentEdit(AdvancePaymentInfo infoAdvancePayment)
 {
     try
     {
         spAdvancePayment.AdvancePaymentEdit(infoAdvancePayment);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 public List<DataTable> AdvancePaymentAddWithIdentity(AdvancePaymentInfo infoAdvancePayment, bool IsAutomatic)
 {
     List<DataTable> ListObj = new List<DataTable>();
     try
     {
         ListObj = spAdvancePayment.AdvancePaymentAddWithIdentity(infoAdvancePayment, IsAutomatic);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return ListObj;
 }
 public List<DataTable> AdvancePaymentAddWithIdentity(AdvancePaymentInfo advancepaymentinfo, bool IsAutomatic)
 {
     List<DataTable> ListObj = new List<DataTable>();
     DataTable dtbl = new DataTable();
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlDataAdapter sqlda = new SqlDataAdapter("AdvancePaymentAddWithIdentity", sqlcon);
         sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sqlda.SelectCommand.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.EmployeeId;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.LedgerId;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.VoucherNo;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.InvoiceNo;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.Date;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.Amount;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@salaryMonth", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.SalaryMonth;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@chequenumber", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Chequenumber;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@chequeDate", SqlDbType.DateTime);
         sprmparam.Value = advancepaymentinfo.ChequeDate;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Narration;
         //sprmparam = sqlda.SelectCommand.Parameters.Add("@extraDate", SqlDbType.DateTime);
         //sprmparam.Value = advancepaymentinfo.ExtraDate;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Extra1;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = advancepaymentinfo.Extra2;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.SuffixPrefixId;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.VoucherTypeId;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = advancepaymentinfo.FinancialYearId;
         sprmparam = sqlda.SelectCommand.Parameters.Add("@IsAutomatic", SqlDbType.Bit);
         sprmparam.Value = IsAutomatic;
         sqlda.Fill(dtbl);
         ListObj.Add(dtbl);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return ListObj;
 }
 public AdvancePaymentInfo AdvancePaymentView(decimal advancePaymentId)
 {
     AdvancePaymentInfo advancepaymentinfo = new AdvancePaymentInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("AdvancePaymentView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@advancePaymentId", SqlDbType.Decimal);
         sprmparam.Value = advancePaymentId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             advancepaymentinfo.AdvancePaymentId = Convert.ToDecimal(sdrreader[0].ToString());
             advancepaymentinfo.EmployeeId = Convert.ToDecimal(sdrreader[1].ToString());
             advancepaymentinfo.LedgerId = Convert.ToDecimal(sdrreader[2].ToString());
             advancepaymentinfo.VoucherNo = sdrreader[3].ToString();
             advancepaymentinfo.InvoiceNo = (sdrreader[4].ToString());
             advancepaymentinfo.Date = Convert.ToDateTime(sdrreader[5].ToString());
             advancepaymentinfo.Amount = Convert.ToDecimal(sdrreader[6].ToString());
             advancepaymentinfo.SalaryMonth = Convert.ToDateTime(sdrreader[7].ToString());
             advancepaymentinfo.Chequenumber = sdrreader[8].ToString();
             advancepaymentinfo.ChequeDate = Convert.ToDateTime(sdrreader[9].ToString());
             advancepaymentinfo.Narration = sdrreader[10].ToString();
             advancepaymentinfo.ExtraDate = Convert.ToDateTime(sdrreader[11].ToString());
             advancepaymentinfo.Extra1 = sdrreader[12].ToString();
             advancepaymentinfo.Extra2 = sdrreader[13].ToString();
             advancepaymentinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader[14].ToString());
             advancepaymentinfo.VoucherTypeId = Convert.ToDecimal(sdrreader[15].ToString());
             advancepaymentinfo.FinancialYearId = Convert.ToDecimal(sdrreader[16].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return advancepaymentinfo;
 }
 public AdvancePaymentInfo AdvancePaymentView(decimal decAdvancePaymentId)
 {
     AdvancePaymentInfo infoiAdvancePayment = new AdvancePaymentInfo();
     try
     {
         infoiAdvancePayment = spAdvancePayment.AdvancePaymentView(decAdvancePaymentId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return infoiAdvancePayment;
 }