/// <summary>
        /// Adds the new receipt.
        /// </summary>
        /// <param name="receiptTypeID">The receipt type ID.</param>
        /// <param name="userID">The user ID.</param>
        /// <param name="receiptInvoiceID">The receipt invoice ID.</param>
        /// /// <param name="receiptStatusID">The receipt confirmation status ID.</param>
        /// <returns></returns>
        public int AddNewReceipt(int receiptTypeID, int warehouseID, int userID, int receiptInvoiceID, string txtTransitTransferVoucherNoOverride, int receiptStatusID) //, string transitTransferNo, string insurancePolicyNo, string wayBillNo)
        {
            this.AddNew();
            this.DateOfEntry      = DateTimeHelper.ServerDateTime;
            this.ReceiptTypeID    = receiptTypeID;
            this.SavedByUserID    = userID;
            this.WarehouseID      = warehouseID;
            this.ReceiptInvoiceID = receiptInvoiceID;
            this.ReceiptStatusID  = receiptStatusID;

            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.LoadByPrimaryKey(receiptInvoiceID);

            this.STVOrInvoiceNo = rctInvoice.STVOrInvoiceNo;
            if (string.IsNullOrEmpty(txtTransitTransferVoucherNoOverride))
            {
                this.TransitTransferNo = rctInvoice.TransitTransferNo;
            }
            else
            {
                this.TransitTransferNo = txtTransitTransferVoucherNoOverride;
            }
            this.InsurancePolicyNo = rctInvoice.InsurancePolicyNo;
            this.WayBillNo         = rctInvoice.WayBillNo;
            this.Save();
            return(this.ID);
        }
 public void LoadByReceiptID(int receiptID)
 {
     BLL.Receipt rct = new Receipt();
     rct.LoadByPrimaryKey(receiptID);
     BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
     rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID);
     this.LoadByPrimaryKey(rctInvoice.POID);
 }
 private void btnInvoice_Click(object sender, EventArgs e)
 {
     BLL.Receipt GRV = new BLL.Receipt();
     GRV.LoadByPrimaryKey(ReceiptID);
     ReceiptInvoice invoice = new ReceiptInvoice();
     invoice.LoadByPrimaryKey(GRV.ReceiptInvoiceID);
     ReceiptInvoiceDialog InvoiceDialog = new ReceiptInvoiceDialog(invoice.POID, invoice.ID);
     InvoiceDialog.ShowDialog();
     LoadSelectedGRVDetailForCostBuildUp(ReceiptID);
 }
Exemple #4
0
        public void LoadCostBuilUp(bool AutoProrate, string GRNFString)
        {
            //ToDo: Remove the Setting Before Implementation
            _CostBuildup = new CostBuildup();
            ReceiptInvoice invoice = new ReceiptInvoice();

            invoice.LoadByPrimaryKey(GRV.ReceiptInvoiceID);
            _CostBuildup.UseTransitServiceCharge = false;
            _CostBuildup.AutoProrate             = AutoProrate;
            _CostBuildup.LoadByReceiptIDInvoiceIDAndPoID(ReceiptID, invoice.ID, invoice.POID, GRNFString, _SubTotal);
        }
Exemple #5
0
 public static void DeleteList(List <int> list)
 {
     BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
     foreach (int v in list)
     {
         // try to load by primary key
         bv.LoadByPrimaryKey(v);
         // if the entry doesn't exist, create it
         if (bv.RowCount > 0)
         {
             bv.MarkAsDeleted();
             bv.Save();
         }
         // populate the contents of v on the to the database list
     }
 }
Exemple #6
0
        public void SaveAirFreight(double Freight)
        {
            ReceiptInvoice receiptInvoice = new ReceiptInvoice();

            receiptInvoice.LoadByPrimaryKey(GRV.ReceiptInvoiceID);
            if (receiptInvoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {
                _Freight       = Freight;
                GRV.SeaFreight = _Freight;
            }
            else if (receiptInvoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_AIR)
            {
                _Freight       = Freight;
                GRV.AirFreight = _Freight;
            }
            GRV.Save();
            LoadGRV(GRV.ID);
        }
        private void PrintReceiptConfirmation(string referenceNumber, int? reprintOfReceiptConfirmationPrintoutID)
        {
            var rc = new ReceiptConfirmationPrintout();
            var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName);

            int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
            var receiveDoc = new ReceiveDoc();
            receiveDoc.LoadByReceiptID(ReceiptID);
            ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID);
            srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName;
            rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 3, null,
                                                  reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
            srmPrintout.DataSource = rc.DefaultView.ToTable();

            var rUnit = new Institution();
            var idoc = new IssueDoc();
            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID);
                rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID);
            }
            else
            {
                var po = new PO();
                po.LoadByReceiptID(receiveDoc.ReceiptID);
                rUnit.LoadByPrimaryKey(int.Parse(po.RefNo));
            }

            srmPrintout.xrFromValue.Text = rUnit.Name;
            srmPrintout.xrWoredaValue.Text = rUnit.WoredaText;
            srmPrintout.xrRegionValue.Text = rUnit.Region;
            srmPrintout.xrZoneValue.Text = rUnit.ZoneText;

            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                var stvLog = new BLL.Issue();
                stvLog.LoadByPrimaryKey(idoc.STVID);

                srmPrintout.xrIssueDateValue.Text = idoc.Date.ToString("M/d/yyyy");
                var activity = new Activity();
                activity.LoadByPrimaryKey(idoc.StoreId);
                 srmPrintout.xrAccountName.Text = activity.FullActivityName;
                var rct = new BLL.Receipt();
                rct.LoadByPrimaryKey(ReceiptID);
                var rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID);
                srmPrintout.xrSTVNoValue.Text = rctInvoice.STVOrInvoiceNo;
            }
            else
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(receiveDoc.StoreID);
                srmPrintout.xrAccountName.Text = activity.FullActivityName;
                srmPrintout.xrSTVNoValue.Text = receiveDoc.RefNo;
            }

            var dtDate = new DateTimePickerEx();
            dtDate.Value = receiveDoc.EurDate;
            srmPrintout.Date.Text = dtDate.Text;
            if (srmPrintout.PrintDialog() != DialogResult.OK)
            {
                throw new Exception("Print cancelled by user!");
            }

            //Successfully printed

            //Release Product
            var GRV = new CostCalculator();
            GRV.LoadGRV(ReceiptID);
            GRV.ReleaseForIssue();

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();
            var recDoc = new ReceiveDoc();
            recDoc.LoadByReferenceNo(reference);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");
            BindFormContents();
        }
 private void btnSTV_Click(object sender, EventArgs e)
 {
     BLL.Receipt receipt = new BLL.Receipt();
     receipt.LoadByPrimaryKey(ReceiptID);
     receipt.STVOrInvoiceNo = txtSTVNo.EditValue.ToString();
     receipt.Save();
     ReceiptInvoice invoice = new ReceiptInvoice();
     invoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
     invoice.STVOrInvoiceNo = txtSTVNo.EditValue.ToString();
     invoice.Save();
     this.LogActivity("Set-New-STV-No", ReceiptID);
     XtraMessageBox.Show("STV Number has been saved");
 }
        private void LoadItemsFromTransferredReceiptInvoiceDetail(int receiptInvoiceID)
        {
            BLL.ReceiptInvoice receiptInvoice = new ReceiptInvoice();
            receiptInvoice.LoadByPrimaryKey(receiptInvoiceID);
            if (receiptInvoice.RowCount == 0)
            {
                XtraMessageBox.Show("Invalid STV/Invoice number!", "Error");
                return;
            }

            DataTable tbl = BLL.Item.GetItemsByReceiptInvoiceNoForSTVTransfer(receiptInvoice.ID);

            _dtSelectedTable = tbl.Clone();
            gridSelected.DataSource = _dtSelectedTable;

            foreach (DataRow dr in tbl.Rows)
            {
                SelectAnItem(dr);
            }
        }
        private void lkReceiptInvoice_EditValueChanged(object sender, EventArgs e)
        {
            ResetFields();

            if (lkReceiptInvoice.EditValue != null)
            {
                if ((standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic) && lkReceiptInvoice.EditValue.Equals(-1))
                {
                    HandleReceiptTypeChange(true);
                    return;
                }

                if (standardRecType == StandardReceiptType.iGRV && !lkReceiptInvoice.EditValue.Equals(-1))
                {
                    //This means, the hub has chosen an invoice other than "Not Found" from the list of invoices.  Therefore, we want to change the receipt type to be iGRV-Online.
                    HandleReceiptTypeChange();
                }

                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(Convert.ToInt32(lkReceiptInvoice.EditValue));
                var po = new PO();
                po.LoadByPrimaryKey(rctInvoice.POID);

                if (po.IsElectronic == true)
                {
                    rdIsElectronic.Checked = true;
                    lblSyncDate.Text = rctInvoice.DateOfEntry.ToShortDateString();
                    txtPassCode.Enabled = true;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }
                else
                {
                    rdIsElectronic.Checked = false;
                    lblSyncDate.Text = "-";
                    txtPassCode.Enabled = false;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                lblOrderNo.Text = po.PONumber;
                lblOrderNum.Text = po.PONumber;

                if (!rctInvoice.IsColumnNull("DocumentTypeID"))
                {
                    var doctype = new BLL.DocumentType();
                    doctype.LoadByPrimaryKey(rctInvoice.DocumentTypeID);
                    lblDeliveryNote.Text = doctype.Name;
                    lblHeaderDoc.Text = doctype.Name;
                }
                else
                {
                    lblDeliveryNote.Text = "-";
                    lblHeaderDoc.Text = "-";
                }

                var mode = new Mode();
                mode.LoadByPrimaryKey(po.ModeID);
                lblMode.Text = mode.TypeName;
                lblAccount.Text = "-";
                lblSubAccount.Text = "-";
                lblActivity.Text = "-";
                lblReferenceNo.Text = po.RefNo;

                var payment = new PaymentType();
                payment.LoadByPrimaryKey(po.PaymentTypeID);
                lblPaymentType.Text = payment.Name;
                lblHeaderPayment.Text = payment.Name;

                //if (po.IsColumnNull("NBE"))
                //{
                //    lblNebService.Text = Convert.ToString(po.NBE);
                //}
                //else
                //{
                //    lblNebService.Text = "-";
                //}

                if (po.Remaining != -1)
                    lblRemainingValue.Text = po.Remaining.ToString();
                else
                    lblRemainingValue.Text = "-";

                if (po.TotalValue != -1)
                    lblTotalValue.Text = po.Remaining.ToString();
                else
                    lblTotalValue.Text = "-";

                if (po.Insurance != -1)
                    lblChargeInsurance.Text = po.Insurance.ToString();
                else
                    lblChargeInsurance.Text = "-";

                if (po.NBE != -1)
                    lblNebService.Text = po.NBE.ToString();
                else
                    lblNebService.Text = "-";

                lblOrderDate.Text = po.PODate.ToShortDateString();
                lblReceiptDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                var user = new User();
                user.LoadByPrimaryKey(po.SavedbyUserID);
                lblOrderBy.Text =  user.FullName;

                var sup = new Supplier();

                lkAccounts.EditValue = rctInvoice.ActivityID;
                var act = new Activity();
                act.LoadByPrimaryKey(rctInvoice.ActivityID);
                _supplierID = rctInvoice.GetSupplier();
                sup.LoadByPrimaryKey(_supplierID);

                lblSupplier.Text = sup.CompanyName;
                lblOrdSup.Text = sup.CompanyName;
                lblInvoiceNo.Text = rctInvoice.STVOrInvoiceNo;

                lblInvAccount.Text = act.AccountName ?? "-";
                lblInvActivity.Text = act.Name ?? "-";
                lblAct.Text = act.FullActivityName ?? "-";
                lblInvSubAccount.Text = act.SubAccountName ?? "-";
                lblInvMode.Text = act.ModeName ?? "-";
                lblInvTotalValue.Text = rctInvoice.TotalFOBValue.ToString("N");
                lblInsurancePolicy.Text = rctInvoice.InsurancePolicyNo == " "? rctInvoice.InsurancePolicyNo : "-";

                var poType = new POType();
                poType.LoadByPrimaryKey(po.PurchaseType);
                lblOrderType.Text = poType.Name ?? "-";
                lblPOType.Text = poType.Name ?? "-";

                var poStatus = new PurchaseOrderStatus();
                poStatus.LoadByPrimaryKey(po.PurchaseOrderStatusID);
                lblOrderStatus.Text = poStatus.Name ?? "-";

                var it = new InvoiceType();
                it.LoadByPrimaryKey(rctInvoice.InvoiceTypeID);
                lblInvType.Text = it.Name;
                lblInvDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                mode.LoadByPrimaryKey(rctInvoice.ActivityID);

                lblWayBillNo.Text = rctInvoice.WayBillNo;

                txtTransitTransferVoucherNo.Text = rctInvoice.TransitTransferNo;
                txtEditTransferNo.Text = rctInvoice.TransitTransferNo;

                lblInsurancePolicyNo.Text = rctInvoice.InsurancePolicyNo;
                BLL.PO order = new PO();
                order.LoadByPrimaryKey(rctInvoice.POID);
                lblRefNo.Text = order.RefNo;
                lblPoNo.Text = order.PONumber;

                DataTable relatedReceives = rctInvoice.GetRelatedReceives();

                hasPreviousReceive = false;

                if (relatedReceives.Rows.Count > 0)
                {
                    XtraMessageBox.Show(
                        "The Invoice you have selected has previous associated receives",
                        "Invoice Detail", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        colSelectedManufactuerer.Visible = true;
                        colSelectedUnit.Visible = true;
                        colSelectionLineNo.Visible = true;
                        colSelectedReceiveQty.Visible = true;
                        colSelectedInvoiceQty.Visible = true;
                        hasPreviousReceive = true;
                        gridItemsChoice.Enabled = false;
                        colRemainingQty.VisibleIndex = 9;
                        lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        _dtSelectedTable = relatedReceives.Clone();
                        gridSelected.DataSource = _dtSelectedTable;

                        foreach (DataRow dr in relatedReceives.Rows)
                        {
                            SelectAnItem(dr);
                        }
                }
                else
                {
                    hasPreviousReceive = false;
                    colSelectedManufactuerer.Visible = false;
                    colSelectedUnit.Visible = false;
                    colSelectionLineNo.Visible = false;
                    colSelectedReceiveQty.Visible = false;
                    colSelectedInvoiceQty.Visible = false;
                    colRemainingQty.Visible = false;
                    gridItemsChoice.Enabled = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }

                if (lkAccounts.EditValue != null)
                {
                  //  lcInvoiceDetail.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                if (standardRecType == StandardReceiptType.iGRVOnline || standardRecType == StandardReceiptType.GRV || deliveryNoteType == DeliveryNoteType.Automatic)
                {
                    if (!hasPreviousReceive) LoadItemsFromTransferredReceiptInvoiceDetail(rctInvoice.ID);
                    txtRefNo.Text = lkReceiptInvoice.Text;
                    colSelectedReceiveQty.Visible = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    lkAccounts.Enabled = false;
                }
                else
                {
                    lkAccounts.Enabled = !BLL.Settings.IsCenter;
                }

                if(!BLL.Settings.IsCenter)
                {  //Passcode Textbox
                    var dataRowView = lkReceiptInvoice.GetSelectedDataRow() as DataRowView;
                    if (dataRowView != null)
                        _isElectronic = Convert.ToBoolean(dataRowView["IsElectronic"]);

                    lcPassCode.Visibility = (!_isNonElectronicReceiveOnly) && (_isElectronic) && (standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic)
                                            ? LayoutVisibility.Always
                                            : LayoutVisibility.Never;
                    txtPassCode.Text = "HHMM";
                }

            }
        }
 private void lblWaybill_MouseEnter(object sender, EventArgs e)
 {
     if (lkReceiptInvoice.EditValue != null)
     {
         var receiptInvoice = new ReceiptInvoice();
         receiptInvoice.LoadByPrimaryKey((int)lkReceiptInvoice.EditValue);
         ShowTooltip(receiptInvoice.PrintedDate.ToString());
     }
 }
 public void LoadCostBuilUp(bool AutoProrate,string GRNFString)
 {
     //ToDo: Remove the Setting Before Implementation
     _CostBuildup = new CostBuildup();
     ReceiptInvoice invoice = new ReceiptInvoice();
     invoice.LoadByPrimaryKey(GRV.ReceiptInvoiceID);
     _CostBuildup.UseTransitServiceCharge = false;
         _CostBuildup.AutoProrate = AutoProrate;
     _CostBuildup.LoadByReceiptIDInvoiceIDAndPoID(ReceiptID, invoice.ID, invoice.POID, GRNFString,_SubTotal);
 }
Exemple #13
0
        private void LoadData(int ReceiptID, int InvoiceID, int PoID)
        {
            //PO Cost Elements;
            purchaseOrder.LoadByPrimaryKey(PoID);
            Invoice.LoadByPrimaryKey(InvoiceID);
            GRV.LoadByPrimaryKey(ReceiptID);

            if (Invoice.IsColumnNull("InvoiceTypeID"))
            {
                Invoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.NON_STANDARD;
            }
            if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {
                UseSeaFreight = true;
            }
            else
            {
                UseSeaFreight = false;
            }

            if (!purchaseOrder.IsColumnNull("TotalValue"))
            {
                PurchaseOrderTotal = purchaseOrder.TotalValue;
            }
            if (!purchaseOrder.IsColumnNull("AirFreight"))
            {
                PurchaseOrderAirFreight = purchaseOrder.AirFreight;
            }
            if (!purchaseOrder.IsColumnNull("SeaFreight"))
            {
                PurchaseOrderSeaFreight = purchaseOrder.SeaFreight;
            }
            if (!purchaseOrder.IsColumnNull("Insurance"))
            {
                PurchaseOrderInsurance = purchaseOrder.Insurance;
            }
            if (!purchaseOrder.IsColumnNull("NBE"))
            {
                PurcahseOrderNBE = purchaseOrder.NBE;
            }

            //Invoice Cost Elements;
            if (!Invoice.IsColumnNull("TotalValue"))
            {
                InvoiceTotal = Invoice.TotalValue;
            }
            if (!Invoice.IsColumnNull("AirFreight"))
            {
                InvoiceAirFreight = Invoice.AirFreight;
            }
            if (!Invoice.IsColumnNull("SeaFreight"))
            {
                InvoiceSeaFreight = Invoice.SeaFreight;
            }
            if (!Invoice.IsColumnNull("InlandFreight"))
            {
                InvoiceInlandFreight = Invoice.InlandFreight;
            }
            if (!Invoice.IsColumnNull("Insurance"))
            {
                InvoiceInsurance = Invoice.Insurance;
            }
            if (!Invoice.IsColumnNull("NBE"))
            {
                InvoiceNBE = Invoice.NBE;
            }
            if (!Invoice.IsColumnNull("CBE"))
            {
                InvoiceCBE = Invoice.CBE;
            }
            if (!Invoice.IsColumnNull("CustomDutyTax"))
            {
                InvoiceCustomDutyTax = Invoice.CustomDutyTax;
            }


            //GRV Cost Elements



            if (UseSeaFreight)
            {
                if (!GRV.IsColumnNull("SeaFreight"))
                {
                    GRVSeaFreight = GRV.SeaFreight;
                }
            }
            else
            {
                if (!GRV.IsColumnNull("AirFreight"))
                {
                    GRVAirFreight = GRV.AirFreight;
                }
            }

            if (!GRV.IsColumnNull("InlandFreight"))
            {
                GRVInlandFreight = GRV.InlandFreight;
            }

            if (!GRV.IsColumnNull("Insurance"))
            {
                GRVInsurance = GRV.Insurance;
            }

            if (!GRV.IsColumnNull("NBE"))
            {
                GRVNBE = GRV.NBE;
            }

            if (!GRV.IsColumnNull("CBE"))
            {
                GRVCBE = GRV.CBE;
            }

            if (!GRV.IsColumnNull("CustomDutyTax"))
            {
                GRVCustomDutyTax = GRV.CustomDutyTax;
            }

            if (!GRV.IsColumnNull("TransitServiceCharge"))
            {
                GRVTransit = GRV.TransitServiceCharge;
            }
            else
            {
                GRVTransit = UseTransitServiceCharge ? 250 : 0;
            }

            //if (!GRV.IsColumnNull("OtherExpenses"))
            //  GRVOtherExpense = GRV;

            //Exchange rate
            if (!purchaseOrder.IsColumnNull("ExhangeRate"))
            {
                FOBExchangeRate = purchaseOrder.ExhangeRate;
            }
            if (!Invoice.IsColumnNull("ExchangeRate"))
            {
                FreightExchangeRate = Invoice.ExchangeRate;
            }
        }
        private HCMIS.Desktop.Reports.ReceiptConfirmationPrintout PrintReceiptConfirmation(int ReceiptID, int? reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);

            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            var activity = new Activity();
            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            BLL.Receipt receipt=new BLL.Receipt();
            receipt.LoadByPrimaryKey(receiveDoc.ReceiptID);
            BLL.ReceiptInvoice receiptInvoice= new ReceiptInvoice();
            receiptInvoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
            BLL.PO po = new PO();
            po.LoadByPrimaryKey(receiptInvoice.POID);
            BLL.POType poType = new POType();
            poType.LoadByPrimaryKey(po.PurchaseType);

            int printedID = 0;
            string GRNFNo = FiscalYear.Current.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID));
            if (currentMode == Modes.GRVPrinting) //The GRVConfirmation is for reprinting
            {
                printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (poType.PurchaseOrderTypeCode == "LP") printout.xrGRVLabel.Text = "GRV No.";
                else printout.xrGRVLabel.Text = "iGRV No.";

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    //printout.xrGRVLabel.Text =  "iGRV No.";
                    printout.xrAir.Visible = false;
                    printout.xrAirValue.Visible = false;
                    printout.xrTransit.Visible = false;
                    printout.xrTransitValue.Visible = false;
                    printout.xrInsurance.Visible = false;
                    printout.xrInsuranceValue.Visible = false;
                    printout.xrNumberOfCases.Visible = false;
                    printout.xrNumberOfCasesValue.Visible = false;
                    printout.xrInvoiceNo.Text = "STV No.";
                    printout.xrPurchaseOrderNo.Visible = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 4,
                                                                    null,reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.DataSource = rc.DefaultView.ToTable();
                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                   // printout.xrGRVLabel.Text = "GRV No.";
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 2,
                                                                    null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource = rc.DefaultView.ToTable();

                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
            }

            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(ReceiptID, printedID);
                if (currentMode == Modes.GRVPrinting)
                    PrepareGRVPrintout(printoutShortage);
                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }

            //Release Product
            CostCalculator GRV = new CostCalculator();
            GRV.LoadGRV(ReceiptID);

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReceiptID(ReceiptID);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");

            BindFormContents();
            // LOG Cost Analysis printout in PDF Log
            MemoryStream stream = new MemoryStream();
            printout.ExportToPdf(stream);
            HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "GRV/IGRV", true, ReceiptID, CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime);
            return printout;
        }
        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();
            }
        }
        public static void DeleteList(List<int> list)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (int v in list)
            {
                // try to load by primary key
                bv.LoadByPrimaryKey(v);
                // if the entry doesn't exist, create it
                if (bv.RowCount > 0)
                {
                    bv.MarkAsDeleted();
                    bv.Save();
                }
                // populate the contents of v on the to the database list

            }
        }
 public void LoadByReceiptID(int receiptID)
 {
     BLL.Receipt rct = new Receipt();
     rct.LoadByPrimaryKey(receiptID);
     BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
     rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID);
     this.LoadByPrimaryKey(rctInvoice.POID);
 }
Exemple #18
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();
            }
        }
 public void SaveAirFreight(double Freight)
 {
     ReceiptInvoice receiptInvoice = new ReceiptInvoice();
     receiptInvoice.LoadByPrimaryKey(GRV.ReceiptInvoiceID);
     if (receiptInvoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
     {
         _Freight = Freight;
         GRV.SeaFreight = _Freight;
     }
     else if (receiptInvoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_AIR)
     {
         _Freight = Freight;
         GRV.AirFreight = _Freight;
     }
     GRV.Save();
     LoadGRV(GRV.ID);
 }
        //, string transitTransferNo, string insurancePolicyNo, string wayBillNo)
        /// <summary>
        /// Adds the new receipt.
        /// </summary>
        /// <param name="receiptTypeID">The receipt type ID.</param>
        /// <param name="userID">The user ID.</param>
        /// <param name="receiptInvoiceID">The receipt invoice ID.</param>
        /// /// <param name="receiptStatusID">The receipt confirmation status ID.</param>
        /// <returns></returns>
        public int AddNewReceipt(int receiptTypeID,int warehouseID ,int userID, int receiptInvoiceID, string txtTransitTransferVoucherNoOverride, int receiptStatusID)
        {
            this.AddNew();
            this.DateOfEntry = DateTimeHelper.ServerDateTime;
            this.ReceiptTypeID = receiptTypeID;
            this.SavedByUserID = userID;
            this.WarehouseID = warehouseID;
            this.ReceiptInvoiceID = receiptInvoiceID;
            this.ReceiptStatusID = receiptStatusID;

            BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
            rctInvoice.LoadByPrimaryKey(receiptInvoiceID);

            this.STVOrInvoiceNo = rctInvoice.STVOrInvoiceNo;
            if (string.IsNullOrEmpty(txtTransitTransferVoucherNoOverride))
            {
                this.TransitTransferNo = rctInvoice.TransitTransferNo;
            }
            else
            {
                this.TransitTransferNo = txtTransitTransferVoucherNoOverride;
            }
            this.InsurancePolicyNo = rctInvoice.InsurancePolicyNo;
            this.WayBillNo = rctInvoice.WayBillNo;
            this.Save();
            return this.ID;
        }