/// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (cmbCashBankAC.Text.Trim() == string.Empty)
         {
             if (cmbCashBankAC.DropDownStyle != ComboBoxStyle.DropDown)
             {
                 cmbCashBankAC.DropDownStyle = ComboBoxStyle.DropDown;
             }
             cmbCashBankAC.Text = "All";
         }
         DataTable dtbl = new DataTable();
         SalaryVoucherMasterSP spSalaryVoucherMaster = new SalaryVoucherMasterSP();
         dtbl = spSalaryVoucherMaster.MonthlySalaryRegisterSearch(Convert.ToDateTime(txtVoucherDateFrom.Text.Trim().ToString()), Convert.ToDateTime(txtVoucherDateTo.Text.Trim().ToString()), Convert.ToDateTime(dtpSalaryMonth.Value.ToString("MMMM yyyy")), txtVoucherNo.Text.Trim(), cmbCashBankAC.Text.ToString(), cmbVoucherTypeName.Text.ToString());
         dgvMonthlySalaryRegister.DataSource = dtbl;
         if (cmbCashBankAC.Text == "All")
         {
             cmbCashBankAC.Text = string.Empty;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         if (cmbCashBankAC.Text.Trim() == string.Empty)
         {
             if (cmbCashBankAC.DropDownStyle != ComboBoxStyle.DropDown)
             {
                 cmbCashBankAC.DropDownStyle = ComboBoxStyle.DropDown;
             }
             cmbCashBankAC.Text = "All";
         }
         DataTable             dtbl = new DataTable();
         SalaryVoucherMasterSP spSalaryVoucherMaster = new SalaryVoucherMasterSP();
         dtbl = spSalaryVoucherMaster.MonthlySalaryRegisterSearch(Convert.ToDateTime(txtVoucherDateFrom.Text.Trim().ToString()), Convert.ToDateTime(txtVoucherDateTo.Text.Trim().ToString()), Convert.ToDateTime(dtpSalaryMonth.Value.ToString("MMMM yyyy")), txtVoucherNo.Text.Trim(), cmbCashBankAC.Text.ToString(), cmbVoucherTypeName.Text.ToString());
         dgvMonthlySalaryRegister.DataSource = dtbl;
         if (cmbCashBankAC.Text == "All")
         {
             cmbCashBankAC.Text = string.Empty;
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "MSR2:" + ex.Message;
     }
 }
Пример #3
0
        /// <summary>
        /// Function for print
        /// </summary>
        public void Print()
        {
            try
            {
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnPrint.Text))
                {
                    if (cmbEmployee.Text == string.Empty || cmbEmployee.Text == "--Select--")
                    {
                        Messages.InformationMessage("Select an employee");
                        cmbEmployee.Focus();
                    }
                    else
                    {
                        SalaryVoucherMasterSP spSalaryVoucherMaster = new SalaryVoucherMasterSP();
                        DateTime dtMon         = DateTime.Parse(dtpSalaryMonth.Text);
                        DateTime dtSalaryMonth = new DateTime(dtMon.Year, dtMon.Month, 1);
                        decimal  decEmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                        DataSet  dsPaySlip     = spSalaryVoucherMaster.PaySlipPrinting(decEmployeeId, dtSalaryMonth, 1);

                        foreach (DataTable dtbl in dsPaySlip.Tables)
                        {
                            if (dtbl.TableName == "Table1")
                            {
                                if (dtbl.Rows.Count > 0)
                                {
                                    frmReport frmReport = new frmReport();
                                    frmReport.MdiParent = formMDI.MDIObj;
                                    frmReport.PaySlipPrinting(dsPaySlip);
                                }
                                else
                                {
                                    MessageBox.Show("Salary not paid", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Messages.NoPrivillageMessage();
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "PS3:" + ex.Message;
            }
        }
        /// <summary>
        /// Function to generate the voucher number as per settings
        /// </summary>
        public void voucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFill obj = new TransactionsGeneralFill();
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                //-----------------------------------------Voucher number Automatic generation ------------------------------------------------//
                if (strVoucherNo == string.Empty)
                {

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

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

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void FillFunction()
        {
            try
            {
                SalaryVoucherMasterSP SpMaster = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeSP spVoucherType = new VoucherTypeSP();

                InfoMaster = SpMaster.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 = spVoucherType.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
            {
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo();
                SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP();
                SalaryVoucherDetailsInfo infoDetails = new SalaryVoucherDetailsInfo();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();

                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());
                        spDetails.SalaryVoucherDetailsDelete(SalaryVoucherDetailsId);
                        spMaster.SalaryVoucherMasterEdit(infoMaster);

                        LedgerUpdate();

                    }

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

                        LedgerUpdate();
                    }
                    if (dgvMonthlySalary.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvMonthlySalary.Rows[i].Cells["txtMasterId"].Value.ToString() == "0")
                    {
                        spMaster.SalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();
                    }
                }
                if (spDetails.SalaryVoucherDetailsCount(decIsEditModeMasterId) == 0)
                {
                    spMaster.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 for Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo infoMaster = new SalaryVoucherMasterInfo();
                SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP();
                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 (spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) != "0")
                    {
                        strEployeeNames = strEployeeNames + spDetails.CheckWhetherSalaryAlreadyPaid(decVal, dtpMonth.Value) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }

                    }
                }
                if (spDetails.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 )---------------------//
                    DataTable dtbl = new DataTable();
                    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();
                    }
                    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;
                            spDetails.MonthlySalaryVoucherDetailsAdd(infoDetails);
                        }
                    }

                    Messages.SavedMessage();
                    GridFill(isEditMode);
                    Clear();
                }
                else
                {
                    Messages.InformationMessage("Can't save without atleast one employee");
                    strVoucherNo = spMaster.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call Save or Edit
        /// </summary>
        public void SaveOrEdit()
        {
            try
            {
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                cmbCashOrBankAcc.DropDownStyle = ComboBoxStyle.DropDownList;
                if (txtVoucherNo.Text == string.Empty)
                {

                    Messages.InformationMessage("Enter voucher number");

                    lblVoucherNoIndicator.Visible = true;
                    txtVoucherNo.Focus();

                }
                else if (dtpVoucherDate.Value.ToString() == string.Empty)
                {
                    Messages.InformationMessage("Select voucher date");
                    lblVoucherDateIndicator.Visible = true;
                    dtpVoucherDate.Focus();
                }
                else if (cmbCashOrBankAcc.SelectedIndex == -1)
                {

                    Messages.InformationMessage("Select cash or bank account");
                    lblCashOrBankIndicator.Visible = true;
                    cmbCashOrBankAcc.Focus();
                }
                else
                {

                    if (isEditMode == false)
                    {
                        if (PublicVariables.isMessageAdd)
                        {
                            if (Messages.SaveMessage())
                            {
                                if (!isAutomatic)
                                {
                                    if (spMaster.MonthlySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decMonthlyVoucherTypeId, 0) == false)
                                    {
                                        SaveFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                    }
                                }
                                else
                                {
                                    SaveFunction();
                                }
                            }
                        }
                        else
                        {
                            if (!isAutomatic)
                            {
                                if (spMaster.MonthlySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decMonthlyVoucherTypeId, 0) == false)
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                SaveFunction();
                            }
                        }

                    }
                    //------ Update-------------//
                    else if (isEditMode)
                    {
                        if (PublicVariables.isMessageEdit)
                        {
                            if (Messages.UpdateMessage())
                            {
                                if (!isAutomatic)
                                {
                                    if (spMaster.MonthlySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decMonthlyVoucherTypeId, decIsEditModeMasterId) == false)
                                    {
                                        EditFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                    }
                                }
                                else
                                {
                                    EditFunction();
                                }
                            }
                        }
                        else
                        {
                            if (!isAutomatic)
                            {
                                if (spMaster.MonthlySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decMonthlyVoucherTypeId, decIsEditModeMasterId) == false)
                                {
                                    EditFunction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                EditFunction();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
        /// <summary>
        /// Function for delete
        /// </summary>
        public void DeleteFunction()
        {
            try
            {
                SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                SalaryVoucherDetailsSP spDetails = new SalaryVoucherDetailsSP();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                spMaster.SalaryVoucherMasterDelete(decIsEditModeMasterId);
                spDetails.SalaryVoucherDetailsDeleteUsingMasterId(decIsEditModeMasterId);
                spLedgerPosting.LedgerPostDelete(txtVoucherNo.Text, decMonthlyVoucherTypeId);

                Messages.DeletedMessage();
                Clear();
                GridFill(isEditMode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #10
0
        /// <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();
                SalaryVoucherMasterSP SpMaster = new SalaryVoucherMasterSP();
                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                btnDelete.Enabled = true;
                btnSave.Text = "Update";
                InfoMaster = SpMaster.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 = spVoucherType.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);
            }
        }
Пример #11
0
        /// <summary>
        /// To reset the form here and Generate the voucher no generation
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFill obj = new TransactionsGeneralFill();
                if (btnSave.Text == "Update")
                {
                    if (frmPaymentRegisterObj != null)
                    {
                        frmPaymentRegisterObj.Close();
                    }
                }
                if (isAutomatic)
                {

                    SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP();
                    PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    if (Convert.ToDecimal(strVoucherNo) != SpPaymentMaster.PaymentMasterMax(decPaymentVoucherTypeId) + 1)
                    {
                        strVoucherNo = SpPaymentMaster.PaymentMasterMax(decPaymentVoucherTypeId).ToString();
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        if (SpPaymentMaster.PaymentMasterMax(decPaymentVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        }
                    }
                    SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.Text = string.Empty;
                    txtVoucherNo.ReadOnly = false;
                }
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.Value = PublicVariables._dtCurrentDate;
                cmbBankorCash.SelectedIndex = -1;
                txtNarration.Text = string.Empty;
                txtTotal.Text = string.Empty;
                dgvPaymentVoucher.ClearSelection();
                dgvPaymentVoucher.Rows.Clear();
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                cbxPrintafterSave.Checked = false;
                dtblPartyBalance.Clear();
                if (isAutomatic)
                {
                    txtDate.Select();
                }
                else
                {
                    txtVoucherNo.Select();
                }
                PrintCheck();

            }
            catch (Exception ex)
            {
                MessageBox.Show("PV9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #12
0
        /// <summary>
        /// Function for print
        /// </summary>
        public void Print()
        {
            try
            {
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnPrint.Text))
                {
                    if (cmbEmployee.Text == string.Empty || cmbEmployee.Text == "--Select--")
                    {
                        Messages.InformationMessage("Select an employee");
                        cmbEmployee.Focus();
                    }
                    else
                    {
                        SalaryVoucherMasterSP spSalaryVoucherMaster = new SalaryVoucherMasterSP();
                        DateTime dtMon = DateTime.Parse(dtpSalaryMonth.Text);
                        DateTime dtSalaryMonth = new DateTime(dtMon.Year, dtMon.Month, 1);
                        decimal decEmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                        DataSet dsPaySlip = spSalaryVoucherMaster.PaySlipPrinting(decEmployeeId, dtSalaryMonth, 1);

                        foreach (DataTable dtbl in dsPaySlip.Tables)
                        {
                            if (dtbl.TableName == "Table1")
                            {
                                if (dtbl.Rows.Count > 0)
                                {
                                    frmReport frmReport = new frmReport();
                                    frmReport.MdiParent = formMDI.MDIObj;
                                    frmReport.PaySlipPrinting(dsPaySlip);
                                }
                                else
                                {
                                    MessageBox.Show("Salary not paid", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Messages.NoPrivillageMessage();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PS 3: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }