public void DailySalaryVoucherDetailsAdd(DailySalaryVoucherDetailsInfo dailysalaryvoucherdetailsinfo)
 {
     try
     {
         spDetails.DailySalaryVoucherDetailsAdd(dailysalaryvoucherdetailsinfo);
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
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);
        }
Пример #3
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);
        }