Example #1
0
 public void DailySalaryVoucherDetailsAdd(DailySalaryVoucherDetailsInfo dailysalaryvoucherdetailsinfo)
 {
     try
     {
         if (base.sqlcon.State == ConnectionState.Closed)
         {
             base.sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DailySalaryVoucherDetailsAdd", base.sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam7 = new SqlParameter();
         sprmparam7       = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.DailySalaryVocherMasterId;
         sprmparam7       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.EmployeeId;
         sprmparam7       = sccmd.Parameters.Add("@wage", SqlDbType.Decimal);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.Wage;
         sprmparam7       = sccmd.Parameters.Add("@status", SqlDbType.VarChar);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.Status;
         sprmparam7       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.Extra1;
         sprmparam7       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam7.Value = dailysalaryvoucherdetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         base.sqlcon.Close();
     }
 }
 public void DailySalaryVoucherDetailsAdd(DailySalaryVoucherDetailsInfo dailysalaryvoucherdetailsinfo)
 {
     try
     {
         spDetails.DailySalaryVoucherDetailsAdd(dailysalaryvoucherdetailsinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to get particular values from DailySalaryVoucherDetails table based on the parameter
        /// </summary>
        /// <param name="dailySalaryVoucherDetailsId"></param>
        /// <returns></returns>
        public DailySalaryVoucherDetailsInfo DailySalaryVoucherDetailsView(decimal dailySalaryVoucherDetailsId)
        {
            DailySalaryVoucherDetailsInfo dailysalaryvoucherdetailsinfo = new DailySalaryVoucherDetailsInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DailySalaryVoucherDetailsView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@dailySalaryVoucherDetailsId", SqlDbType.Decimal);
                sprmparam.Value = dailySalaryVoucherDetailsId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    dailysalaryvoucherdetailsinfo.DailySalaryVoucherDetailsId = decimal.Parse(sdrreader[0].ToString());
                    dailysalaryvoucherdetailsinfo.DailySalaryVocherMasterId   = decimal.Parse(sdrreader[1].ToString());
                    dailysalaryvoucherdetailsinfo.EmployeeId = decimal.Parse(sdrreader[2].ToString());
                    dailysalaryvoucherdetailsinfo.Wage       = decimal.Parse(sdrreader[3].ToString());
                    dailysalaryvoucherdetailsinfo.Status     = sdrreader[4].ToString();
                    dailysalaryvoucherdetailsinfo.ExtraDate  = DateTime.Parse(sdrreader[5].ToString());
                    dailysalaryvoucherdetailsinfo.Extra1     = sdrreader[6].ToString();
                    dailysalaryvoucherdetailsinfo.Extra2     = sdrreader[7].ToString();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(dailysalaryvoucherdetailsinfo);
        }
        /// <summary>
        /// Function to Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {

                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();

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

                    }
                }
                if (BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                {

                    Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames);
                    DailySalaryVoucherDetailsGridfill(isEditmode);
                }
                else
                {
                    if (isAutomatic)
                    {
                        infoMaster.VoucherNo = strVoucherNo;
                    }
                    else
                    {
                        infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.Date = DateTime.Parse(dtpDate.Text.ToString());
                    infoMaster.SalaryDate = DateTime.Parse(dtpSalaryDate.Text.ToString());
                    infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                    infoMaster.Narration = txtNarration.Text.Trim();
                    infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                    infoMaster.Extra1 = string.Empty; // Fields not in design//
                    infoMaster.Extra2 = string.Empty; // Fields not in design//
                    if (isAutomatic)
                    {
                        infoMaster.InvoiceNo = strInvoiceNo;
                    }
                    else
                    {
                        infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                    infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                    infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    int inval = 0;
                    int inCount = dgvDailySalaryVoucher.RowCount;
                    for (int i = 0; i < inCount; i++)
                    {
                        if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid")
                        {
                            inval++;
                        }

                    }
                    if (inval >= 0)
                    {
                        //-------------checks Voucher No. repeating in Multi user case----------//
                        List<DataTable> listObj = new List<DataTable>();
                        listObj = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterAddWithIdentity(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 (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo))
                            {
                                Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo);
                                strVoucherNo = strUpdatedVoucherNo.ToString();
                                strInvoiceNo = strUpdatedInvoiceNo;
                            }
                        }
                        //-------------------------------------//
                        LedgerPosting(Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString()));

                        infoDetails.DailySalaryVocherMasterId = decMasterId;
                        infoDetails.Extra1 = string.Empty;// Fields not in design//
                        infoDetails.Extra2 = string.Empty;// Fields not in design//
                        int inRowCount = dgvDailySalaryVoucher.RowCount;
                        for (int i = 0; i < inRowCount; i++)
                        {

                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                            {
                                infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());

                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();

                            }

                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                            {
                                infoDetails.DailySalaryVocherMasterId = decMasterId;
                                BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails);
                            }
                        }
                        Messages.SavedMessage();
                        DailySalaryVoucherDetailsGridfill(isEditmode);
                        Clear();

                    }
                    else
                    {
                        strVoucherNo = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId);
                        Messages.InformationMessage("Can't save without atleast one employee");
                        Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();

                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                infoMaster.DailySalaryVoucehrMasterId = decMasterIdforEdit;
                infoMaster.Date = Convert.ToDateTime(dtpDate.Value.ToString());
                infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                infoMaster.Narration = txtNarration.Text;
                infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                if (isAutomatic)
                {
                    infoMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                }

                if (isAutomatic)
                {
                    infoMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                }
                infoMaster.Extra1 = string.Empty;
                infoMaster.Extra2 = string.Empty;
                infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.SalaryDate = Convert.ToDateTime(dtpSalaryDate.Text.ToString());
                infoDetails.Extra1 = string.Empty;// Fields not in design//
                infoDetails.Extra2 = string.Empty;// Fields not in design//
                BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster);
                int inRowCount = dgvDailySalaryVoucher.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();
                    }

                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() != string.Empty)
                    {
                        decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtdailySalaryVoucherDetailsId"].Value.ToString());
                        BllDailySalaryVoucher.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId);

                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        infoDetails.DailySalaryVocherMasterId = decMasterIdforEdit;
                        BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails);
                        //spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                }
                if (BllDailySalaryVoucher.DailySalaryVoucherDetailsCount(decMasterIdforEdit) == 0)
                {
                    BllDailySalaryVoucherMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit);
                }
                Messages.UpdatedMessage();
                Clear();
                if (frmDailySalaryRegisterobj != null)
                {

                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #6
0
        public string SaveDailySalaryVoucher(string dailyMasterId, string voucherTypeId, string voucherNo, string date,
                                             string salaryDate, string cash, string narration, string totalAmount, string details)
        {
            string message = string.Empty;

            try
            {
                decimal       decDailyVoucherTypeId = 0;
                VoucherTypeSP spVoucherType         = new VoucherTypeSP();
                DataTable     dtblVouchetType       = new DataTable();
                dtblVouchetType = spVoucherType.VoucherTypeSelectionComboFill("Daily Salary Voucher");
                int    nCount      = dtblVouchetType.Rows.Count;
                string voucherType = string.Empty;
                if (nCount == 1)
                {
                    voucherType           = dtblVouchetType.Rows[0].ItemArray[0].ToString();
                    decDailyVoucherTypeId = decimal.Parse(voucherType);
                }

                string strEployeeNames = string.Empty;
                DailySalaryVoucherMasterInfo  infoMaster  = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherMasterSP    spMaster    = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherDetailsSP   spDetails   = new DailySalaryVoucherDetailsSP();

                //-------------In multi user case check whether salary is paying for the same persone--------------//
                List <Dictionary <string, object> > detailsData = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(details);
                int      inCounts     = detailsData.Count;
                int      incont       = 0;
                decimal  decVal       = 0;
                DateTime dtSalaryDate = Convert.ToDateTime(salaryDate);
                for (int i = 0; i < inCounts; i++)
                {
                    decVal = Convert.ToDecimal(detailsData[i]["employeeId"].ToString());
                    if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) != "0")
                    {
                        strEployeeNames = strEployeeNames + spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont          = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }
                    }
                }
                if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtSalaryDate) != "0")
                {
                    message = "Salary already paid for - " + " " + strEployeeNames;
                }
                else
                {
                    DateTime dtDate = Convert.ToDateTime(date);
                    if (isAutomatic)
                    {
                        infoMaster.VoucherNo = strVoucherNo;
                    }
                    else
                    {
                        infoMaster.VoucherNo = voucherNo;
                    }
                    infoMaster.Date        = dtDate;
                    infoMaster.SalaryDate  = dtSalaryDate;
                    infoMaster.LedgerId    = Convert.ToDecimal(cash);
                    infoMaster.Narration   = narration ?? string.Empty;
                    infoMaster.TotalAmount = Convert.ToDecimal(totalAmount);
                    infoMaster.Extra1      = string.Empty; // Fields not in design//
                    infoMaster.Extra2      = string.Empty; // Fields not in design//
                    if (isAutomatic)
                    {
                        infoMaster.InvoiceNo = strInvoiceNo;
                    }
                    else
                    {
                        infoMaster.InvoiceNo = voucherNo;
                    }
                    infoMaster.SuffixPrefixId  = 0;//decDailySuffixPrefixId;
                    infoMaster.VoucherTypeId   = decDailyVoucherTypeId;
                    infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    int inval   = 0;
                    int inCount = detailsData.Count;
                    for (int i = 0; i < inCount; i++)
                    {
                        if (detailsData[i]["status"].ToString() == "paid")
                        {
                            inval++;
                        }
                    }
                    if (inval >= 0)
                    {
                        decimal decMasterId         = 0;
                        string  strUpdatedVoucherNo = string.Empty;
                        string  strUpdatedInvoiceNo = string.Empty;
                        //-------------checks Voucher No. repeating in Multi user case----------//
                        DataTable dtbl = new DataTable();
                        dtbl = spMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, true);
                        foreach (DataRow dr in dtbl.Rows)
                        {
                            decMasterId         = Convert.ToDecimal(dr.ItemArray[0].ToString());
                            strUpdatedVoucherNo = dr.ItemArray[1].ToString();
                            strUpdatedInvoiceNo = dr.ItemArray[2].ToString();
                        }
                        if (!isAutomatic)
                        {
                            strVoucherNo = voucherNo;
                        }
                        if (isAutomatic)
                        {
                            if (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo))
                            {
                                message      = "Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo;
                                strVoucherNo = strUpdatedVoucherNo.ToString();
                                strInvoiceNo = strUpdatedInvoiceNo;
                            }
                        }
                        //-------------------------------------//
                        LedgerPostingForDailySalary(Convert.ToDecimal(cash), totalAmount, decDailyVoucherTypeId, voucherNo, date);

                        infoDetails.DailySalaryVocherMasterId = decMasterId;
                        infoDetails.Extra1 = string.Empty; // Fields not in design//
                        infoDetails.Extra2 = string.Empty; // Fields not in design//
                        int inRowCount = detailsData.Count;
                        for (int i = 0; i < inRowCount; i++)
                        {
                            if (detailsData[i]["employeeId"].GetType().Name != "JObject" && detailsData[i]["employeeId"].ToString() != string.Empty)
                            {
                                infoDetails.EmployeeId = Convert.ToDecimal(detailsData[i]["employeeId"].ToString());
                            }
                            if (detailsData[i]["dailyWage"].GetType().Name != "JObject" && detailsData[i]["dailyWage"].ToString() != string.Empty)
                            {
                                infoDetails.Wage = Convert.ToDecimal(detailsData[i]["dailyWage"].ToString());
                            }
                            if (detailsData[i]["status"].GetType().Name != "JObject" && detailsData[i]["status"].ToString() == "paid")
                            {
                                infoDetails.Status = detailsData[i]["status"].ToString();
                            }

                            if (detailsData[i]["status"].ToString() == "paid" && detailsData[i]["masterId"].ToString() == string.Empty)
                            {
                                infoDetails.DailySalaryVocherMasterId = decMasterId;
                                spDetails.DailySalaryVoucherDetailsAdd(infoDetails);
                            }
                        }
                    }
                    else
                    {
                        strVoucherNo = spMaster.DailySalaryVoucherMasterGetMax(Convert.ToDecimal(decDailyVoucherTypeId));
                        message      = "Can't save without at least one employee";
                    }
                }
            }
            catch (Exception ex)
            {
                message = "DSV11:" + ex.Message;
            }
            return(message);
        }
Example #7
0
        public string  EditDailySalaryVoucher(string dailyMasterId, string voucherTypeId, string voucherNo, string date,
                                              string salaryDate, string cash, string narration, string totalAmount, string details)
        {
            string message = string.Empty;

            try
            {
                DailySalaryVoucherMasterInfo  infoMaster  = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherMasterSP    spMaster    = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherDetailsSP   spDetails   = new DailySalaryVoucherDetailsSP();
                LedgerPostingSP spLedgerPosting           = new LedgerPostingSP();

                infoMaster.DailySalaryVoucehrMasterId = Convert.ToDecimal(dailyMasterId);
                infoMaster.Date        = Convert.ToDateTime(date);
                infoMaster.LedgerId    = Convert.ToDecimal(cash);
                infoMaster.Narration   = narration;
                infoMaster.TotalAmount = Convert.ToDecimal(totalAmount);
                infoMaster.VoucherNo   = voucherNo;
                infoMaster.InvoiceNo   = voucherNo;

                infoMaster.Extra1          = string.Empty;
                infoMaster.Extra2          = string.Empty;
                infoMaster.SuffixPrefixId  = 0;//decDailySuffixPrefixId;
                infoMaster.VoucherTypeId   = Convert.ToDecimal(voucherTypeId);
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.SalaryDate      = Convert.ToDateTime(salaryDate);
                infoDetails.Extra1         = string.Empty; // Fields not in design//
                infoDetails.Extra2         = string.Empty; // Fields not in design//
                spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                List <Dictionary <string, object> > detailsData = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(details);

                int inRowCount = detailsData.Count;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (detailsData[i]["employeeId"].GetType().Name != "JObject" && detailsData[i]["employeeId"].ToString() != string.Empty)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(detailsData[i]["employeeId"].ToString());
                    }
                    if (detailsData[i]["dailyWage"].GetType().Name != "JObject" && detailsData[i]["dailyWage"].ToString() != string.Empty)
                    {
                        infoDetails.Wage = Convert.ToDecimal(detailsData[i]["dailyWage"].ToString());
                    }
                    if (detailsData[i]["status"].GetType().Name != "JObject" && detailsData[i]["status"].ToString() == "paid")
                    {
                        infoDetails.Status = detailsData[i]["status"].ToString();
                    }

                    if (detailsData[i]["status"].ToString() == "pending" && detailsData[i]["masterId"].GetType().Name != "JObject")
                    {
                        decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(detailsData[i]["detailsId"].ToString());
                        spDetails.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId);

                        LedgerUpdate(infoMaster);
                    }
                    else if (detailsData[i]["status"].ToString() == "pending" && detailsData[i]["masterId"].GetType().Name == "JObject")
                    {
                        spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate(infoMaster);
                    }
                    else if (detailsData[i]["status"].ToString() == "paid" && detailsData[i]["masterId"].GetType().Name == "JObject")
                    {
                        infoDetails.DailySalaryVocherMasterId = infoMaster.DailySalaryVoucehrMasterId;
                        spDetails.DailySalaryVoucherDetailsAdd(infoDetails);
                        //spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate(infoMaster);
                    }
                }
                if (spDetails.DailySalaryVoucherDetailsCount(infoMaster.DailySalaryVoucehrMasterId) == 0)
                {
                    spMaster.DailySalaryVoucherMasterDelete(infoMaster.DailySalaryVoucehrMasterId);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(message);
        }