private void btnSaveInvoice_Click(object sender, EventArgs e)
        {
            PO po = new PO(_orderID);
            if (dxValidation.Validate())
            {
                ReceiptInvoice invoice = new ReceiptInvoice();
                if (_receiptInvoiceID != 0)
                {
                    invoice.LoadByPrimaryKey(_receiptInvoiceID);

                }
                else
                {
                    invoice.AddNew();
                }
                //TODO: save the Invoice Type Here.
                invoice.InvoiceTypeID = 1;
                invoice.InsurancePolicyNo = txtInsurance.Text;
                double TotalValue = 0;
                if (!invoice.IsColumnNull("TotalValue"))
                {
                    TotalValue = invoice.TotalValue;
                }
                if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue)
                    && POType.GetModes(po.PurchaseType) == POType.STANDARD)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD &&
                    _receiptInvoiceID == 0)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }

                invoice.WayBillNo = txtWayBill.Text;
                invoice.TransitTransferNo = txtTransitNumber.Text;
                invoice.STVOrInvoiceNo = txtInvoiceNumber.Text;
                invoice.POID = _orderID;
                invoice.SavedByUserID = CurrentContext.UserId;
                invoice.AirFreight = Convert.ToDouble(txtInvoiceAirFreight.EditValue);
                invoice.SeaFreight = Convert.ToDouble(txtInvoiceSeaFreight.EditValue);
                invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue);
                invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue);
                invoice.CBE = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue);
                invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue);
                invoice.DateOfEntry = Convert.ToDateTime(dtInvoiceDate.EditValue);
                invoice.ExchangeRate = Convert.ToDouble(txtExchangeRate.EditValue);
                invoice.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue);
                invoice.ActivityID = po.StoreID;
                invoice.Rowguid = Guid.NewGuid();
                invoice.PrintedDate = dtInvoiceDate.DateTime;
                invoice.IsVoided = false ;
                invoice.ShippingSite = " ";
                invoice.IsConvertedFromDeliveryNote = false;
                invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN;
                if (Convert.ToInt32(lkDocumentType.EditValue) != -1)
                    invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue);
                invoice.Save();
                this.LogActivity("Save-Invoice", invoice.ID);

                lblInvoiceNoDetail.Text = txtInvoiceNumber.EditValue.ToString();
                lblInvoiceTypeDetail.Text = lkInvoiceType.Text;

                BLL.Receipt receipt = new BLL.Receipt();
                receipt.UpdateInvoiceRelatedHeaders(invoice);
                _receiptInvoiceID = invoice.ID;
                MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString();
            }
        }
示例#2
0
        private void btnSaveInvoice_Click(object sender, EventArgs e)
        {
            PO po = new PO(_orderID);

            if (dxValidation.Validate())
            {
                ReceiptInvoice invoice = new ReceiptInvoice();
                if (_receiptInvoiceID != 0)
                {
                    invoice.LoadByPrimaryKey(_receiptInvoiceID);
                }
                else
                {
                    invoice.AddNew();
                }
                //TODO: save the Invoice Type Here.
                invoice.InvoiceTypeID     = 1;
                invoice.InsurancePolicyNo = txtInsurance.Text;
                double TotalValue = 0;
                if (!invoice.IsColumnNull("TotalValue"))
                {
                    TotalValue = invoice.TotalValue;
                }
                if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue) &&
                    POType.GetModes(po.PurchaseType) == POType.STANDARD)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD &&
                    _receiptInvoiceID == 0)
                {
                    XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value",
                                        MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }

                invoice.WayBillNo         = txtWayBill.Text;
                invoice.TransitTransferNo = txtTransitNumber.Text;
                invoice.STVOrInvoiceNo    = txtInvoiceNumber.Text;
                invoice.POID          = _orderID;
                invoice.SavedByUserID = CurrentContext.UserId;
                invoice.AirFreight    = Convert.ToDouble(txtInvoiceAirFreight.EditValue);
                invoice.SeaFreight    = Convert.ToDouble(txtInvoiceSeaFreight.EditValue);
                invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue);
                invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue);
                invoice.CBE           = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue);
                invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue);
                invoice.DateOfEntry   = Convert.ToDateTime(dtInvoiceDate.EditValue);
                invoice.ExchangeRate  = Convert.ToDouble(txtExchangeRate.EditValue);
                invoice.LCID          = Convert.ToInt32(lkCurrencyLCID.EditValue);
                invoice.ActivityID    = po.StoreID;
                invoice.Rowguid       = Guid.NewGuid();
                invoice.PrintedDate   = dtInvoiceDate.DateTime;
                invoice.IsVoided      = false;
                invoice.ShippingSite  = " ";
                invoice.IsConvertedFromDeliveryNote = false;
                invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN;
                if (Convert.ToInt32(lkDocumentType.EditValue) != -1)
                {
                    invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue);
                }
                invoice.Save();
                this.LogActivity("Save-Invoice", invoice.ID);

                lblInvoiceNoDetail.Text   = txtInvoiceNumber.EditValue.ToString();
                lblInvoiceTypeDetail.Text = lkInvoiceType.Text;

                BLL.Receipt receipt = new BLL.Receipt();
                receipt.UpdateInvoiceRelatedHeaders(invoice);
                _receiptInvoiceID = invoice.ID;
                MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString();
            }
        }