Example #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (!verifyAndReworkVoucherDetailGridRows())
                {
                    MessageBox.Show("Validation Failed for Purhcase journal Detail");
                    return;
                }

                if (JVdocID == "PJV")
                {
                    PJVHeader pjvh = new PJVHeader();
                    pjvh.TemporaryNo   = Convert.ToInt32(txtTemporarryNo.Text);
                    pjvh.TemporaryDate = dtTempDate.Value;
                    pjvh.DocumentID    = JVdocID;
                    List <PJVDetail> PJVList = getVoucherDetails(pjvh);
                    if (Convert.ToDecimal(txtTotalCreditAmnt.Text) != Convert.ToDecimal(txtTotalDebitAmnt.Text))
                    {
                        MessageBox.Show("Debit and Credit total should be equal.");
                        return;
                    }
                    if (InvAmount != Convert.ToDouble(txtTotalCreditAmnt.Text))
                    {
                        MessageBox.Show("Journal amount should be equal to invoice amount.");
                        return;
                    }
                    if (PJVDB.UpdatePJVHeaderDetailDuringApproveInvoiceIN(PJVList, pjvh))
                    {
                        MessageBox.Show("Purchase journal updated.");
                    }
                }
                else if (JVdocID == "SJV")
                {
                    SJVHeader sjvh = new SJVHeader();
                    sjvh.TemporaryNo   = Convert.ToInt32(txtTemporarryNo.Text);
                    sjvh.TemporaryDate = dtTempDate.Value;
                    sjvh.DocumentID    = JVdocID;
                    List <SJVDetail> SJVList = getSalesVoucherDetails(sjvh);
                    if (Convert.ToDecimal(txtTotalCreditAmnt.Text) != Convert.ToDecimal(txtTotalDebitAmnt.Text))
                    {
                        MessageBox.Show("Debit and Credit total should be equal.");
                        return;
                    }
                    if (InvAmount != Convert.ToDouble(txtTotalCreditAmnt.Text))
                    {
                        MessageBox.Show("Journal amount should be equal to invoice amount.");
                        return;
                    }
                    if (SJVDB.UpdateSJVHeaderDetailDuringApproveInvoiceIN(SJVList, sjvh))
                    {
                        MessageBox.Show("Sales journal updated.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to update");
            }
        }
Example #2
0
        private void ShowAllDetails()
        {
            try
            {
                if (JVdocID == "PJV")
                {
                    invoiceinheader iih = new invoiceinheader();
                    iih.DocumentID    = InvDociD;
                    iih.TemporaryNo   = InvTemporaryNo;
                    iih.TemporaryDate = InvTemporaryDate;

                    PJVHeader pjvh = PJVDB.getPJVHeaderPerInvoiceIN(iih);
                    if (pjvh.TemporaryNo == 0)
                    {
                        MessageBox.Show("PJV Not prepared");
                        return;
                    }
                    txtTemporarryNo.Text = pjvh.TemporaryNo.ToString();
                    dtTempDate.Value     = pjvh.TemporaryDate;
                    txtJournalNo.Text    = pjvh.JournalNo.ToString();
                    dtJournalDate.Value  = pjvh.JournalDate;
                    txtINVTempNo.Text    = pjvh.InvTempNo.ToString();
                    dtINVTempDate.Value  = pjvh.InvTempDate;
                    txtnarration.Text    = pjvh.Narration.ToString();

                    List <PJVDetail> PJVDetail = PJVDB.getPJVDetail(pjvh);
                    grdPRDetail.Rows.Clear();
                    int     i         = 0;
                    decimal totCredit = 0;
                    decimal totDebit  = 0;
                    foreach (PJVDetail vd in PJVDetail)
                    {
                        AddPRDetailRow();
                        grdPRDetail.Rows[i].Cells["AccountCode"].Value = vd.AccountCode;
                        grdPRDetail.Rows[i].Cells["AccountName"].Value = vd.AccountName;
                        grdPRDetail.Rows[i].Cells["AmountDebit"].Value = vd.AmountDebit;
                        totDebit = totDebit + vd.AmountDebit;
                        grdPRDetail.Rows[i].Cells["AmountCredit"].Value = vd.AmountCredit;
                        totCredit = totCredit + vd.AmountCredit;

                        grdPRDetail.Rows[i].Cells["PartyCode"].Value = vd.SLCode;
                        grdPRDetail.Rows[i].Cells["PartyName"].Value = vd.SLName;
                        grdPRDetail.Rows[i].Cells["gSLType"].Value   = vd.SLType;
                        i++;
                    }
                    txtTotalCreditAmnt.Text = totCredit.ToString();
                    txtTotalDebitAmnt.Text  = totDebit.ToString();
                    txtAmountInWords.Text   = NumberToString.convert(txtTotalDebitAmnt.Text);
                }
                else if (JVdocID == "SJV")
                {
                    invoiceoutheader ioh = new invoiceoutheader();
                    ioh.DocumentID    = InvDociD;
                    ioh.TemporaryNo   = InvTemporaryNo;
                    ioh.TemporaryDate = InvTemporaryDate;

                    SJVHeader sjvh = SJVDB.getSJVHeaderPerInvoiceOut(ioh);
                    if (sjvh.TemporaryNo == 0)
                    {
                        MessageBox.Show("SJV Not prepared");
                        return;
                    }
                    txtTemporarryNo.Text = sjvh.TemporaryNo.ToString();
                    dtTempDate.Value     = sjvh.TemporaryDate;
                    txtJournalNo.Text    = sjvh.JournalNo.ToString();
                    dtJournalDate.Value  = sjvh.JournalDate;
                    txtINVTempNo.Text    = sjvh.InvTempNo.ToString();
                    dtINVTempDate.Value  = sjvh.InvTempDate;
                    txtnarration.Text    = sjvh.Narration.ToString();

                    List <SJVDetail> SJVdetail = SJVDB.getSJVDetail(sjvh);
                    grdPRDetail.Rows.Clear();
                    int     i         = 0;
                    decimal totCredit = 0;
                    decimal totDebit  = 0;
                    foreach (SJVDetail vd in SJVdetail)
                    {
                        AddPRDetailRow();
                        grdPRDetail.Rows[i].Cells["AccountCode"].Value = vd.AccountCode;
                        grdPRDetail.Rows[i].Cells["AccountName"].Value = vd.AccountName;
                        grdPRDetail.Rows[i].Cells["AmountDebit"].Value = vd.AmountDebit;
                        totDebit = totDebit + vd.AmountDebit;
                        grdPRDetail.Rows[i].Cells["AmountCredit"].Value = vd.AmountCredit;
                        totCredit = totCredit + vd.AmountCredit;

                        grdPRDetail.Rows[i].Cells["PartyCode"].Value = vd.SLCode;
                        grdPRDetail.Rows[i].Cells["PartyName"].Value = vd.SLName;
                        grdPRDetail.Rows[i].Cells["gSLType"].Value   = vd.SLType;
                        i++;
                    }
                    txtTotalCreditAmnt.Text = totCredit.ToString();
                    txtTotalDebitAmnt.Text  = totDebit.ToString();
                    txtAmountInWords.Text   = NumberToString.convert(txtTotalDebitAmnt.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in showing details");
            }
        }