Exemplo n.º 1
0
        private void Cmb_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cmb = (ComboBox)sender;

            if (cmb.Text == "Receive Payment")
            {
                string         billNo            = dgvBills.CurrentRow.Cells["InvoiceNo"].Value.ToString();
                string         customer          = dgvBills.CurrentRow.Cells["Buyer"].Value.ToString();
                ReceiptVoucher frmReceiptVoucher = new ReceiptVoucher(billNo, customer);
                frmReceiptVoucher.OnClose += GenerateBillingList;
                frmReceiptVoucher.ShowDialog();
            }
            else if (cmb.Text == "Original for Recipient")
            {
                string billNo    = dgvBills.CurrentRow.Cells["InvoiceNo"].Value.ToString();
                string suppliers = dgvBills.CurrentRow.Cells["Buyer"].Value.ToString();
                InvoiceReportViewer frmInvoiceReportViewer = new InvoiceReportViewer(InvoiceReportViewer._InvoiceCopy.Original, billNo);
                frmInvoiceReportViewer.OnClose += GenerateBillingList;
                frmInvoiceReportViewer.ShowDialog();
            }
            else if (cmb.Text == "Duplicate for Transporter")
            {
                string billNo    = dgvBills.CurrentRow.Cells["InvoiceNo"].Value.ToString();
                string suppliers = dgvBills.CurrentRow.Cells["Buyer"].Value.ToString();
                InvoiceReportViewer frmInvoiceReportViewer = new InvoiceReportViewer(InvoiceReportViewer._InvoiceCopy.Duplicate, billNo);
                frmInvoiceReportViewer.OnClose += GenerateBillingList;
                frmInvoiceReportViewer.ShowDialog();
            }
            else if (cmb.Text == "Triplicate for Supplier")
            {
                string billNo    = dgvBills.CurrentRow.Cells["InvoiceNo"].Value.ToString();
                string suppliers = dgvBills.CurrentRow.Cells["Buyer"].Value.ToString();
                InvoiceReportViewer frmInvoiceReportViewer = new InvoiceReportViewer(InvoiceReportViewer._InvoiceCopy.Triplicate, billNo);
                frmInvoiceReportViewer.OnClose += GenerateBillingList;
                frmInvoiceReportViewer.ShowDialog();
            }
            else if (cmb.Text == "Credit Note")
            {
                string          invoiceNo      = dgvBills.CurrentRow.Cells["InvoiceNo"].Value.ToString();
                CreditNoteIssue creditnoteissu = new CreditNoteIssue(CreditNoteIssue._NoteType.Credit_Note, invoiceNo);
                creditnoteissu.OnClose += GenerateBillingList;
                creditnoteissu.ShowDialog();
            }
            else if (cmb.Text == "Cancel")
            {
                if (UserTools._IsCancel)
                {
                    string         invoiceno     = dgvBills.CurrentRow.Cells["invoiceno"].Value.ToString();
                    string         status        = dgvBills.CurrentRow.Cells["STATUS"].Value.ToString();
                    Invoice_Direct invoicedirect = new Invoice_Direct(invoiceno, status, "");
                    invoicedirect.InvoiceCancel();
                    GenerateBillingList();
                }
                else
                {
                    MessageBox.Show("Cancel permission denied by Admin", "Permission", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    GenerateBillingList();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Data Save
        /// </summary>
        private void SaveInvoice()
        {
            mlistQuery.Clear();
            #region data
            string receivableheadid = AccountHeadTools._ReceivableAccountHeadId;
            string salesheadid      = AccountHeadTools._SalesLedgerId;

            string invoiceNo    = lblInvoiceNo.Text.GetDBFormatString();
            string invoiceDate  = dtpInvoiceDate.Text;
            string billingTerms = cmbBillingTerms.Text;
            string dueDate      = dtpDueDate.Text;

            string billingTo        = lblNameBilling.Text;
            string billingAddress   = lblBillingAddress.Text;
            string billingGSTIN     = lblGSTIn.Text;
            string billingState     = lblStateNameBilling.Text;
            string billingStateCode = lblStateCodeBilling.Text;

            string buyerOrderNo   = lblBuyrOrderNo.Text;
            string buyerOrderDate = lblBuyrOrderDate.Text;

            string challanNo       = lblChallanNo.Text;
            string challanDate     = lblChallanDate.Text;
            string despatchThrough = lblDespatchThrough.Text;
            string vehiclaNo       = lblVehiclaNo.Text;

            string shippingTo        = lblShippedTo.Text;
            string shippingAddress   = lblShippedAddress.Text;
            string shippingState     = lblStateNameShipping.Text;
            string shippingStateCode = lblStateCodeShipping.Text;

            string totalQty       = lblTotQuantity.Text;
            string totalAmount    = lblTotAmount.Text;
            string totalDiscount  = lblTotalDiscount.Text;
            string totalTaxAmount = lblTaxableAmountTotal.Text;
            string totalCGST      = lblTotalCGST.Text;
            string totalSGST      = lblTotalSGST.Text;
            string totalIGST      = lblTotalIGST.Text;
            string totalCess      = lblTotalCESS.Text;
            string totalNet       = lblTotalWithTax.Text;

            double totalInvoiceAmount = 0d, freightCharges = 0d, pachingCharges = 0d, otherCharges = 0d, overAllDiscount = 0d;
            double.TryParse(lblTotalInvoiceAmount.Text, out totalInvoiceAmount);
            double.TryParse(txtFreightCharges.Text, out freightCharges);
            double.TryParse(txtPackingCharges.Text, out pachingCharges);
            double.TryParse(txtOtherCharges.Text, out otherCharges);
            double.TryParse(txtDiscount.Text, out overAllDiscount);
            string note  = "";

            string rcm   = (ORG_Tools._GSTtype == "Regular") ? "NO" : "YES";
            #endregion
            string query = "Insert into invoice( SlNo, InvoiceNo, InvoiceDate, LedgerId, BillingTerms, DueDate, " +
                           "BillingTo, BillingAddress, BillingGSTNO, BillingState, BillingStateCode, BuyerOrderNo, " +
                           "BuyerOrderDate, ChallanNo, ChallanDate, DispatchThrough, VehiclaNo, ShippingTo, " +
                           "ShippingAddress, ShippingState, ShippingStateCode, TotalQty, TotalAmount, TotalDiscount, " +
                           "TotalTaxAmount, TotalCGST, TotalSGST, TotalIGST, TotalCess, NetAmount, FreightChargs, " +
                           "PackingCharges, OtherCharges, OverAllDiscount, TotalInvoiceAmount,Note,RCM,InvoiceType) " +
                           "values(" + mInvoiceSlNo + ",'" + invoiceNo + "','" + invoiceDate + "','" +
                           mCustomerLadgerID + "','" + billingTerms + "','" + dueDate + "','" + billingTo + "','" +
                           billingAddress + "','" + billingGSTIN + "','" + billingState + "','" + billingStateCode
                           + "','" + buyerOrderNo + "','" + buyerOrderDate + "','" + challanNo + "','" + challanDate
                           + "','" + despatchThrough + "','" + vehiclaNo + "','" + shippingTo + "','" + shippingAddress
                           + "','" + shippingState + "','" + shippingStateCode + "'," + totalQty + "," + totalAmount
                           + "," + totalDiscount + "," + totalTaxAmount + "," + totalCGST + "," + totalSGST + "," + totalIGST + "," +
                           totalCess + "," + totalNet + "," + freightCharges + "," + pachingCharges + "," + otherCharges + "," +
                           overAllDiscount + "," + totalInvoiceAmount + ",'" + note + "','" + rcm + "','" + mInvoiceType + "')";
            mlistQuery.Add(query);

            string transectionid = Guid.NewGuid().ToString();

            query = "Insert into Transection(TransectionID,LedgerID,AccountHeadIdTo,Date,TransectionType,Amount, " +
                    "DueDate,VoucherNo,Balance,Status) values('" + transectionid + "','" + mCustomerLadgerID + "','" + receivableheadid + "','" + invoiceDate + "','Invoice'," + mTotalInvoiceAmount + ",'" + dueDate + "','" + invoiceNo + "'," + mTotalAmount + ",'Open')";
            mlistQuery.Add(query);
            SaveInvoiceDetails(invoiceNo, transectionid);
            switch (mInvoiceFrom)
            {
            case _Invoicefrom.Order:
                break;

            case _Invoicefrom.Challan:
                UpdateChallan();
                break;

            default:
                break;
            }
            if (SQLHelper.GetInstance().ExecuteTransection(mlistQuery, out msg))
            {
                if (MessageBox.Show("Invoice saved.\nDo you want to print now ?", "Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    InvoiceReportViewer frmInvoiceReportViewer = new InvoiceReportViewer(InvoiceReportViewer._InvoiceCopy.Original, lblInvoiceNo.Text);
                    frmInvoiceReportViewer.OnClose += FrmInvoiceReportViewer_OnClose;
                    frmInvoiceReportViewer.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show(msg);
            }
        }