Beispiel #1
0
        public bool SuffixPrefixSettingsEdit(SuffixPrefixInfo Infosuffixprefix)
        {
            bool isEdit = false;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sqlcmd = new SqlCommand("SuffixPrefixSettingsEdit", base.sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add("@suffixprefixId", SqlDbType.Decimal).Value       = Infosuffixprefix.SuffixprefixId;
                sqlcmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal).Value        = Infosuffixprefix.VoucherTypeId;
                sqlcmd.Parameters.Add("@fromDate", SqlDbType.DateTime).Value            = Infosuffixprefix.FromDate;
                sqlcmd.Parameters.Add("@toDate", SqlDbType.DateTime).Value              = Infosuffixprefix.ToDate;
                sqlcmd.Parameters.Add("@startIndex", SqlDbType.VarChar).Value           = Infosuffixprefix.StartIndex;
                sqlcmd.Parameters.Add("@prefix", SqlDbType.VarChar).Value               = Infosuffixprefix.Prefix;
                sqlcmd.Parameters.Add("@suffix", SqlDbType.VarChar).Value               = Infosuffixprefix.Suffix;
                sqlcmd.Parameters.Add("@widthOfNumericalPart", SqlDbType.Decimal).Value = Infosuffixprefix.WidthOfNumericalPart;
                sqlcmd.Parameters.Add("@prefillWithZero", SqlDbType.Bit).Value          = Infosuffixprefix.PrefillWithZero;
                sqlcmd.Parameters.Add("@narration", SqlDbType.VarChar).Value            = Infosuffixprefix.Narration;
                int ineffectedrow = sqlcmd.ExecuteNonQuery();
                isEdit = (ineffectedrow > 0 && true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                base.sqlcon.Close();
            }
            return(isEdit);
        }
Beispiel #2
0
        public void VoucherNoGeneration(DateTime salaryMonth)
        {
            TransactionsGeneralFill obj = new TransactionsGeneralFill();
            AdvancePaymentSP        spAdvancePayment = new AdvancePaymentSP();

            if (strVoucherNo == string.Empty)
            {
                strVoucherNo = "0";
            }
            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), salaryMonth, strAdvancePayment);
            if (Convert.ToDecimal(strVoucherNo) != spAdvancePayment.AdvancePaymentGetMaxPlusOne(decPaymentVoucherTypeId))
            {
                strVoucherNo = spAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId).ToString();
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), salaryMonth, strAdvancePayment);
                if (spAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId) == "0")
                {
                    strVoucherNo = "0";
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), salaryMonth, strAdvancePayment);
                }
            }
            if (isAutomatic)
            {
                SuffixPrefixSP   spSuffixPrefix   = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = spSuffixPrefix.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate);
                string strPrefix = infoSuffixPrefix.Prefix;
                string strSuffix = infoSuffixPrefix.Suffix;
                strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Edit function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         SuffixPrefixSP   spSuffixPrefix   = new SuffixPrefixSP();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix.FromDate = Convert.ToDateTime(txtFromDate.Text.ToString());
         infoSuffixPrefix.ToDate   = Convert.ToDateTime(txtToDate.Text.ToString());
         String strvouchertype = (cmbVoucherType.SelectedValue.ToString());
         infoSuffixPrefix.VoucherTypeId = Convert.ToDecimal(strvouchertype.ToString());
         infoSuffixPrefix.Prefix        = txtPrefix.Text.Trim();
         infoSuffixPrefix.Suffix        = txtSufix.Text.Trim();
         infoSuffixPrefix.StartIndex    = Convert.ToDecimal(txtStartIndex.Text.ToString());
         if (cbxPrefillWithZero.Checked)
         {
             infoSuffixPrefix.PrefillWithZero      = true;
             infoSuffixPrefix.WidthOfNumericalPart = Convert.ToInt32(txtWidthofNumericalPart.Text.ToString());
         }
         else
         {
             infoSuffixPrefix.PrefillWithZero      = false;
             infoSuffixPrefix.WidthOfNumericalPart = 0;
         }
         infoSuffixPrefix.Narration      = txtNarration.Text.Trim();
         infoSuffixPrefix.Extra1         = string.Empty;
         infoSuffixPrefix.Extra2         = string.Empty;
         infoSuffixPrefix.SuffixprefixId = decSuffixPrefixId;
         if (spSuffixPrefix.SuffixPrefixCheckExistenceForAdd(txtFromDate.Text.ToString(), txtToDate.Text.ToString(), Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()), decSuffixPrefixId) == false)
         {
             if (spSuffixPrefix.SuffixPrefixSettingsEdit(infoSuffixPrefix))
             {
                 Messages.UpdatedMessage();
                 Clear();
             }
             else
             {
                 Messages.ReferenceExistsMessageForUpdate();
                 cmbVoucherType.Focus();
             }
         }
         else
         {
             Messages.InformationMessage("Voucher type already exist for  dates");
             cmbVoucherType.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public SuffixPrefixInfo GetSuffixPrefixDetails(decimal vouchertypeId, DateTime date)
        {
            SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

            try
            {
                infoSuffixPrefix = spSuffixPrefix.GetSuffixPrefixDetails(vouchertypeId, date);
            }
            catch (Exception ex)
            {
                MessageBox.Show("BD4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(infoSuffixPrefix);
        }
        public SuffixPrefixInfo SuffixPrefixView(decimal suffixprefixId)
        {
            SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

            try
            {
                infoSuffixPrefix = spSuffixPrefix.SuffixPrefixView(suffixprefixId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("BD4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(infoSuffixPrefix);
        }
        public bool SuffixPrefixSettingsEdit(SuffixPrefixInfo Infosuffixprefix)
        {
            bool isEdit = false;

            try
            {
                isEdit = spSuffixPrefix.SuffixPrefixSettingsEdit(Infosuffixprefix);
            }
            catch (Exception ex)
            {
                MessageBox.Show("BD2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(isEdit);
        }
Beispiel #7
0
 public void SuffixPrefixEdit(SuffixPrefixInfo suffixprefixinfo)
 {
     try
     {
         if (base.sqlcon.State == ConnectionState.Closed)
         {
             base.sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SuffixPrefixEdit", base.sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam14 = new SqlParameter();
         sprmparam14       = sccmd.Parameters.Add("@suffixprefixId", SqlDbType.Decimal);
         sprmparam14.Value = suffixprefixinfo.SuffixprefixId;
         sprmparam14       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam14.Value = suffixprefixinfo.VoucherTypeId;
         sprmparam14       = sccmd.Parameters.Add("@fromDate", SqlDbType.DateTime);
         sprmparam14.Value = suffixprefixinfo.FromDate;
         sprmparam14       = sccmd.Parameters.Add("@toDate", SqlDbType.DateTime);
         sprmparam14.Value = suffixprefixinfo.ToDate;
         sprmparam14       = sccmd.Parameters.Add("@startIndex", SqlDbType.Decimal);
         sprmparam14.Value = suffixprefixinfo.StartIndex;
         sprmparam14       = sccmd.Parameters.Add("@prefix", SqlDbType.VarChar);
         sprmparam14.Value = suffixprefixinfo.Prefix;
         sprmparam14       = sccmd.Parameters.Add("@suffix", SqlDbType.VarChar);
         sprmparam14.Value = suffixprefixinfo.Suffix;
         sprmparam14       = sccmd.Parameters.Add("@widthOfNumericalPart", SqlDbType.Int);
         sprmparam14.Value = suffixprefixinfo.WidthOfNumericalPart;
         sprmparam14       = sccmd.Parameters.Add("@prefillWithZero", SqlDbType.Bit);
         sprmparam14.Value = suffixprefixinfo.PrefillWithZero;
         sprmparam14       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam14.Value = suffixprefixinfo.Narration;
         sprmparam14       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam14.Value = suffixprefixinfo.ExtraDate;
         sprmparam14       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam14.Value = suffixprefixinfo.Extra1;
         sprmparam14       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam14.Value = suffixprefixinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         base.sqlcon.Close();
     }
 }
Beispiel #8
0
 /// <summary>
 /// grid double click fill the items in controll for edit
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvSuffixPrefixSettings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             SuffixPrefixSP   spSuffixPrefix   = new SuffixPrefixSP();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix             = spSuffixPrefix.SuffixPrefixView(Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString()));
             decSuffixPrefixId            = Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString());
             txtFromDate.Text             = infoSuffixPrefix.FromDate.ToString("dd-MMM-yyyy");
             txtToDate.Text               = infoSuffixPrefix.ToDate.ToString("dd-MMM-yyyy");
             cmbVoucherType.SelectedValue = infoSuffixPrefix.VoucherTypeId.ToString();
             txtStartIndex.Text           = infoSuffixPrefix.StartIndex.ToString();
             txtStartIndex.Enabled        = false;
             txtSufix.Text  = infoSuffixPrefix.Suffix;
             txtPrefix.Text = infoSuffixPrefix.Prefix;
             if (infoSuffixPrefix.PrefillWithZero == true)
             {
                 cbxPrefillWithZero.Checked   = true;
                 txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
             }
             else
             {
                 cbxPrefillWithZero.Checked   = false;
                 txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
             }
             txtNarration.Text = infoSuffixPrefix.Narration;
             btnSave.Text      = "Update";
             btnDelete.Enabled = true;
             txtFromDate.Focus();
             txtWidthofNumericalPart.Enabled = true;
             if (cbxPrefillWithZero.Checked == true)
             {
                 txtWidthofNumericalPart.Enabled = true;
             }
             else
             {
                 txtWidthofNumericalPart.Enabled = false;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #9
0
        public SuffixPrefixInfo GetSuffixPrefixDetails(decimal vouchertypeId, DateTime date)
        {
            SuffixPrefixInfo suffixprefixinfo = new SuffixPrefixInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("GetSuffixPrefixDetails", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam3 = new SqlParameter();
                sprmparam3       = sccmd.Parameters.Add("@voucherId", SqlDbType.Decimal);
                sprmparam3.Value = vouchertypeId;
                sprmparam3       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam3.Value = date;
                sdrreader        = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    suffixprefixinfo.SuffixprefixId       = decimal.Parse(((DbDataReader)sdrreader)[0].ToString());
                    suffixprefixinfo.VoucherTypeId        = decimal.Parse(((DbDataReader)sdrreader)[1].ToString());
                    suffixprefixinfo.FromDate             = DateTime.Parse(((DbDataReader)sdrreader)[2].ToString());
                    suffixprefixinfo.ToDate               = DateTime.Parse(((DbDataReader)sdrreader)[3].ToString());
                    suffixprefixinfo.StartIndex           = decimal.Parse(((DbDataReader)sdrreader)[4].ToString());
                    suffixprefixinfo.Prefix               = ((DbDataReader)sdrreader)[5].ToString();
                    suffixprefixinfo.Suffix               = ((DbDataReader)sdrreader)[6].ToString();
                    suffixprefixinfo.WidthOfNumericalPart = int.Parse(((DbDataReader)sdrreader)[7].ToString());
                    suffixprefixinfo.PrefillWithZero      = bool.Parse(((DbDataReader)sdrreader)[8].ToString());
                    suffixprefixinfo.Narration            = ((DbDataReader)sdrreader)[9].ToString();
                    suffixprefixinfo.ExtraDate            = DateTime.Parse(((DbDataReader)sdrreader)[10].ToString());
                    suffixprefixinfo.Extra1               = ((DbDataReader)sdrreader)[11].ToString();
                    suffixprefixinfo.Extra2               = ((DbDataReader)sdrreader)[12].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                base.sqlcon.Close();
            }
            return(suffixprefixinfo);
        }
        public string voucherNumberGeneration(decimal decMonthlyVoucherTypeId, string strVoucherNo, string dptVoucherDate)
        {
            try
            {
                //TransactionsGeneralFill obj = new TransactionsGeneralFill();
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                if (strVoucherNo == string.Empty || strVoucherNo == null)
                {
                    strVoucherNo = "0";
                }
                string tableName = "SalaryVoucherMaster";
                //-----------------------------------------Voucher number Automatic generation ------------------------------------------------//
                //strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != spMaster.SalaryVoucherMasterGetMaxPlusOne(decMonthlyVoucherTypeId))
                {
                    strVoucherNo = spMaster.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId).ToString();
                    //strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (spMaster.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        // strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dptVoucherDate.Value, tableName);
                    }
                }
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                //var isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                //if (isAutomatic)
                {
                    SuffixPrefixSP   spSuffisprefix   = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decMonthlyVoucherTypeId, Convert.ToDateTime(dptVoucherDate));
                    var strPrefix    = infoSuffixPrefix.Prefix;
                    var strSuffix    = infoSuffixPrefix.Suffix;
                    var strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    return(strInvoiceNo);
                    //txtVoucherNo.ReadOnly = true;
                }
                //return string.Empty;
            }
            catch (Exception ex)
            {
                //MessageBox.Show("MSV14:" + ex.Message, "Masterfine", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(string.Empty);
        }
        /// <summary>
        /// Function to get particular values from SuffixPrefix Table based on the parameter
        /// </summary>
        /// <param name="suffixprefixId"></param>
        /// <returns></returns>
        public SuffixPrefixInfo SuffixPrefixView(decimal suffixprefixId)
        {
            SuffixPrefixInfo suffixprefixinfo = new SuffixPrefixInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("SuffixPrefixView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@suffixprefixId", SqlDbType.Decimal);
                sprmparam.Value = suffixprefixId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    suffixprefixinfo.SuffixprefixId       = decimal.Parse(sdrreader[0].ToString());
                    suffixprefixinfo.VoucherTypeId        = decimal.Parse(sdrreader[1].ToString());
                    suffixprefixinfo.FromDate             = DateTime.Parse(sdrreader[2].ToString());
                    suffixprefixinfo.ToDate               = DateTime.Parse(sdrreader[3].ToString());
                    suffixprefixinfo.StartIndex           = decimal.Parse(sdrreader[4].ToString());
                    suffixprefixinfo.Prefix               = sdrreader[5].ToString();
                    suffixprefixinfo.Suffix               = sdrreader[6].ToString();
                    suffixprefixinfo.WidthOfNumericalPart = int.Parse(sdrreader[7].ToString());
                    suffixprefixinfo.PrefillWithZero      = bool.Parse(sdrreader[8].ToString());
                    suffixprefixinfo.Narration            = sdrreader[9].ToString();
                    suffixprefixinfo.ExtraDate            = DateTime.Parse(sdrreader[10].ToString());
                    suffixprefixinfo.Extra1               = sdrreader[11].ToString();
                    suffixprefixinfo.Extra2               = sdrreader[12].ToString();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(suffixprefixinfo);
        }
Beispiel #12
0
        public void CallFromVoucherTypeSelection()
        {
            VoucherTypeSP spVoucherType   = new VoucherTypeSP();
            DataTable     dtblVouchetType = new DataTable();

            dtblVouchetType = spVoucherType.VoucherTypeSelectionComboFill(strVoucherType);
            decimal decVoucherTypeId = (decimal)dtblVouchetType.Rows[0][0];

            decPaymentVoucherTypeId = decVoucherTypeId;
            strPaymentVoucherTypeId = decVoucherTypeId.ToString();

            isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(Convert.ToDecimal(decVoucherTypeId.ToString()));
            SuffixPrefixSP   spSuffisprefix   = new SuffixPrefixSP();
            SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

            infoSuffixPrefix         = spSuffisprefix.GetSuffixPrefixDetails(Convert.ToDecimal(strPaymentVoucherTypeId), dtpDate);
            decPaymentSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
        }
 /// <summary>
 /// save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix.FromDate = Convert.ToDateTime(txtFromDate.Text.ToString());
         infoSuffixPrefix.ToDate = Convert.ToDateTime(txtToDate.Text.ToString());
         String strvouchertype = (cmbVoucherType.SelectedValue.ToString());
         infoSuffixPrefix.VoucherTypeId = Convert.ToDecimal(strvouchertype.ToString());
         infoSuffixPrefix.Suffix = txtSufix.Text.Trim();
         infoSuffixPrefix.Prefix = txtPrefix.Text.Trim();
         infoSuffixPrefix.StartIndex = Convert.ToDecimal(txtStartIndex.Text.ToString());
         if (cbxPrefillWithZero.Checked)
         {
             infoSuffixPrefix.PrefillWithZero = true;
             infoSuffixPrefix.WidthOfNumericalPart = Convert.ToInt32(txtWidthofNumericalPart.Text.ToString());
         }
         else
         {
             infoSuffixPrefix.PrefillWithZero = false;
             infoSuffixPrefix.WidthOfNumericalPart = 0;
         }
         infoSuffixPrefix.Narration = txtNarration.Text.Trim();
         infoSuffixPrefix.Extra1 = string.Empty;
         infoSuffixPrefix.Extra2 = string.Empty;
         if (BllSuffixPrefixSettings.SuffixPrefixCheckExistenceForAdd(txtFromDate.Text.ToString(), txtToDate.Text.ToString(), Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()), 0) == false)
         {
             if (BllSuffixPrefixSettings.SuffixPrefixAddWithId(infoSuffixPrefix))
             {
                 Messages.SavedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Voucher type already exist for  dates");
             cmbVoucherType.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPS4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Voucher no generation function based on the settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll();
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
         if (Convert.ToDecimal(strVoucherNo) != BllPdcRecieveble.PDCReceivableMaxUnderVoucherTypePlusOne(decPDCReceivableVoucherTypeId))
         {
             strVoucherNo = BllPdcRecieveble.PDCReceivableMaxUnderVoucherType(decPDCReceivableVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
             if (BllPdcRecieveble.PDCReceivableMaxUnderVoucherType(decPDCReceivableVoucherTypeId).ToString() == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPDCReceivableVoucherTypeId, dtpVoucherDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decSufixprefixPdcReceivableID = infoSuffixPrefix.SuffixprefixId;
             strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
             txtVoucherNo.Text = strInvoiceNo;
             txtVoucherNo.ReadOnly = true;
             txtVoucherNo.Enabled = false;
             lblVoucherNoManualValidator.Visible = false;
         }
         else
         {
             txtVoucherNo.ReadOnly = false;
             txtVoucherNo.Text = string.Empty;
             lblVoucherNoManualValidator.Visible = true;
             strInvoiceNo = txtVoucherNo.Text.Trim();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// These function for generating the voucher no automatically if its automatic with preffix and sufix
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                //ContraMasterSP spContraMaster = new ContraMasterSP();
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0";
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != bllContraVoucherDetails.ContraVoucherMasterGetMaxPlusOne(DecContraVoucherTypeId))
                {
                    strVoucherNo = bllContraVoucherDetails.ContraVoucherMasterGetMax(DecContraVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                    if (bllContraVoucherDetails.ContraVoucherMasterGetMax(DecContraVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecContraVoucherTypeId, dtpContraVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decContraSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:08" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to generate voucherNo
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != bllMaterialReceiptMaster.MaterialReceiptMasterGetMaxPlusOne(decMaterialReceiptVoucherTypeId))
         {
             strVoucherNo = bllMaterialReceiptMaster.MaterialReceiptMasterGetMax(decMaterialReceiptVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (bllMaterialReceiptMaster.MaterialReceiptMasterGetMax(decMaterialReceiptVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decMaterialReceiptVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decMaterialReceiptSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             strReceiptNo = strPrefix + strVoucherNo + strSuffix;
             txtReceiptNo.Text = strReceiptNo;
             txtReceiptNo.ReadOnly = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Voucher no generation function based on settings
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                //PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP();
                PhysicalStockBll BllPhysicalStock = new PhysicalStockBll();
                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0";
                }
                strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPhysicalStockVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                if (Convert.ToDecimal(strVoucherNo) != (BllPhysicalStock.PhysicalStockMasterVoucherMax(decPhysicalStockVoucherTypeId)))
                {
                    strVoucherNo = BllPhysicalStock.PhysicalStockMasterVoucherMax(decPhysicalStockVoucherTypeId).ToString();
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPhysicalStockVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    if (BllPhysicalStock.PhysicalStockMasterVoucherMax(decPhysicalStockVoucherTypeId) == 0)
                    {
                        strVoucherNo = "0";
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPhysicalStockVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPhysicalStockVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decPhysicalStockSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    txtVoucherNo.Text = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.ReadOnly = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PS:18" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to reset the form to create new sales quatation
        /// </summary>
        public void Clear()
        {
            TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll();
            SalesQuotationBll bllSalesQuotation = new SalesQuotationBll();
            try
            {
                if (isAutomatic)
                {
                    strSalesQuotationNo = bllSalesQuotation.SalesQuotationMasterGetMax(decsalesQuotationTypeId).ToString();
                    if (strSalesQuotationNo == string.Empty)
                    {
                        strSalesQuotationNo = " 0";
                    }
                    strSalesQuotationNo = transactionGeneralFillObj.VoucherNumberAutomaicGeneration(decsalesQuotationTypeId, Convert.ToDecimal(strSalesQuotationNo), dtpSalesQuotationDate.Value, tableName);
                    if (Convert.ToDecimal(strSalesQuotationNo) != bllSalesQuotation.SalesQuotationMaxGetPlusOne(decsalesQuotationTypeId))
                    {
                        strSalesQuotationNo = Convert.ToString(bllSalesQuotation.SalesQuotationMaxGetPlusOne(decsalesQuotationTypeId));
                        strSalesQuotationNo = transactionGeneralFillObj.VoucherNumberAutomaicGeneration(decsalesQuotationTypeId, Convert.ToDecimal(strSalesQuotationNo), dtpSalesQuotationDate.Value, tableName);
                        if (bllSalesQuotation.SalesQuotationMasterGetMax(decsalesQuotationTypeId) == 0)
                        {
                            strSalesQuotationNo = "0";
                            strSalesQuotationNo = transactionGeneralFillObj.VoucherNumberAutomaicGeneration(decsalesQuotationTypeId, Convert.ToDecimal(strSalesQuotationNo), dtpSalesQuotationDate.Value, tableName);
                        }
                    }
                    if (isAutomatic)
                    {
                        SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                        SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                        infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decsalesQuotationTypeId, dtpSalesQuotationDate.Value);
                        strPrefix = infoSuffixPrefix.Prefix;
                        strSuffix = infoSuffixPrefix.Suffix;
                        decSalesQuotationPreffixSuffixId = infoSuffixPrefix.SuffixprefixId;
                        strInvoiceNo = strPrefix + strSalesQuotationNo + strSuffix;
                        txtQuotationNo.Text = strInvoiceNo;
                        txtQuotationNo.ReadOnly = true;
                    }
                }
                else
                {
                    txtQuotationNo.Text = string.Empty;
                }
                salesQuotationDatefill();
                if (!ShowProductCode())
                {
                    this.dgvProduct.Columns["dgvtxtProductCode"].Visible = false;
                }
                if (!ShowBarcode())
                {
                    this.dgvProduct.Columns["dgvtxtBarcode"].Visible = false;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                dgvProduct.Rows.Clear();
                txtNarration.Text = string.Empty;
                txtTotal.Text = string.Empty;
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                cbxApproved.Checked = false;
                ComboCurrencyFill();
                ComboPricingLevelFill();
                ComboSalesManFill();
                CashOrPartyCombofill();
                FillProducts(false, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:31" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                decsalesQuotationTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decsalesQuotationTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo InfoSuffixPrefix = new SuffixPrefixInfo();
                InfoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decsalesQuotationTypeId, dtpSalesQuotationDate.Value);
                decSalesQuotationPreffixSuffixId = InfoSuffixPrefix.SuffixprefixId;
                this.Text = strVoucherTypeName;
                base.Show();
                if (isAutomatic)
                {
                    txtSalesQuotationDate.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// To reset the form here and Generate the voucher no generation
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                if (btnSave.Text == "Update")
                {
                    if (frmPaymentRegisterObj != null)
                    {
                        frmPaymentRegisterObj.Close();
                    }
                }
                if (isAutomatic)
                {

                    SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();
                    //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                    PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    if (Convert.ToDecimal(strVoucherNo) != BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId) + 1)
                    {
                        strVoucherNo = BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId).ToString();
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        if (BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.Text = string.Empty;
                    txtVoucherNo.ReadOnly = false;
                }
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.Value = PublicVariables._dtCurrentDate;
                cmbBankorCash.SelectedIndex = -1;
                txtNarration.Text = string.Empty;
                txtTotal.Text = string.Empty;
                dgvPaymentVoucher.ClearSelection();
                dgvPaymentVoucher.Rows.Clear();
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                cbxPrintafterSave.Checked = false;
                dtblPartyBalance.Clear();
                if (isAutomatic)
                {
                    txtDate.Select();
                }
                else
                {
                    txtVoucherNo.Select();
                }
                PrintCheck();

            }
            catch (Exception ex)
            {
                MessageBox.Show("PV9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to clear the fields
        /// </summary>
        public void clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                JournalVoucherBll bllJournalVoucher = new JournalVoucherBll();

                //-----------------------------------VoucherNo automatic generation-------------------------------------------//

                if (strVoucherNo == string.Empty)
                {

                    strVoucherNo = "0"; //strMax;
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decJournalVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);

                if (Convert.ToDecimal(strVoucherNo) != bllJournalVoucher.JournalMasterGetMaxPlusOne(decJournalVoucherTypeId))
                {
                    strVoucherNo = bllJournalVoucher.JournalMasterGetMax(decJournalVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decJournalVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (bllJournalVoucher.JournalMasterGetMax(decJournalVoucherTypeId).ToString() == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decJournalVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    }
                }

                //===================================================================================================================//
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decJournalVoucherTypeId, dtpVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                    txtVoucherNo.Text = string.Empty;
                    strInvoiceNo = txtVoucherNo.Text.Trim();
                }

                dgvJournalVoucher.Rows.Clear();
                VoucherDate();
                dtpVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                txtDebitTotal.Text = string.Empty;
                txtCreditTotal.Text = string.Empty;
                txtNarration.Text = string.Empty;
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                isEditMode = false;
                dtblPartyBalance.Clear();//to clear party balance entries to clear the dgvpatybalance
                PrintCheck();
                if (!txtVoucherNo.ReadOnly)
                {
                    txtVoucherNo.Focus();
                }
                else
                {
                    txtDate.Select();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("JV2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// It is a function for vouchertypeselection form to select perticular voucher and open the form under the vouchertype
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                decJournalVoucherTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decJournalVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                //SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decJournalVoucherTypeId, dtpVoucherDate.Value);
                decJournalSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strVoucherTypeName;
                base.Show();
                clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Voucher Number Generation
        /// </summary>
        public void VoucherNumberGeneration()
        {
            string strPrefix = string.Empty;
            string strSuffix = string.Empty;
            string tableName = "PurchaseReturnMaster";
            string strReturnNo = string.Empty;
            TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll();
            PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll();
            try
            {
                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0";
                }
                strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != BllPurchaseReturn.PurchaseReturnMasterGetMaxPlusOne(decPurchaseReturnVoucherTypeId))
                {
                    strVoucherNo = BllPurchaseReturn.PurchaseReturnMasterGetMax(decPurchaseReturnVoucherTypeId).ToString();
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    if (BllPurchaseReturn.PurchaseReturnMasterGetMax(decPurchaseReturnVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    }
                }
                if (isAutomatic)
                {

                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPurchaseReturnVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decPurchaseReturnSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strReturnNo = strPrefix + strVoucherNo + strSuffix;
                    txtReturnNo.Text = strReturnNo;
                    txtReturnNo.ReadOnly = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decDailySalaryVoucherTypeId"></param>
        /// <param name="strVoucherTypeNames1"></param>
        public void CallFromVoucherTypeSelection(decimal decDailySalaryVoucherTypeId, string strVoucherTypeNames1)
        {
            try
            {
                decDailyVoucherTypeId = decDailySalaryVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
               // SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decDailyVoucherTypeId, dtpDate.Value);
                decDailySuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;

                this.Text = strVoucherTypeNames1;
                base.Show();
                if (isAutomatic)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtVoucherNo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to generate the voucher number as per settings
        /// </summary>
        public void voucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();
                //-----------------------------------------Voucher number Automatic generation ------------------------------------------------//
                if (strVoucherNo == string.Empty)
                {

                   strVoucherNo = "0";
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != BllSalaryVoucher.SalaryVoucherMasterGetMaxPlusOne(decMonthlyVoucherTypeId))
                {
                    strVoucherNo = BllSalaryVoucher.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (BllSalaryVoucher.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decMonthlyVoucherTypeId, dtpVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="DecPhysicalStockVoucherType"></param>
        /// <param name="strPhysicalStockVouchertypeName"></param>
        public void CallFromVoucherTypeSelection(decimal DecPhysicalStockVoucherType, string strPhysicalStockVouchertypeName)
        {
            try
            {
                decPhysicalStockVoucherTypeId = DecPhysicalStockVoucherType;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPhysicalStockVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPhysicalStockVoucherTypeId, dtpDate.Value);
                decDailySuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strPhysicalStockVouchertypeName;
                base.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PS:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Cleare function and Generate the voucher no based on settings
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                //SalesMasterSP spSalesMaster = new SalesMasterSP();
                SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
                if (isAutomatic)
                {
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                    if (Convert.ToDecimal(strVoucherNo) != (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId)))
                    {
                        strVoucherNo = BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId).ToString();
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        if (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                   // SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecSalesInvoiceVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtInvoiceNo.Text = strInvoiceNo;
                    txtInvoiceNo.ReadOnly = true;
                    decSalseInvoiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                }
                else
                {
                    txtInvoiceNo.ReadOnly = false;
                    txtInvoiceNo.Text = string.Empty;
                    strVoucherNo = string.Empty;
                    strInvoiceNo = strVoucherNo;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                cmbPricingLevel.SelectedIndex = 0;
                cmbSalesAccount.SelectedIndex = 0;
                cmbCashOrParty.SelectedIndex = 0;
                cmbSalesMan.SelectedIndex = 0;
                cmbSalesMode.SelectedIndex = 0;
                cmbDrorCr.SelectedIndex = 0;
                cmbCashOrbank.SelectedIndex = 0;
                cmbCurrency.Enabled = true;
                txtCustomer.Text = cmbCashOrParty.Text;
                txtTransportCompany.Text = string.Empty;
                txtVehicleNo.Text = string.Empty;
                txtNarration.Text = string.Empty;
                txtCreditPeriod.Text = "0";
                txtTotalAmount.Text = "0.00";
                txtBillDiscount.Text = "0";
                txtGrandTotal.Text = "0.00";
                lblTaxTotalAmount.Text = "0.00";
                lblLedgerTotalAmount.Text = "0.00";
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.Value = PublicVariables._dtCurrentDate;
                txtDate.Text = dtpDate.Value.ToString("dd-MMM-yyyy");
                dgvSalesInvoiceLedger.Rows.Clear();
                isFromEditMode = false;
                if (dgvSalesInvoice.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoice.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoice.Rows.Clear();
                }
                gridCombofill();
                if (dgvSalesInvoiceTax.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoiceTax.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoiceTax.Rows.Clear();
                }
                taxGridFill();
                if (!txtInvoiceNo.ReadOnly)
                {
                    txtInvoiceNo.Focus();
                }
                else
                {
                    txtDate.Select();
                }

                txtTotalAmount.Text = "0.00";
                txtGrandTotal.Text = "0.00";
                lblTotalQuantitydisplay.Text = "0";
            }
            catch (Exception ex)
            {
                MessageBox.Show("SI : 01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to generate Voucher number as per settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecPOSVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
         if (Convert.ToDecimal(strVoucherNo) != (BllSalesInvoice.SalesMasterVoucherMax(DecPOSVoucherTypeId)))
         {
             strVoucherNo = BllSalesInvoice.SalesMasterVoucherMax(DecPOSVoucherTypeId).ToString();
             strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecPOSVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
             if (BllSalesInvoice.SalesMasterVoucherMax(DecPOSVoucherTypeId) == 0)
             {
                 strVoucherNo = "0";
                 strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecPOSVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecPOSVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decPOSSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             txtVoucherNo.Text = strPrefix + strVoucherNo + strSuffix;
             txtVoucherNo.ReadOnly = true;
         }
         else
         {
             txtVoucherNo.ReadOnly = false;
             txtVoucherNo.Text = string.Empty;
             strVoucherNo = string.Empty;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POS : 05" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to generate Voucher number as per settings
        /// </summary>
        public void VoucherNoGeneration()
        {
            TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
            AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
            if (strVoucherNo == string.Empty)
            {
                strVoucherNo = "0";
            }
            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
            if (Convert.ToDecimal(strVoucherNo) != bllAdvancePayment.AdvancePaymentGetMaxPlusOne(decPaymentVoucherTypeId))
            {
                strVoucherNo = bllAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId).ToString();
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
                if (bllAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId) == "0")
                {
                    strVoucherNo = "0";
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
                }
            }
            if (isAutomatic)
            {
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate.Value);
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                txtAdvanceVoucherNo.Text = strInvoiceNo;
                txtAdvanceVoucherNo.Enabled = false;
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="strVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal strVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                strPaymentVoucherTypeId = strVoucherTypeId.ToString();
                decPaymentVoucherTypeId = strVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(Convert.ToDecimal(strVoucherTypeId.ToString()));
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(Convert.ToDecimal(strPaymentVoucherTypeId), dtpDate.Value);
                decPaymentSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                this.Text = strVoucherTypeName;
                base.Show();
                if (isAutomatic)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtAdvanceVoucherNo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// its a function for vouchertype selection form to select purticular voucher and open the form under the vouchertype
        /// </summary>
        /// <param name="decDailyContraVoucherTypeId"></param>
        /// <param name="strVoucherTypeNames1"></param>
        public void CallFromVoucherTypeSelection(decimal decDailyContraVoucherTypeId, string strVoucherTypeNames1)
        {
            try
            {
                DecContraVoucherTypeId = decDailyContraVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecContraVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecContraVoucherTypeId, dtpContraVoucherDate.Value);
                decContraSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strVoucherTypeNames1;
                base.Show();
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:10" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to generate Voucher number as per settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
     TransactionsGeneralFillBll TransactionGenerateFillObj = new TransactionsGeneralFillBll();
     DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
     string tableName = "DeliveryNoteMaster";
     string strPrefix = string.Empty;
     string strSuffix = string.Empty;
     try
     {
         strVoucherNo = "0";
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != bllDeliveryNote.DeliveryNoteMasterGetMaxPlusOne(decDeliveryNoteVoucherTypeId))
         {
             strVoucherNo = bllDeliveryNote.DeliveryNoteMasterMax1(decDeliveryNoteVoucherTypeId).ToString();
             strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (bllDeliveryNote.DeliveryNoteMasterMax1(decDeliveryNoteVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             infoSuffixPrefix = new SuffixPrefixSettingsBll().GetSuffixPrefixDetails(decDeliveryNoteVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decDeliveryNoteSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             strDeliveryNoteNo = strPrefix + strVoucherNo + strSuffix;
             txtDeliveryNoteNo.Text = strDeliveryNoteNo;
             txtDeliveryNoteNo.ReadOnly = true;
         }
         else
         {
             txtDeliveryNoteNo.Text = string.Empty;
             strDeliveryNoteNo = txtDeliveryNoteNo.Text.Trim();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN09:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to call this form from VoucherType Selection form
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <param name="strVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
 {
     try
     {
         decPDCReceivableVoucherTypeId = decVoucherTypeId;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPDCReceivableVoucherTypeId);
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPDCReceivableVoucherTypeId, dtpVoucherDate.Value);
         decSufixprefixPdcReceivableID = infoSuffixPrefix.SuffixprefixId;
         this.Text = strVoucherTypeName;
         base.Show();
         if (isAutomatic)
         {
             txtVoucherDate.Focus();
         }
         else
         {
             txtVoucherNo.Focus();
         }
         ClearFunction();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 //  Invoked from frmVoucherTypeSelection form
 /// <summary>
 /// Function to call this form from VoucherType Selection form
 /// </summary>
 /// <param name="decServiceVoucherTypeId"></param>
 /// <param name="strServiceVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decServiceVoucherTypeId, string strServiceVoucherTypeName)
 {
     try
     {
         DecServicetVoucherTypeId = decServiceVoucherTypeId;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecServicetVoucherTypeId);    //  Checking voucher number is automatic or not
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecServicetVoucherTypeId, dtpVoucherDate.Value);
         decServiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
         strPrefix = infoSuffixPrefix.Prefix;
         strSuffix = infoSuffixPrefix.Suffix;
         this.Text = strServiceVoucherTypeName;
         base.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 13 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to call this form from VoucherType Selection form
 /// </summary>
 /// <param name="decVoucherTypeId1"></param>
 /// <param name="strReceiptVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decVoucherTypeId1, string strReceiptVoucherTypeName)
 {
     try
     {
         btnDelete.Enabled = true;
         decReceiptVoucherTypeId = decVoucherTypeId1;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decReceiptVoucherTypeId);
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decReceiptVoucherTypeId, dtpDate.Value);
         decDailySuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
         strPrefix = infoSuffixPrefix.Prefix;
         strSuffix = infoSuffixPrefix.Suffix;
         base.Show();
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("RV8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            string strSuffix = string.Empty;
            string strPrefix = string.Empty;
            try
            {
                decRejectionInVoucherTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decRejectionInVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                SuffixPrefixInfo InfoSuffixPrefix = new SuffixPrefixInfo();
                InfoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decRejectionInVoucherTypeId, dtpDate.Value);
                decRejectionInSuffixPrefixId = InfoSuffixPrefix.SuffixprefixId;
                strSuffix = InfoSuffixPrefix.Suffix;
                strPrefix = InfoSuffixPrefix.Prefix;
                this.Text = strVoucherTypeName;
                base.Show();

                if (isAutomatic)
                {
                    ClearRejectionIn();
                    VoucherNoGeneration();
                    txtDate.Focus();
                    txtRejectionInNo.ReadOnly = true;
                }
                else
                {
                    txtRejectionInNo.Focus();
                    txtRejectionInNo.ReadOnly = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("RI:30" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// grid double click fill the items in controll for edit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvSuffixPrefixSettings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex != -1)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.SuffixPrefixView(Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString()));
                    decSuffixPrefixId = Convert.ToDecimal(dgvSuffixPrefixSettings.Rows[e.RowIndex].Cells["dgvtxtSuffixPrefixId"].Value.ToString());
                    txtFromDate.Text = infoSuffixPrefix.FromDate.ToString("dd-MMM-yyyy");
                    txtToDate.Text = infoSuffixPrefix.ToDate.ToString("dd-MMM-yyyy");
                    cmbVoucherType.SelectedValue = infoSuffixPrefix.VoucherTypeId.ToString();
                    txtStartIndex.Text = infoSuffixPrefix.StartIndex.ToString();
                    txtStartIndex.Enabled = false;
                    txtSufix.Text = infoSuffixPrefix.Suffix;
                    txtPrefix.Text = infoSuffixPrefix.Prefix;
                    if (infoSuffixPrefix.PrefillWithZero == true)
                    {
                        cbxPrefillWithZero.Checked = true;
                        txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
                    }
                    else
                    {
                        cbxPrefillWithZero.Checked = false;
                        txtWidthofNumericalPart.Text = infoSuffixPrefix.WidthOfNumericalPart.ToString();
                    }
                    txtNarration.Text = infoSuffixPrefix.Narration;
                    btnSave.Text = "Update";
                    btnDelete.Enabled = true;
                    txtFromDate.Focus();
                    txtWidthofNumericalPart.Enabled = true;
                    if (cbxPrefillWithZero.Checked == true)
                    {
                        txtWidthofNumericalPart.Enabled = true;
                    }
                    else
                    {
                        txtWidthofNumericalPart.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SPS20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to clear the fields
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                StockJournalBll BllStockJournal = new StockJournalBll();
                if (isAutomatic)
                {
                    if (strVoucherNo == string.Empty)
                    {

                        strVoucherNo = "0";
                    }
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, TableName);

                    if (Convert.ToDecimal(strVoucherNo) != BllStockJournal.StockJournalMasterMaxPlusOne(decVoucherTypeId))
                    {
                        strVoucherNo = BllStockJournal.StockJournalMasterMax(decVoucherTypeId).ToString();
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, TableName);
                        if (BllStockJournal.StockJournalMasterMax(decVoucherTypeId).ToString() == "0")
                        {
                            strVoucherNo = "0";
                            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, TableName);
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                    txtVoucherNo.Text = string.Empty;
                    strInvoiceNo = txtVoucherNo.Text.Trim();
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;

                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                btnDelete.Enabled = false;
                btnSave.Text = "Save";
                gbxTransactionType.Enabled = true;
                cmbFinishedGoods.Enabled = true;
                txtQty.Enabled = true;
                btnAdd.Enabled = true;
                VoucherDate();
                dgvConsumption.Rows.Clear();
                dgvProduction.Rows.Clear();
                dgvAdditionalCost.Rows.Clear();
                cmbFinishedGoods.Text = string.Empty;
                txtQty.Text = String.Empty;
                txtNarration.Text = string.Empty;
                lblAdditionalCostAmount.Text = "0.00";
                lblConsumptionAmount.Text = "0.00";
                lblProductionAmount.Text = "0.00";

            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:29" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to call These form from vouchertype Selection form
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <param name="strVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
 {
     try
     {
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         decDeliveryNoteVoucherTypeId = decVoucherTypeId;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDeliveryNoteVoucherTypeId);
         infoSuffixPrefix = new SuffixPrefixSettingsBll().GetSuffixPrefixDetails(decDeliveryNoteVoucherTypeId, dtpDate.Value);
         decDeliveryNoteSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
         this.Text = strVoucherTypeName;
         base.Show();
         if (isAutomatic)
         {
             txtDate.Focus();
         }
         else
         {
             txtDeliveryNoteNo.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN07:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Clear function and voucherno generation based on settings
        /// </summary>
        public void Clear()
        {
            try
            {
                PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();

                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                SettingsBll BllSettings = new SettingsBll();
                if (isAutomatic)
                {
                    strVoucherNo = BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    if (strVoucherNo != BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString())
                    {
                        strVoucherNo = BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString();
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        if (BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId) == "0")
                        {
                            strVoucherNo = "0";
                            strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        }
                    }
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPurchaseOrderTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decPurchaseSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strOrderNo = strPrefix + strVoucherNo + strSuffix;
                    txtOrderNo.Text = strOrderNo;
                    txtOrderNo.ReadOnly = true;
                    txtDate.Focus();
                }
                else
                {
                    txtOrderNo.Text = string.Empty;
                    txtOrderNo.ReadOnly = false;
                    txtOrderNo.Focus();
                }
                dtpDate.Value = PublicVariables._dtCurrentDate;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDueDate.Value = PublicVariables._dtCurrentDate;
                this.txtDueDate.Text = this.dtpDueDate.Value.ToString("dd-MMM-yyyy");
                dtpDueDate.MinDate = PublicVariables._dtFromDate;
                dtpDueDate.MaxDate = PublicVariables._dtToDate;
                txtDueDays.Text = "0";
                CashOrPartyComboFill();
                if (!ShowProductCode())
                {
                    this.dgvPurchaseOrder.Columns["dgvtxtProductCode"].Visible = false;
                }
                if (!ShowBarcode())
                {
                    this.dgvPurchaseOrder.Columns["dgvtxtBarcode"].Visible = false;
                }
                if (BllSettings.SettingsStatusCheck("ShowUnit") == "Yes")
                {
                    dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = true;
                }
                else
                {
                    dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = false;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                txtNarration.Text = string.Empty;

                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                cbxCancel.Enabled = true;
                cbxCancel.Checked = false;
                dgvPurchaseOrder.Rows.Clear();
                txtTotalAmount.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PO28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to reset the form to make new service voucher
        /// </summary>
        public void Clear()
        {
            try
            {
                /*Automatic invoice number generation*/
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                VoucherDate();
                if (isAutomatic)    //  Checking voucher number generation is automatic or not
                {
                    ServicesBll BllService = new ServicesBll();
                    ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (Convert.ToDecimal(strVoucherNo) != (BllService.ServiceMasterGetMax(DecServicetVoucherTypeId)) + 1)
                    {
                        strVoucherNo = BllService.ServiceMasterGetMax(DecServicetVoucherTypeId).ToString();
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                        if (BllService.ServiceMasterGetMax(DecServicetVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecServicetVoucherTypeId, dtpVoucherDate.Value);   //  Getting suffix-prefix settings
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decServiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;    // Generating invoice number with suffix and prefix
                    txtInvoiceNumber.Text = strInvoiceNo;
                    txtInvoiceNumber.ReadOnly = true;
                    txtVoucherDate.Select();
                }
                else
                {
                    txtInvoiceNumber.Text = string.Empty;
                    txtInvoiceNumber.ReadOnly = false;
                }
                ServiceAcoountComboFill();
                GridParticularComboFill();
                SalesmanComboFill();
                CashOrPartyComboFill();
                isEditMode = false;
                txtDiscount.Text = "0";
                txtTotalAmount.Text = "0";
                txtGrandTotal.Text = "0";
                txtCreditPeriod.Text = "0";
                txtCustomer.Text = string.Empty;
                txtNarration.Text = string.Empty;
                PrintCheck();
                int inCount = dgvServiceVoucher.RowCount;
                for (int i = 0; i < inCount; i++)
                {
                    dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value = null;
                    dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value = null;
                    dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value = null;
                }
                dgvServiceVoucher.ClearSelection();
                btnDelete.Enabled = false;
                btnSave.Text = "Save";
                dgvServiceVoucher.Rows.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("SV 04 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to generate Voucher number as per settings
 /// </summary>
 public void VoucherNoGeneration()
 {
     string strRejectionIn = "RejectionInMaster";
     string strSuffix = string.Empty;
     string strPrefix = string.Empty;
     string strInvoiceNo = string.Empty;
     try
     {
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = transactionGeneralFillObj.VoucherNumberAutomaicGeneration(decRejectionInVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strRejectionIn);
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             // SuffixPrefixSP spSuffixPrefix = new SuffixPrefixSP();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decRejectionInVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
             txtRejectionInNo.Text = strInvoiceNo;
             txtRejectionInNo.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RI:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }