Example #1
0
 public void SalaryVoucherMasterEdit(SalaryVoucherMasterInfo salaryvouchermasterinfo)
 {
     try
     {
         SPSalaryVoucherMaster.SalaryVoucherMasterEdit(salaryvouchermasterinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CN01:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to insert values to MonthlySalaryVoucherMaster Table and return the Curresponding row's Id
        /// </summary>
        /// <param name="salaryvouchermasterinfo"></param>
        /// <param name="IsAutomatic"></param>
        /// <returns></returns>
        public List <DataTable> MonthlySalaryVoucherMasterAddWithIdentity(SalaryVoucherMasterInfo salaryvouchermasterinfo, bool IsAutomatic)
        {
            List <DataTable> ListObj = new List <DataTable>();
            DataTable        dtbl    = new DataTable();

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlDataAdapter sqlda = new SqlDataAdapter("MonthlySalaryVoucherMasterAddWithIdentity", sqlcon);
                sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = salaryvouchermasterinfo.LedgerId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = salaryvouchermasterinfo.VoucherNo;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = salaryvouchermasterinfo.InvoiceNo;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = salaryvouchermasterinfo.Date;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@month", SqlDbType.DateTime);
                sprmparam.Value = salaryvouchermasterinfo.Month;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = salaryvouchermasterinfo.TotalAmount;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = salaryvouchermasterinfo.Narration;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = salaryvouchermasterinfo.Extra1;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = salaryvouchermasterinfo.Extra2;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = salaryvouchermasterinfo.SuffixPrefixId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = salaryvouchermasterinfo.VoucherTypeId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = salaryvouchermasterinfo.FinancialYearId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@isAutomatic", SqlDbType.Bit);
                sprmparam.Value = IsAutomatic;
                sqlda.Fill(dtbl);
                ListObj.Add(dtbl);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(ListObj);
        }
Example #3
0
        public List <DataTable> MonthlySalaryVoucherMasterAddWithIdentity(SalaryVoucherMasterInfo salaryvouchermasterinfo, bool IsAutomatic)
        {
            List <DataTable> list = new List <DataTable>();

            try
            {
                SPSalaryVoucherMaster.MonthlySalaryVoucherMasterAddWithIdentity(salaryvouchermasterinfo, IsAutomatic);
            }
            catch (Exception ex)
            {
                MessageBox.Show("BR6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(list);
        }
Example #4
0
        public SalaryVoucherMasterInfo SalaryVoucherMasterView(decimal salaryVoucherMasterId)
        {
            SalaryVoucherMasterInfo InfoSalaryVoucherMaster = new SalaryVoucherMasterInfo();

            try
            {
                InfoSalaryVoucherMaster = SPSalaryVoucherMaster.SalaryVoucherMasterView(salaryVoucherMasterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CN01:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(InfoSalaryVoucherMaster);
        }
 /// <summary>
 /// Function to insert values to SalaryVoucherMaster Table
 /// </summary>
 /// <param name="salaryvouchermasterinfo"></param>
 public void SalaryVoucherMasterAdd(SalaryVoucherMasterInfo salaryvouchermasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("SalaryVoucherMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@salaryVoucherMasterId", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.SalaryVoucherMasterId;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = salaryvouchermasterinfo.VoucherNo;
         sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = salaryvouchermasterinfo.InvoiceNo;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = salaryvouchermasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@month", SqlDbType.DateTime);
         sprmparam.Value = salaryvouchermasterinfo.Month;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = salaryvouchermasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = salaryvouchermasterinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = salaryvouchermasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = salaryvouchermasterinfo.Extra2;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = salaryvouchermasterinfo.FinancialYearId;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #6
0
        /// <summary>
        /// Function to get particular values from SalaryVoucherMaster Table based on the parameter
        /// </summary>
        /// <param name="salaryVoucherMasterId"></param>
        /// <returns></returns>
        public SalaryVoucherMasterInfo SalaryVoucherMasterView(decimal salaryVoucherMasterId)
        {
            SalaryVoucherMasterInfo salaryvouchermasterinfo = new SalaryVoucherMasterInfo();
            SqlDataReader           sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("SalaryVoucherMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@salaryVoucherMasterId", SqlDbType.Decimal);
                sprmparam.Value = salaryVoucherMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    salaryvouchermasterinfo.SalaryVoucherMasterId = decimal.Parse(sdrreader[0].ToString());
                    salaryvouchermasterinfo.LedgerId        = decimal.Parse(sdrreader[1].ToString());
                    salaryvouchermasterinfo.VoucherNo       = sdrreader[2].ToString();
                    salaryvouchermasterinfo.InvoiceNo       = sdrreader[3].ToString();
                    salaryvouchermasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    salaryvouchermasterinfo.Month           = DateTime.Parse(sdrreader[5].ToString());
                    salaryvouchermasterinfo.TotalAmount     = decimal.Parse(sdrreader[6].ToString());
                    salaryvouchermasterinfo.Narration       = sdrreader[7].ToString();
                    salaryvouchermasterinfo.ExtraDate       = DateTime.Parse(sdrreader[8].ToString());
                    salaryvouchermasterinfo.Extra1          = sdrreader[9].ToString();
                    salaryvouchermasterinfo.Extra2          = sdrreader[10].ToString();
                    salaryvouchermasterinfo.SuffixPrefixId  = decimal.Parse(sdrreader[11].ToString());
                    salaryvouchermasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[12].ToString());
                    salaryvouchermasterinfo.FinancialYearId = decimal.Parse(sdrreader[13].ToString());
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (sdrreader != null)
                {
                    sdrreader.Close();
                }
                sqlcon.Close();
            }
            return(salaryvouchermasterinfo);
        }
        public List <DataTable> MonthlySalaryVoucherMasterAddWithIdentity(SalaryVoucherMasterInfo salaryvouchermasterinfo, bool IsAutomatic)
        {
            SalaryVoucherMasterSP SPSalaryVoucherMaster = new SalaryVoucherMasterSP();
            List <DataTable>      ListObj = new List <DataTable>();

            try
            {
                ListObj = SPSalaryVoucherMaster.MonthlySalaryVoucherMasterAddWithIdentity(salaryvouchermasterinfo, IsAutomatic);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SvBll 11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(ListObj);
        }
        public SalaryVoucherMasterInfo SalaryVoucherMasterView(decimal salaryVoucherMasterId)
        {
            SalaryVoucherMasterInfo salaryvouchermasterinfo = new SalaryVoucherMasterInfo();

            SalaryVoucherMasterSP SPSalaryVoucherMaster = new SalaryVoucherMasterSP();

            try
            {
                salaryvouchermasterinfo = SPSalaryVoucherMaster.SalaryVoucherMasterView(salaryVoucherMasterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SvBll 9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(salaryvouchermasterinfo);
        }
        /// <summary>
        /// Function for Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();
                SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo();

                SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo();

                //------------------------------- In the case of multi user check whether salary is paying for the sam person ----------------//
                int inCounts = dgvMonthlySalary.RowCount;
                int incont = 0;
                decimal decVal = 0;
                for (int i = 0; i < inCounts; i++)
                {
                    decVal = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    if (BllSalaryVoucher.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) != "0")
                    {
                        strEployeeNames = strEployeeNames + BllSalaryVoucher.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }

                    }
                }
                if (BllSalaryVoucher.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) != "0")
                {

                    Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames);
                    GridFill(isEditMode);
                }
                infoMaster.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString());
                if (isAutomatic)
                {
                    infoMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoMaster.VoucherNo = txtVoucherNo.Text;
                }
                infoMaster.Month = Convert.ToDateTime(dtpMonth.Text.ToString());
                infoMaster.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString());
                infoMaster.Narration = txtNarration.Text.Trim();
                if (isAutomatic)
                {
                    infoMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoMaster.InvoiceNo = txtVoucherNo.Text;
                }
                if (lblTotalAmount.Text.ToString() != string.Empty)
                {
                    infoMaster.TotalAmount = Math.Round(Convert.ToDecimal(lblTotalAmount.Text.ToString()), PublicVariables._inNoOfDecimalPlaces);
                }
                infoMaster.Extra1 = string.Empty; // Fields not in design//
                infoMaster.Extra2 = string.Empty; // Fields not in design//
                infoMaster.SuffixPrefixId = decMonthlySuffixPrefixId;
                infoMaster.VoucherTypeId = decMonthlyVoucherTypeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                int inCount = dgvMonthlySalary.RowCount;
                int inValue = 0;
                for (int i = 0; i < inCount; i++)
                {
                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid")
                    {
                        inValue++;
                    }
                }
                if (inValue > 0)
                {
                    //-------------------------In the case of Multi-User Check the VoucherNo. again (Max of VoucherNumber )---------------------//
                    List<DataTable> ListObj = new List<DataTable>();
                    ListObj = BllSalaryVoucher.MonthlySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic);
                    foreach (DataRow dr in ListObj[0].Rows)
                    {
                        decMasterId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                        strUpdatedVoucherNo = dr.ItemArray[1].ToString();
                        strUpdatedInvoiceNo = dr.ItemArray[2].ToString();
                    }
                    if (!isAutomatic)
                    {
                        strVoucherNo = txtVoucherNo.Text;
                    }
                    if (isAutomatic)
                    {
                        if (strUpdatedVoucherNo != "" && Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo))
                        {
                            Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo);
                            strVoucherNo = strUpdatedVoucherNo.ToString();
                            strInvoiceNo = strUpdatedInvoiceNo;

                        }
                    }
                    LedgerPosting(Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString()));
                    infoDetails.Extra1 = string.Empty;
                    infoDetails.Extra2 = string.Empty;
                    infoDetails.SalaryVoucherMasterId = decMasterId;

                    int inRowCount = dgvMonthlySalary.RowCount;
                    for (int i = 0; i < inRowCount; i++)
                    {

                        if (dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                        {
                            infoDetails.EmployeeId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Bonus = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Deduction = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Advance = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["txtLop"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Lop = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Salary = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString());
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value != null && dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                        {
                            infoDetails.Status = dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString();
                        }
                        if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid" && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0")
                        {
                            infoDetails.SalaryVoucherMasterId = decMasterId;
                            BllSalaryVoucher.MonthlySalaryVoucherDetailsAdd(infoDetails);
                        }
                    }

                    Messages.SavedMessage();
                    GridFill(isEditMode);
                    Clear();
                }
                else
                {
                    Messages.InformationMessage("Can't save without atleast one employee");
                    strVoucherNo = BllSalaryVoucher.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void FillFunction()
        {
            try
            {
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();

                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();

                InfoMaster = BllSalaryVoucher.SalaryVoucherMasterView(decIsEditModeMasterId);

                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;

                txtVoucherDate.Text = InfoMaster.Date.ToString("dd-MMMM-yyyy");
                string stra = Convert.ToDateTime(InfoMaster.Month.ToString()).ToString("MMM yyyy");
                dtpMonth.Value = Convert.ToDateTime(InfoMaster.Month.ToString("MMM yyyy"));
                txtNarration.Text = InfoMaster.Narration;

                decimal decTotalAmont = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString()), PublicVariables._inNoOfDecimalPlaces);
                lblTotalAmount.Text = decTotalAmont.ToString();
                decMonthlySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decMonthlyVoucherTypeId = InfoMaster.VoucherTypeId;

                cmbCashOrBankAcc.SelectedValue = InfoMaster.LedgerId;
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }
                dtpMonth.Enabled = false;

                GridFill(isEditMode);
            }
            catch (Exception ex)
            {

                MessageBox.Show("MSV10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for edit
        /// </summary>
        public void EditFunction()
        {
            try
            {

                SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo();
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();
                SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                infoMaster.SalaryVoucherMasterId = decIsEditModeMasterId;
                infoMaster.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString());
                infoMaster.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString());
                infoMaster.Narration = txtNarration.Text.Trim();
                infoMaster.TotalAmount = Convert.ToDecimal(lblTotalAmount.Text.ToString());
                if (isAutomatic)
                {
                    infoMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoMaster.VoucherNo = txtVoucherNo.Text;
                }

                if (isAutomatic)
                {
                    infoMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoMaster.InvoiceNo = txtVoucherNo.Text;
                }
                infoMaster.Extra1 = string.Empty;
                infoMaster.Extra2 = string.Empty;
                infoMaster.SuffixPrefixId = decMonthlySuffixPrefixId;
                infoMaster.VoucherTypeId = decMonthlyVoucherTypeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.Month = Convert.ToDateTime(dtpMonth.Text.ToString());

                infoDetails.Extra1 = string.Empty;
                infoDetails.Extra2 = string.Empty;

                int inRowCount = dgvMonthlySalary.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {

                    if (dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Bonus = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtBonus"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Deduction = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDeduction"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Advance = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtAdvance"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["txtLop"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Lop = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtLop"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value != null && dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Salary = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtSalary"].Value.ToString());
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value != null && dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Status = dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString();
                    }

                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() != "0")
                    {
                        decimal SalaryVoucherDetailsId = Convert.ToDecimal(dgvMonthlySalary.Rows[i].Cells["txtDetailsId"].Value.ToString());
                        BllSalaryVoucher.SalaryVoucherDetailsDelete(SalaryVoucherDetailsId);
                        BllSalaryVoucher.SalaryVoucherMasterEdit(infoMaster);

                        LedgerUpdate();

                    }

                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == "Paid" && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0")
                    {
                        infoDetails.SalaryVoucherMasterId = decIsEditModeMasterId;
                        BllSalaryVoucher.MonthlySalaryVoucherDetailsAdd(infoDetails);
                        BllSalaryVoucher.SalaryVoucherMasterEdit(infoMaster);

                        LedgerUpdate();
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0")
                    {
                        BllSalaryVoucher.SalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();
                    }
                }
                if (BllSalaryVoucher.SalaryVoucherDetailsCount(decIsEditModeMasterId) == 0)
                {
                    BllSalaryVoucher.SalaryVoucherMasterDelete(decIsEditModeMasterId);
                }
                Messages.UpdatedMessage();
                GridFill(isEditMode);

                if (frmMonthlySalaryRegisterObj != null)
                {
                    this.Close();
                }
                if (frmLedgerDetailsObj != null)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from frmVoucherSearch form to view voucher details
        /// </summary>
        /// <param name="frm"></param>
        /// <param name="decId"></param>
        public void CallFromVoucherSerach(frmVoucherSearch frm, decimal decId)
        {
            try
            {

                isEditMode = true;
                decIsEditModeMasterId = decId;
                base.Show();
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();

                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                btnDelete.Enabled = true;
                btnSave.Text = "Update";
                InfoMaster = BllSalaryVoucher.SalaryVoucherMasterView(decIsEditModeMasterId);
                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;
                txtVoucherDate.Text = InfoMaster.Date.ToString("dd-MMMM-yyyy");
                string stra = Convert.ToDateTime(InfoMaster.Month.ToString()).ToString("MMM yyyy");
                dtpMonth.Value = Convert.ToDateTime(InfoMaster.Month.ToString("MMM yyyy"));
                txtNarration.Text = InfoMaster.Narration;
                lblTotalAmount.Text = InfoMaster.TotalAmount.ToString();
                decMonthlySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decMonthlyVoucherTypeId = InfoMaster.VoucherTypeId;
                this.objVoucherSearch = frm;
                cmbCashOrBankAcc.SelectedValue = InfoMaster.LedgerId;
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }
                dtpMonth.Enabled = false;
                GridFill(isEditMode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV2: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for edit
        /// </summary>
        public void EditFunction_MSV(string masterId, string tableData, string editMode)
        {
            try
            {
                List <Object>            dgvMonthlySalary = JsonConvert.DeserializeObject <List <Object> >(tableData);
                JArray                   itemFirst        = (JArray)dgvMonthlySalary[0];
                string                   voucherNo        = Convert.ToString(itemFirst[0]["voucherNo"].Value <string>());
                string                   voucherDate      = Convert.ToString(itemFirst[0]["voucherDate"].Value <string>());
                string                   month            = Convert.ToString(itemFirst[0]["month"].Value <string>());
                string                   cash             = Convert.ToString(itemFirst[0]["cash"].Value <string>());
                string                   totalAmount      = Convert.ToString(itemFirst[0]["totalAmount"].Value <string>());
                string                   narration        = Convert.ToString(itemFirst[0]["narration"].Value <string>());
                SalaryVoucherMasterSP    spMaster         = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo  infoMaster       = new SalaryVoucherMasterInfo();
                SalaryVoucherDetailsSP   spDetails        = new SalaryVoucherDetailsSP();
                SalaryVoucherDetailsInfo infoDetails      = new SalaryVoucherDetailsInfo();
                LedgerPostingSP          spLedgerPosting  = new LedgerPostingSP();
                decimal                  masterID         = Convert.ToDecimal(masterId);
                infoMaster.SalaryVoucherMasterId = masterID;
                infoMaster.Date        = Convert.ToDateTime(voucherDate);
                infoMaster.LedgerId    = Convert.ToDecimal(cash);
                infoMaster.Narration   = narration;
                infoMaster.TotalAmount = Convert.ToDecimal(totalAmount);
                bool          isEditMode              = Convert.ToBoolean(editMode);
                VoucherTypeSP spVoucherType           = new VoucherTypeSP();
                int           decMonthlyVoucherTypeId = 27;
                decimal       typeId      = Convert.ToDecimal(decMonthlyVoucherTypeId);
                var           isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(typeId);
                infoMaster.VoucherNo = voucherNo;
                infoMaster.InvoiceNo = voucherNo;

                infoMaster.Extra1          = string.Empty;
                infoMaster.Extra2          = string.Empty;
                infoMaster.SuffixPrefixId  = Convert.ToDecimal(ViewData["decMonthlySuffixPrefixId"]);
                infoMaster.VoucherTypeId   = typeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.Month           = Convert.ToDateTime(month);

                infoDetails.Extra1 = string.Empty;
                infoDetails.Extra2 = string.Empty;

                int inRowCount = dgvMonthlySalary.Count;
                for (int i = 0; i < inRowCount; i++)
                {
                    JArray item = (JArray)dgvMonthlySalary[i];
                    if (item[0]["txtEmployeeId"] != null)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(item[0]["txtEmployeeId"].Value <string>());
                    }
                    if (item[0]["txtBonus"] != null)
                    {
                        infoDetails.Bonus = Convert.ToDecimal(item[0]["txtBonus"].Value <string>());
                    }
                    if (item[0]["txtDeduction"] != null)
                    {
                        infoDetails.Deduction = Convert.ToDecimal(item[0]["txtDeduction"].Value <string>());
                    }
                    if (item[0]["txtAdvance"] != null)
                    {
                        infoDetails.Advance = Convert.ToDecimal(item[0]["txtAdvance"].Value <string>());
                    }
                    if (item[0]["txtLop"] != null)
                    {
                        infoDetails.Lop = Convert.ToDecimal(item[0]["txtLop"].Value <string>());
                    }
                    if (item[0]["txtSalary"] != null)
                    {
                        infoDetails.Salary = Convert.ToDecimal(item[0]["txtSalary"].Value <string>());
                    }
                    if (item[0]["cmbStatus"] != null && Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid")
                    {
                        infoDetails.Status = Convert.ToString(item[0]["cmbStatus"].Value <string>());
                    }


                    if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Pending" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) != "0")
                    {
                        decimal SalaryVoucherDetailsId = Convert.ToDecimal(item[0]["txtDetailsId"].Value <string>());
                        spDetails.SalaryVoucherDetailsDelete(SalaryVoucherDetailsId);
                        spMaster.SalaryVoucherMasterEdit(infoMaster);

                        //LedgerUpdate();
                    }

                    if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) == "0")
                    {
                        infoDetails.SalaryVoucherMasterId = masterID;
                        spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails);
                        spMaster.SalaryVoucherMasterEdit(infoMaster);

                        //LedgerUpdate();
                    }
                    if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Pending" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) == "0")
                    {
                        spMaster.SalaryVoucherMasterEdit(infoMaster);
                        //LedgerUpdate();
                    }
                }
                if (spDetails.SalaryVoucherDetailsCount(masterID) == 0)
                {
                    spMaster.SalaryVoucherMasterDelete(masterID);
                }
                //GridFillVoucher(isEditMode, Convert.ToDateTime(month), voucherNo);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("MSV8:" + ex.Message, "Masterfine", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public void SaveFunction_MSV(string tableData, string editMode)
        {
            try
            {
                List <Object>            dgvMonthlySalary = JsonConvert.DeserializeObject <List <Object> >(tableData);
                JArray                   itemFirst        = (JArray)dgvMonthlySalary[0];
                string                   voucherNo        = Convert.ToString(itemFirst[0]["voucherNo"].Value <string>());
                string                   voucherDate      = Convert.ToString(itemFirst[0]["voucherDate"].Value <string>());
                string                   month            = Convert.ToString(itemFirst[0]["month"].Value <string>());
                string                   cash             = Convert.ToString(itemFirst[0]["cash"].Value <string>());
                string                   totalAmount      = Convert.ToString(itemFirst[0]["totalAmount"].Value <string>());
                string                   narration        = Convert.ToString(itemFirst[0]["narration"].Value <string>());
                SalaryVoucherMasterSP    spMaster         = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo  infoMaster       = new SalaryVoucherMasterInfo();
                SalaryVoucherDetailsSP   spDetails        = new SalaryVoucherDetailsSP();
                SalaryVoucherDetailsInfo infoDetails      = new SalaryVoucherDetailsInfo();
                DateTime                 dtpMonth         = Convert.ToDateTime(month);
                bool          isEditMode = Convert.ToBoolean(editMode);
                int           decMonthlyVoucherTypeId = 27;
                decimal       typeId        = Convert.ToDecimal(decMonthlyVoucherTypeId);
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                var           isAutomatic   = spVoucherType.CheckMethodOfVoucherNumbering(typeId);

                //------------------------------- In the case of multi user check whether salary is paying for the sam person ----------------//
                int     inCounts        = dgvMonthlySalary.Count;
                int     incont          = 0;
                decimal decVal          = 0;
                string  strEployeeNames = "";
                for (int i = 0; i < inCounts; i++)
                {
                    JArray item = (JArray)dgvMonthlySalary[i];
                    decVal = Convert.ToDecimal(item[0]["txtEmployeeId"].Value <string>());
                    if (spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth) != "0")
                    {
                        strEployeeNames = strEployeeNames + spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont          = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }
                    }
                }
                if (spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth) != "0")
                {
                    // Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames);
                    //GridFillVoucher(isEditMode, dtpMonth, voucherNo);
                }
                infoMaster.LedgerId  = Convert.ToDecimal(cash);
                infoMaster.VoucherNo = voucherNo;
                infoMaster.Month     = Convert.ToDateTime(dtpMonth);
                infoMaster.Date      = Convert.ToDateTime(voucherDate);
                infoMaster.Narration = narration;
                infoMaster.InvoiceNo = voucherNo;
                if (totalAmount != string.Empty)
                {
                    infoMaster.TotalAmount = Math.Round(Convert.ToDecimal(totalAmount), PublicVariables._inNoOfDecimalPlaces);
                }
                infoMaster.Extra1          = string.Empty; // Fields not in design//
                infoMaster.Extra2          = string.Empty; // Fields not in design//
                infoMaster.SuffixPrefixId  = Convert.ToDecimal(ViewData["decMonthlySuffixPrefixId"]);
                infoMaster.VoucherTypeId   = typeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                int inCount = dgvMonthlySalary.Count;
                int inValue = 0;
                for (int i = 0; i < inCount; i++)
                {
                    JArray item = (JArray)dgvMonthlySalary[i];
                    if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid")
                    {
                        inValue++;
                    }
                }
                if (inValue > 0)
                {
                    //-------------------------In the case of Multi-User Check the VoucherNo. again (Max of VoucherNumber )---------------------//
                    DataTable dtbl = new DataTable();
                    decimal   decMasterId = 0;
                    string    strUpdatedVoucherNo = "", strUpdatedInvoiceNo = "";
                    dtbl = spMaster.MonthlySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic);
                    foreach (DataRow dr in dtbl.Rows)
                    {
                        decMasterId         = Convert.ToDecimal(dr.ItemArray[0].ToString());
                        strUpdatedVoucherNo = dr.ItemArray[1].ToString();
                        strUpdatedInvoiceNo = dr.ItemArray[2].ToString();
                    }
                    string strVoucherNo = "";
                    string strInvoiceNo = "";
                    if (!isAutomatic)
                    {
                        strVoucherNo = voucherNo;
                    }
                    if (isAutomatic)
                    {
                        if (strUpdatedVoucherNo != "" && Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(voucherNo))
                        {
                            //Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo);
                            strVoucherNo = strUpdatedVoucherNo.ToString();
                            strInvoiceNo = strUpdatedInvoiceNo;
                        }
                    }
                    //LedgerPosting(Convert.ToDecimal(cash));
                    infoDetails.Extra1 = string.Empty;
                    infoDetails.Extra2 = string.Empty;
                    infoDetails.SalaryVoucherMasterId = decMasterId;

                    int inRowCount = dgvMonthlySalary.Count;
                    for (int i = 0; i < inRowCount; i++)
                    {
                        JArray item = (JArray)dgvMonthlySalary[i];
                        if (item[0]["txtEmployeeId"] != null)
                        {
                            infoDetails.EmployeeId = Convert.ToDecimal(item[0]["txtEmployeeId"].Value <string>());
                        }
                        if (item[0]["txtBonus"] != null)
                        {
                            infoDetails.Bonus = Convert.ToDecimal(item[0]["txtBonus"].Value <string>());
                        }
                        if (item[0]["txtDeduction"] != null)
                        {
                            infoDetails.Deduction = Convert.ToDecimal(item[0]["txtDeduction"].Value <string>());
                        }
                        if (item[0]["txtAdvance"] != null)
                        {
                            infoDetails.Advance = Convert.ToDecimal(item[0]["txtAdvance"].Value <string>());
                        }
                        if (item[0]["txtLop"] != null)
                        {
                            infoDetails.Lop = Convert.ToDecimal(item[0]["txtLop"].Value <string>());
                        }
                        if (item[0]["txtSalary"] != null)
                        {
                            infoDetails.Salary = Convert.ToDecimal(item[0]["txtSalary"].Value <string>());
                        }
                        if (item[0]["cmbStatus"] != null)
                        {
                            infoDetails.Status = Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid"? "Paid": string.Empty;
                        }
                        if (Convert.ToString(item[0]["cmbStatus"].Value <string>()) == "Paid" && Convert.ToString(item[0]["txtMasterId"].Value <string>()) == "0")
                        {
                            infoDetails.SalaryVoucherMasterId = decMasterId;
                            spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails);
                        }
                    }

                    //GridFillVoucher(isEditMode,dtpMonth, voucherNo);
                    VoucherClear(strVoucherNo, voucherDate, editMode);
                }
                else
                {
                    //Messages.InformationMessage("Can't save without atleast one employee");
                    voucherNo = spMaster.SalaryVoucherMasterGetMax(typeId);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("MSV7:" + ex.Message, "Masterfine", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public ActionResult FillFunction(string id)
        {
            try
            {
                DataTable               dtbl          = new DataTable();
                SalaryVoucherMasterSP   SpMaster      = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo InfoMaster    = new SalaryVoucherMasterInfo();
                VoucherTypeSP           spVoucherType = new VoucherTypeSP();
                decimal masterId = Convert.ToDecimal(id);
                InfoMaster = SpMaster.SalaryVoucherMasterView(masterId);

                var strVoucherNoforEdit = InfoMaster.VoucherNo;
                var strVoucherNo        = InfoMaster.VoucherNo;
                var strInvoiceNo        = InfoMaster.InvoiceNo;

                var txtVoucherDate = InfoMaster.Date.ToString("yyyy-MM-dd");
                var dtpMonth       = Convert.ToDateTime(InfoMaster.Month.ToString("yyyy-MM"));

                var     txtNarration             = InfoMaster.Narration;
                string  txtMonth                 = InfoMaster.Month.ToString("yyyy-MM");
                decimal decTotalAmont            = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString()), PublicVariables._inNoOfDecimalPlaces);
                var     lblTotalAmount           = decTotalAmont.ToString();
                var     decMonthlySuffixPrefixId = InfoMaster.SuffixPrefixId;
                var     decMonthlyVoucherTypeId  = InfoMaster.VoucherTypeId;
                ViewData["decMonthlyVoucherTypeId"]  = decMonthlyVoucherTypeId;
                ViewData["decMonthlySuffixPrefixId"] = decMonthlySuffixPrefixId;
                var  cmbCashOrBankAcc    = InfoMaster.LedgerId;
                var  isAutomatic         = spVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                bool txtInVoiceNoEnabled = false;
                if (isAutomatic)
                {
                    txtInVoiceNoEnabled = false;
                }
                else
                {
                    txtInVoiceNoEnabled = true;
                }
                bool dtpMonthEnabled = false;
                dtbl = GridFillVoucher(true, dtpMonth, strVoucherNo);
                string jsonResult = Utils.ConvertDataTabletoString(dtbl);
                return(Json(new
                {
                    error = "false",
                    data = jsonResult,
                    voucherNo = strVoucherNo,
                    strInvoiceNo,
                    voucherDate = txtVoucherDate,
                    month = txtMonth,
                    cash = cmbCashOrBankAcc,
                    totalAmount = lblTotalAmount,
                    narration = txtNarration,
                    txtInVoiceNoEnabled,
                    dtpMonthEnabled,
                    masterID = masterId
                }));
            }
            catch (Exception ex)
            {
            }
            return(Json(new{ error = "true" }));
        }