/// <summary>
 /// Function to check method fo voucher numbering based on parameter
 /// </summary>
 /// <param name="voucherTypeId"></param>
 /// <returns></returns>
 public bool CheckMethodOfVoucherNumbering(decimal voucherTypeId)
 {
     VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
     SqlDataReader sdrreader = null;
     bool isAutomatic = false;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CheckMethodOfVoucherNumbering", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = voucherTypeId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             infoVoucherType.MethodOfVoucherNumbering = sdrreader["methodOfVoucherNumbering"].ToString();
         }
         if (infoVoucherType.MethodOfVoucherNumbering == "Automatic")
         {
             isAutomatic = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return isAutomatic;
 }
 /// <summary>
 /// Function for update VoucherType For Default Vouchers
 /// </summary>
 /// <param name="vouchertypeinfo"></param>
 public void VoucherTypeEditForDefaultVouchers(VoucherTypeInfo vouchertypeinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("VoucherTypeEditForDefaultVouchers", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = vouchertypeinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@methodOfVoucherNumbering", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.MethodOfVoucherNumbering;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
         sprmparam.Value = vouchertypeinfo.IsActive;
         sprmparam = sccmd.Parameters.Add("@declaration", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Declarartion;
         sprmparam = sccmd.Parameters.Add("@heading1", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading1;
         sprmparam = sccmd.Parameters.Add("@heading2", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading2;
         sprmparam = sccmd.Parameters.Add("@heading3", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading3;
         sprmparam = sccmd.Parameters.Add("@heading4", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading4;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
 /// <summary>
 /// Function to view type of voucher based on parameter
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <returns></returns>
 public VoucherTypeInfo TypeOfVoucherBasedOnVoucherTypeId(decimal decVoucherTypeId)
 {
     SqlDataReader sdrReader = null;
     VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sqlcmd = new SqlCommand("TypeOfVoucherBasedOnVoucherTypeId", sqlcon);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal).Value = decVoucherTypeId;
         sdrReader = sqlcmd.ExecuteReader();
         while (sdrReader.Read())
         {
             infoVoucherType.TypeOfVoucher = sdrReader["typeOfVoucher"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("VTSP:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         sdrReader.Close();
         sqlcon.Close();
     }
     return infoVoucherType;
 }
 /// <summary>
 /// Function to insert values to table and return id 
 /// </summary>
 /// <param name="vouchertypeinfo"></param>
 /// <returns></returns>
 public decimal VoucherTypeAddWithIdentity(VoucherTypeInfo vouchertypeinfo)
 {
     decimal decVoucherTypeId = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("VoucherTypeAddWithIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherTypeName", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.VoucherTypeName;
         sprmparam = sccmd.Parameters.Add("@typeOfVoucher", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.TypeOfVoucher;
         sprmparam = sccmd.Parameters.Add("@methodOfVoucherNumbering", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.MethodOfVoucherNumbering;
         sprmparam = sccmd.Parameters.Add("@isTaxApplicable", SqlDbType.Bit);
         sprmparam.Value = vouchertypeinfo.IsTaxApplicable;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Extra2;
         sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit);
         sprmparam.Value = vouchertypeinfo.IsActive;
         sprmparam = sccmd.Parameters.Add("@IsDefault", SqlDbType.Bit);
         sprmparam.Value = vouchertypeinfo.IsDefault;
         sprmparam = sccmd.Parameters.Add("@masterId", SqlDbType.Int);
         sprmparam.Value = vouchertypeinfo.MasterId;
         sprmparam = sccmd.Parameters.Add("@declaration", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Declarartion;
         sprmparam = sccmd.Parameters.Add("@heading1", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading1;
         sprmparam = sccmd.Parameters.Add("@heading2", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading2;
         sprmparam = sccmd.Parameters.Add("@heading3", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading3;
         sprmparam = sccmd.Parameters.Add("@heading4", SqlDbType.VarChar);
         sprmparam.Value = vouchertypeinfo.Heading4;
         object obj = sccmd.ExecuteScalar();
         if (obj != null)
         {
             decVoucherTypeId = Convert.ToDecimal(obj.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decVoucherTypeId;
 }
 /// <summary>
 /// Function to view all VoucherTypes based on parameter
 /// </summary>
 /// <param name="voucherTypeId"></param>
 /// <returns></returns>
 public VoucherTypeInfo VoucherTypeView(decimal voucherTypeId)
 {
     VoucherTypeInfo vouchertypeinfo = new VoucherTypeInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("VoucherTypeView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = voucherTypeId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             vouchertypeinfo.VoucherTypeId = Convert.ToDecimal(sdrreader[0].ToString());
             vouchertypeinfo.VoucherTypeName = sdrreader[1].ToString();
             vouchertypeinfo.TypeOfVoucher = sdrreader[2].ToString();
             vouchertypeinfo.MethodOfVoucherNumbering = sdrreader[3].ToString();
             vouchertypeinfo.IsTaxApplicable = Convert.ToBoolean(sdrreader[4].ToString());
             vouchertypeinfo.Narration = sdrreader[5].ToString();
             vouchertypeinfo.ExtraDate = Convert.ToDateTime(sdrreader[6].ToString());
             vouchertypeinfo.Extra1 = sdrreader[7].ToString();
             vouchertypeinfo.Extra2 = sdrreader[8].ToString();
             vouchertypeinfo.IsActive = Convert.ToBoolean(sdrreader[9].ToString());
             vouchertypeinfo.MasterId = Convert.ToInt32(sdrreader[10].ToString());
             vouchertypeinfo.Declarartion = sdrreader[11].ToString();
             vouchertypeinfo.Heading1 = sdrreader[12].ToString();
             vouchertypeinfo.Heading2 = sdrreader[13].ToString();
             vouchertypeinfo.Heading3 = sdrreader[14].ToString();
             vouchertypeinfo.Heading4 = sdrreader[15].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return vouchertypeinfo;
 }
 /// <summary>
 /// Function to view all VoucherTypes based on parameter
 /// </summary>
 /// <param name="voucherTypeId"></param>
 /// <returns></returns>
 public VoucherTypeInfo VoucherTypeView(decimal voucherTypeId)
 {
     VoucherTypeInfo vouchertypeinfo = new VoucherTypeInfo();
        try
        {
        vouchertypeinfo = spVoucherType.VoucherTypeView(voucherTypeId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("VT7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return vouchertypeinfo;
 }
 /// <summary>
 /// Function for update VoucherType For Default Vouchers
 /// </summary>
 /// <param name="vouchertypeinfo"></param>
 public void VoucherTypeEditForDefaultVouchers(VoucherTypeInfo vouchertypeinfo)
 {
     try
     {
         spVoucherType.VoucherTypeEditForDefaultVouchers(vouchertypeinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("VT18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to insert values to table and return id 
 /// </summary>
 /// <param name="vouchertypeinfo"></param>
 /// <returns></returns>
 public decimal VoucherTypeAddWithIdentity(VoucherTypeInfo vouchertypeinfo)
 {
     decimal decVoucherTypeId = 0;
        try
        {
        decVoucherTypeId = spVoucherType.VoucherTypeAddWithIdentity(vouchertypeinfo);
        }
        catch (Exception ex)
        {
        MessageBox.Show("VT14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return decVoucherTypeId;
 }
 /// <summary>
 /// Function to view type of voucher based on parameter
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <returns></returns>
 public VoucherTypeInfo TypeOfVoucherBasedOnVoucherTypeId(decimal decVoucherTypeId)
 {
     VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
        try
        {
        infoVoucherType = spVoucherType.TypeOfVoucherBasedOnVoucherTypeId(decVoucherTypeId);
        }
        catch (Exception ex)
        {
        MessageBox.Show("VT5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        return infoVoucherType;
 }