コード例 #1
0
        public void SaveFunction()
        {
            try
            {
                AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP();
                AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                if (CheckAdvanceAmount())
                {
                    if (!spMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        if (!spAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                        {
                            if (isAutomatic == true)
                            {
                                infoAdvancepayment.VoucherNo = strVoucherNo;
                            }
                            else
                            {
                                infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                            infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                            infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                            infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                            infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                            if (isAutomatic)
                            {
                                infoAdvancepayment.InvoiceNo = strInvoiceNo;
                            }
                            else
                            {
                                infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                            infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                            infoAdvancepayment.Narration = txtNarration.Text.Trim();
                            infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                            infoAdvancepayment.Extra1 = string.Empty;
                            infoAdvancepayment.Extra2 = string.Empty;
                            infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                            infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                            infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                            if (btnAdvancePaymentSave.Text == "Save")
                            {
                                if (decAdvancePaymentsId != -1)
                                {
                                    DataTable dtbl = new DataTable();
                                    dtbl = spAdvancepayment.AdvancePaymentAddWithIdentity(infoAdvancepayment, isAutomatic);
                                    foreach (DataRow dr in dtbl.Rows)
                                    {
                                        decAdvancePaymentId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                                        strUpdatedVoucherNumber = dr.ItemArray[1].ToString();
                                        strUpdatedInvoiceNumber = dr.ItemArray[2].ToString();
                                    }
                                    if (!isAutomatic)
                                    {
                                        strVoucherNo = txtAdvanceVoucherNo.Text.Trim();
                                    }
                                    if (isAutomatic)
                                    {
                                        if (Convert.ToDecimal(strUpdatedVoucherNumber) != Convert.ToDecimal(strVoucherNo))
                                        {
                                            Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNumber);
                                            strVoucherNo = strUpdatedVoucherNumber.ToString();
                                            strInvoiceNo = strUpdatedInvoiceNumber;
                                        }
                                    }
                                    txtAdvanceVoucherNo.Focus();
                                }
                                LedgerPosting(Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()), decAdvancePaymentId);
                                Messages.SavedMessage();
                                Clear();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage(" Advance already paid for this month");
                            dtpSalaryMonth.Focus();
                        }
                    }
                    else
                    {
                        Messages.InformationMessage("Cant pay advance for this month,Salary already paid");
                        dtpSalaryMonth.Focus();
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("AP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        /// <summary>
        /// Function to edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalarySP spMonthlySalary = new MonthlySalarySP();
                if (!spMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                {


                    AdvancePaymentSP spAdvancepayment = new AdvancePaymentSP();
                    AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                    LedgerPostingSP spLedgerPosting = new LedgerPostingSP();

                    if (spAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        txtAmount.ReadOnly = true;
                    }


                    infoAdvancepayment.AdvancePaymentId = (Convert.ToDecimal(decAdvancePaymentEditId.ToString()));
                    infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                    infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                    infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                    infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                    infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                    if (CheckAdvanceAmount())
                    {
                        if (isAutomatic)
                        {
                            infoAdvancepayment.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        if (isAutomatic)
                        {
                            infoAdvancepayment.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                        infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                        infoAdvancepayment.Narration = txtNarration.Text.Trim();
                        infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                        infoAdvancepayment.Extra1 = string.Empty;
                        infoAdvancepayment.Extra2 = string.Empty;
                        infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                        infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                        infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        spAdvancepayment.AdvancePaymentEdit(infoAdvancepayment);
                        LedgerUpdate();
                        Messages.UpdatedMessage();
                        txtAdvanceVoucherNo.Focus();
                        this.Close();
                    }
                }
                else
                {
                    Messages.ReferenceExistsMessageForUpdate();
                    dtpSalaryMonth.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }