Esempio n. 1
0
        private static void SubmitBranchIssues(int hcmisOrderID)
        {
            var tsvc       = new ServiceOrderClient();
            var issuedList = new Collection <Issuance>();

            BLL.OrderDetail hcmisOrderDetail = new OrderDetail();
            hcmisOrderDetail.LoadOrderDetailsWithIssueAndPicklistForPLITS(hcmisOrderID);

            while (!hcmisOrderDetail.EOF)
            {
                var issuance = new Issuance
                {
                    DateIssued            = Convert.ToDateTime(hcmisOrderDetail.GetColumn("EurDate")),
                    ApprovedOrderDetailId = Convert.ToInt32(hcmisOrderDetail.GetColumn("HACTOrderDetailID")),
                    QuantityIssued        = Convert.ToInt32(hcmisOrderDetail.GetColumn("NoOfPack"))
                };
                issuedList.Add(issuance);
                hcmisOrderDetail.MoveNext();
            }


            var validationmessage = tsvc.SubmitBranchIssues(issuedList, PlitsUserName, PlitsPassword);

            XtraMessageBox.Show(validationmessage[0].Message, "Issuance", MessageBoxButtons.OK);
        }
        private void BindMainOrderGrid()
        {
            // Given some items are already selected on the first step of the order process (CDR Request) // I doubt that
            // Bind the second grid with the selected items for the quantity to be filled by the HCMIS Operator

            if (OrderID == null)
            {
                BLL.OrderDetail or = new BLL.OrderDetail();
                or.LoadByPrimaryKey(-1);
                _dvItemTable = new DataView(new DataTable());

                _dvItemTable.Table.Columns.Add("LocationID");
                _dvItemTable.Table.Columns.Add("Packs");
                _dvItemTable.Table.Columns.Add("QtyPerPack");
                _dvItemTable.Table.Columns.Add("UnitPrice");
                _dvItemTable.Table.Columns.Add("ReceiveDocID");
                _dvItemTable.Table.Columns.Add("Cost");
                _dvItemTable.Table.Columns.Add("FullItemName");
                _dvItemTable.Table.Columns.Add("Manufacturer");
                _dvItemTable.Table.Columns.Add("ManufacturerID");
                _dvItemTable.Table.Columns.Add("Unit");
                _dvItemTable.Table.Columns.Add("Balance");
                _dvItemTable.Table.Columns.Add("Location");
                _dvItemTable.Table.Columns.Add("Supplier");
                _dvItemTable.Table.Columns.Add("account");
                _dvItemTable.Table.Columns.Add("BatchNo");
                _dvItemTable.Table.Columns.Add("ExpDate");
                _dvItemTable.Table.Columns.Add("ItemID");
                _dvItemTable.Table.Columns.Add("UnitID");
                _dvItemTable.Table.Columns.Add("ID");
                _dvItemTable.Table.Columns.Add("StockCode");
                _dvItemTable.Table.Columns.Add("StoreID");
                _dvItemTable.Table.Columns.Add("ApprovedPacks");
                _dvItemTable.Table.Columns.Add("ReceivingLocationID");

            }

            orderGrid.DataSource = _dvItemTable;

            dvPickList = new DataTable();
            dvPickList.Columns.Add("BatchNo");
            dvPickList.Columns.Add("CalculatedCost");
            dvPickList.Columns.Add("ExpDate");
            dvPickList.Columns.Add("AccountName");
            dvPickList.Columns.Add("FullItemName");
            dvPickList.Columns.Add("ManufacturerName");
            dvPickList.Columns.Add("Pack");
            dvPickList.Columns.Add("QtyInSKU");
            dvPickList.Columns.Add("PalletLocation");
            dvPickList.Columns.Add("PalletNo");
            dvPickList.Columns.Add("UnitPrice");
            dvPickList.Columns.Add("LineNum");
            dvPickList.Columns.Add("Unit");
            dvPickList.Columns.Add("WarehouseName");
            dvPickList.Columns.Add("PrintedSTVNumber");
            dvPickList.Columns.Add("PhysicalStoreName");
            dvPickList.Columns.Add("PhysicalStoreTypeName");
            dvPickList.Columns.Add("ActivityConcat");
            dvPickList.Columns.Add("StockCode");
        }
        private void BindMainOrderGrid()
        {
            // Given some items are already selected on the first step of the order process (CDR Request) // I doubt that
            // Bind the second grid with the selected items for the quantity to be filled by the HCMIS Operator

            if (OrderID == null)
            {
                BLL.OrderDetail or = new BLL.OrderDetail();
                or.LoadByPrimaryKey(-1);
                _dvItemTable = new DataView(new DataTable());

                _dvItemTable.Table.Columns.Add("LocationID");
                _dvItemTable.Table.Columns.Add("Packs");
                _dvItemTable.Table.Columns.Add("QtyPerPack");
                _dvItemTable.Table.Columns.Add("UnitPrice");
                _dvItemTable.Table.Columns.Add("ReceiveDocID");
                _dvItemTable.Table.Columns.Add("Cost");
                _dvItemTable.Table.Columns.Add("FullItemName");
                _dvItemTable.Table.Columns.Add("Manufacturer");
                _dvItemTable.Table.Columns.Add("ManufacturerID");
                _dvItemTable.Table.Columns.Add("Unit");
                _dvItemTable.Table.Columns.Add("Balance");
                _dvItemTable.Table.Columns.Add("Location");
                _dvItemTable.Table.Columns.Add("Supplier");
                _dvItemTable.Table.Columns.Add("account");
                _dvItemTable.Table.Columns.Add("BatchNo");
                _dvItemTable.Table.Columns.Add("ExpDate");
                _dvItemTable.Table.Columns.Add("ItemID");
                _dvItemTable.Table.Columns.Add("UnitID");
                _dvItemTable.Table.Columns.Add("ID");
                _dvItemTable.Table.Columns.Add("StockCode");
                _dvItemTable.Table.Columns.Add("StoreID");
                _dvItemTable.Table.Columns.Add("ApprovedPacks");
                _dvItemTable.Table.Columns.Add("ReceivingLocationID");
            }

            orderGrid.DataSource = _dvItemTable;

            dvPickList = new DataTable();
            dvPickList.Columns.Add("BatchNo");
            dvPickList.Columns.Add("CalculatedCost");
            dvPickList.Columns.Add("ExpDate");
            dvPickList.Columns.Add("AccountName");
            dvPickList.Columns.Add("FullItemName");
            dvPickList.Columns.Add("ManufacturerName");
            dvPickList.Columns.Add("Pack");
            dvPickList.Columns.Add("QtyInSKU");
            dvPickList.Columns.Add("PalletLocation");
            dvPickList.Columns.Add("PalletNo");
            dvPickList.Columns.Add("UnitPrice");
            dvPickList.Columns.Add("LineNum");
            dvPickList.Columns.Add("Unit");
            dvPickList.Columns.Add("WarehouseName");
            dvPickList.Columns.Add("PrintedSTVNumber");
            dvPickList.Columns.Add("PhysicalStoreName");
            dvPickList.Columns.Add("PhysicalStoreTypeName");
            dvPickList.Columns.Add("ActivityConcat");
            dvPickList.Columns.Add("StockCode");
        }
        public Domain.Request FindSingle(int requestID)
        {
            var request = new Domain.Request();
            var order = new Order();
            order.LoadByPrimaryKey(requestID);

            request.RequestID = order.ID;
            request.OrderNumber = order.RefNo;
            request.LetterNumber = !order.IsColumnNull("LetterNo") ? order.LetterNo : "";
            request.RequestedDate = order.EurDate;

            request.Client = _clientRepository.FindSingle(order.RequestedBy);
            request.Mode = _modeService.GetEnum(order.FromStore);
            request.PaymentTerm = _paymentTermService.FindSingle(order.PaymentTypeID);
            request.OrderStatus = _orderStatusService.GetEnum(order.OrderStatusID);

            var orderDetail = new OrderDetail();
            orderDetail.LoadAllByOrderID(requestID);
            orderDetail.Rewind();
            request.RequestDetails = new Collection<Domain.RequestDetail>();
            while (!orderDetail.EOF)
            {
                var item = _itemRepository.FindSingle(orderDetail.ItemID);
                var unitOfIssue = _unitOfIssueRepository.FindSingle(orderDetail.UnitID);
                var requestDetail = new Domain.RequestDetail()
                                        {

                                            RequestDetailId = orderDetail.ID,
                                            Item = item,
                                            Unit = unitOfIssue,
                                            RequestedQuantity = orderDetail.Pack,
                                            ApprovedQuantity = !orderDetail.IsColumnNull("ApprovedQuantity") ? orderDetail.ApprovedQuantity : orderDetail.Pack,
                                            IsFirstLoad = orderDetail.IsColumnNull("ApprovedQuantity"),
                                            ActivityGroup = orderDetail.IsColumnNull(OrderDetail.ColumnNames.StoreID)?null:_activityRepository.FindSingle(orderDetail.StoreID,orderDetail.DeliveryNote),
                                            ExpiryDate =
                                                !orderDetail.IsColumnNull("PreferredExpiryDate")
                                                    ? orderDetail.PreferredExpiryDate
                                                    : (DateTime?)null,
                                            Manufacturer =
                                                !orderDetail.IsColumnNull("PreferredManufacturerID")
                                                    ? _manufacturerRepository.FindSingle(
                                                        orderDetail.PreferredManufacturerID)
                                                    : null,
                                            physicalStore =
                                                !orderDetail.IsColumnNull("PreferredPhysicalStoreID")
                                                    ? _physicalStoreRepository.FindSingle(
                                                        orderDetail.PreferredPhysicalStoreID)
                                                    : null

                                        };
                request.RequestDetails.Add(requestDetail);
            orderDetail.MoveNext();
            }

            return request;
        }
 private void gridOrderListView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     DataRow dr = gridOrderListView.GetFocusedDataRow();
     if (dr != null)
     {
         int OrderID = Convert.ToInt32(dr["ID"]);
         OrderDetail order = new OrderDetail();
         order.LoadAllByOrderID(OrderID);
         gridOrderDetail.DataSource = order.DefaultView;
     }
 }
Esempio n. 6
0
        private HCMIS.Desktop.Reports.StockOut  StockOutReport(int orderID)
        {
            var stockedOutReport = new HCMIS.Desktop.Reports.StockOut();

            stockedOutReport.HubName.Text             = GeneralInfo.Current.HospitalName;
            stockedOutReport.StockOutExplanation.Text = string.Format("The item/s listed below were stocked-out at the time the request (letter {2} by {1}) was made on {0}", EthiopianDate.EthiopianDate.GregorianToEthiopian(ApprovalOrder.Date), ApprovalOrder.GetRequestedBy(), ApprovalOrder.LetterNo);
            stockedOutReport.PreparedBy.Text          = CurrentContext.LoggedInUserName;
            stockedOutReport.PrintedOn.Text           = EthiopianDate.EthiopianDate.Now.ToDateString();
            stockedOutReport.DataSource = OrderDetail.GetStockOutReport(orderID);
            return(stockedOutReport);
        }
Esempio n. 7
0
        private void tabControlOrderDetail_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            if (tabControlOrderDetail.SelectedTabPage == tabFacility && _isFirstTimeLoad)
            {
                var facilityId  = ApprovalOrder.RequestedBy;
                var orderdetail = new OrderDetail();
                orderdetail.LoadAllByOrderID(_orderID);
                var facilityhistory = orderdetail.GetLastOrderDetailByFacility(_orderID, facilityId);
                gridOrderDetailForFacility.DataSource = facilityhistory;
                _isFirstTimeLoad = false;
            }

            btnApproveOrder.Enabled = tabControlOrderDetail.SelectedTabPage == tabGeneral && this.HasPermission("Approve");
        }
Esempio n. 8
0
 private bool IsApprovalValid()
 {
     //Let's see if there are rows with identical preferrence
     BLL.OrderDetail validatedOrder = new OrderDetail();
     validatedOrder.ValidateOrderDetailForIdenticalPreference(_orderID);
     if (validatedOrder.RowCount > 0)
     {
         XtraMessageBox.Show(
             string.Format(
                 "The item {0} has a split entries with the same preference.  Please correct that to approve the order.",
                 validatedOrder.GetColumn("FullItemName").ToString()));
         return(false);
     }
     return(true);
 }
        public void Save(Domain.Request _request,int userID, Domain.OrderStatus orderStatus = Domain.OrderStatus.Submitted)
        {
            var order = new Order();
            order.LoadByPrimaryKey(_request.RequestID);

            var dborderStatus = new BLL.OrderStatus();
            dborderStatus.LoadByCode(EnumService<Domain.OrderStatus>.GetCode(orderStatus));

            order.ChangeStatus(dborderStatus.ID,CurrentContext.UserId);
            order.ApprovedBy = userID;
            order.ApprovedDate = DateTimeHelper.ServerDateTime;

            var orderDetail = new OrderDetail();
            orderDetail.LoadAllByOrderID(_request.RequestID);
            while (!orderDetail.EOF)
            {
                var requestDetail = _request.RequestDetails.SingleOrDefault(r => r.RequestDetailId == orderDetail.ID);
                if(requestDetail== null)
                {
                    orderDetail.MarkAsDeleted();
                }
                else
                {

                    //Set Activity
                    if (requestDetail.ActivityGroup != null)
                    {
                        orderDetail.StoreID = requestDetail.ActivityGroup.Activity.ActivityID;
                        orderDetail.DeliveryNote = requestDetail.ActivityGroup.IsDeliveryNote;
                    }
                    else
                    {
                        orderDetail.SetColumnNull("StoreID");
                    }
                    //Set Manufacturer
                    if (requestDetail.Manufacturer != null)
                    {
                        orderDetail.PreferredManufacturerID = requestDetail.Manufacturer.ManufacturerID;
                    }
                    else
                    {
                        orderDetail.SetColumnNull("PreferredManufacturerID");
                    }

                    //Set PhysicalStore
                    if (requestDetail.physicalStore != null)
                    {
                        orderDetail.PreferredPhysicalStoreID = requestDetail.physicalStore.PhysicalStoreID;
                    }
                    else
                    {
                        orderDetail.SetColumnNull("PreferredPhysicalStoreID");
                    }

                    //Set ExpiryDate
                    if (requestDetail.ExpiryDate.HasValue)
                    {
                        orderDetail.PreferredExpiryDate = requestDetail.ExpiryDate.Value;
                    }
                    else
                    {
                        orderDetail.SetColumnNull("PreferredExpiryDate");
                    }
                        orderDetail.ApprovedQuantity = requestDetail.ApprovedQuantity;
                    orderDetail.StockedOut = requestDetail.StockedOut;
                }

                orderDetail.MoveNext();
            }
            foreach (var requestDetail in _request.RequestDetails.Where(r => r.RequestDetailId == 0).ToList())
            {
                orderDetail.AddNew();
                orderDetail.ItemID = requestDetail.Item.ItemID;
                orderDetail.UnitID = requestDetail.Unit.UnitID;
                orderDetail.Pack = requestDetail.RequestedQuantity;
                orderDetail.OrderID = order.ID;
                orderDetail.QtyPerPack = 1;
                orderDetail.Quantity = requestDetail.RequestedQuantity;
                orderDetail.ApprovedQuantity = requestDetail.ApprovedQuantity;
                orderDetail.StockedOut = requestDetail.StockedOut;
                if (requestDetail.ActivityGroup != null)
                {
                    orderDetail.StoreID = requestDetail.ActivityGroup.Activity.ActivityID;
                    orderDetail.DeliveryNote = requestDetail.ActivityGroup.IsDeliveryNote;
                }
                else
                {
                    orderDetail.SetColumnNull("StoreID");
                }
                //Set Manufacturer
                if (requestDetail.Manufacturer != null)
                {
                    orderDetail.PreferredManufacturerID = requestDetail.Manufacturer.ManufacturerID;
                }
                else
                {
                    orderDetail.SetColumnNull("PreferredManufacturerID");
                }

                //Set PhysicalStore
                if (requestDetail.physicalStore != null)
                {
                    orderDetail.PreferredPhysicalStoreID = requestDetail.physicalStore.PhysicalStoreID;
                }
                else
                {
                    orderDetail.SetColumnNull("PreferredPhysicalStoreID");
                }

                //Set ExpiryDate
                if (requestDetail.ExpiryDate.HasValue)
                {
                    orderDetail.PreferredExpiryDate = requestDetail.ExpiryDate.Value;
                }
                else
                {
                    orderDetail.SetColumnNull("PreferredExpiryDate");
                }

            }

            order.Save();
            orderDetail.Save();
        }
        private void OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var gv = (GridView)sender;
            var dr = gv.GetFocusedDataRow();
            var or = new BLL.Order();
            _orderID = Convert.ToInt32(gv.GetFocusedDataRow()["ID"].ToString());

            order.LoadByPrimaryKey(_orderID);
            // populate the general order variables
            txtPickListFromStore.Text = order.GetFromStore();
            lblMode.Text = order.GetFromStore();

            txtPickListRequestedBy.Text = order.GetFilledBy();

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                ins.LoadByPrimaryKey(order.RequestedBy);

                var ownership = new BLL.OwnershipType();
                ownership.LoadByPrimaryKey(ins.Ownership);

                lblOwnership.Text = ownership.Name;
                lblInstitutionType.Text = ins.InstitutionTypeName;
                lblFacility.Text = ins.Name;
                lblWoreda.Text = ins.WoredaName;
                lblZone.Text = ins.ZoneName;
                lblRegion.Text = ins.RegionName;
                lblLetterNum.Text = String.IsNullOrEmpty(order.LetterNo) ? "-" : order.LetterNo;

            }
            else
            {
                lblFacility.Text = lblWoreda.Text = lblZone.Text = lblRegion.Text = lblOwnership.Text = "";// lblType.Text = "";
            }

            int length = order.GetRequestedBy().Length;

            string s = "";

            HeaderLayoutGroup.Text = order.GetRequestedBy() + s.PadRight(150 - length) + "Order Number:" + order.RefNo;

            txtPickListOrderNumber.Text = order.RefNo;
            lblOrderNum.Text = order.RefNo;

            txtPickListApprovedBy.Text = order.GetApprovedBy();
            lblApprovedBy.Text = order.GetApprovedBy();

            var orderDetail = new OrderDetail();
            orderDetail.LoadAllByOrderID(order.ID);

            if (!orderDetail.IsColumnNull("StoreID"))
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(orderDetail.StoreID);
                lblMode.Text = activity.ModeName;
            }

            lblOrderDate.Text = order.Date.ToShortDateString();

            var us = new BLL.User();
            us.LoadByPrimaryKey(order.FilledBy);
            lblFilledBy.Text = us.FirstName;

            lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-";
            lblIssueType.Text = (string)dr["Description"] ?? "-";

            var paymentType = new BLL.PaymentType();
            paymentType.LoadByPrimaryKey(order.PaymentTypeID);
            lblPaymentType.Text = paymentType.Name;

            if (order.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED)
            {
                progressBarControl.Properties.Maximum = order.CountOfDetailItems();
                progressBarControl.Properties.DisplayFormat.FormatString = "{0: #,##0}" + string.Format(" of {0}", progressBarControl.Properties.Maximum);
                progressBarControl.Properties.DisplayFormat.FormatType = FormatType.Custom;
                progressBarControl.EditValue = 0;
                this.Enabled = false;
                progressBarControl.Visible = true;
                bgWorker.RunWorkerAsync(_orderID);
            }
        }
        private void tabControlOrderDetail_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            if(tabControlOrderDetail.SelectedTabPage == tabFacility && _isFirstTimeLoad)
            {

                var facilityId = ApprovalOrder.RequestedBy;
                var orderdetail = new OrderDetail();
                orderdetail.LoadAllByOrderID(_orderID);
                var facilityhistory = orderdetail.GetLastOrderDetailByFacility(_orderID, facilityId);
                gridOrderDetailForFacility.DataSource = facilityhistory;
                _isFirstTimeLoad = false;
            }

               btnApproveOrder.Enabled = tabControlOrderDetail.SelectedTabPage == tabGeneral && this.HasPermission("Approve");
        }
        /// <summary>
        /// The code supports manufacturer preference here too but we choose not to prefer manufacturers when looking into the stores.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="orderDetailID"></param>
        /// <param name="pricedUnpricedBoth"></param>
        /// <param name="bal"> </param>
        /// <param name="markStockoutBit"> </param>
        /// <param name="usableStock"> </param>
        /// <param name="approved"> </param>
        public decimal LoadOptionsForOrderDetail(int userID, int orderDetailID, PriceSettings pricedUnpricedBoth, Balance bal, bool markStockoutBit, out decimal usableStock, out decimal approved)
        {
            decimal avQuantity = 0;

            BLL.OrderDetail orderDetail = new OrderDetail();
            orderDetail.LoadByPrimaryKey(orderDetailID);
            BLL.Order order = new Order();
            order.LoadByPrimaryKey(orderDetail.OrderID);

            Institution ru = new Institution();

            ru.LoadByPrimaryKey(order.RequestedBy);

            int month = EthiopianDate.EthiopianDate.Now.Month;
            int year  = EthiopianDate.EthiopianDate.Now.Year;

            decimal availableQty = 0;

            usableStock = 0;
            approved    = 0;
            int?manufacturerPrefrence = null, unitID = null;

            if (!orderDetail.IsColumnNull("PreferredManufacturerID"))
            {
                manufacturerPrefrence = orderDetail.PreferredManufacturerID;
            }

            DateTime?expPreferrence = null;

            if (!orderDetail.IsColumnNull("PreferredExpiryDate"))
            {
                expPreferrence = orderDetail.PreferredExpiryDate;
            }

            int?preferredPhysicalStoreID = null;

            if (!orderDetail.IsColumnNull("PreferredPhysicalStoreID"))
            {
                preferredPhysicalStoreID = orderDetail.PreferredPhysicalStoreID;
            }

            //--------------------------------------------------------------------------
            //manufacturerPrefrence = null; //We are overriding the manufacturer preference.
            //expPreferrence = null;
            //--------------------------------------------------------------------------
            if (!orderDetail.IsColumnNull("UnitID"))
            {
                unitID = orderDetail.UnitID;
            }

            BLL.UserActivity userStore = new UserActivity();

            // Definitely a danger zone
            userStore.LoadByUserIDAndStoreType(userID, order.FromStore, orderDetail.ItemID, unitID.Value);


            while (!userStore.EOF)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(userStore.ActivityID);

                if (order.FromStore == Mode.Constants.RDF && !BLL.Settings.IsCenter && !BLL.Settings.PrivateCanGetFromMDGAndPBS && ru.Ownership == OwnershipType.Constants.Private && activity.IsSubsidized)
                {
                    userStore.MoveNext();
                    continue;
                }



                // Load the Activity Selection that has PRiced Commodities.
                Balance balance = new Balance();
                if (pricedUnpricedBoth == PriceSettings.PRICED_ONLY || pricedUnpricedBoth == PriceSettings.BOTH)
                {
                    BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.PRICED_ONLY, orderDetail,
                                                    userStore.ActivityID, orderDetail.ItemID, order, balance, unitID,
                                                    manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved,
                                                    out availableQty, markStockoutBit);
                    avQuantity += availableQty;

                    if (availableQty > 0)
                    {
                        this.AddNew();
                        this.ID   = userStore.ActivityID;
                        this.Name = string.Format("{0} ({1})", activity.FullActivityName, availableQty.ToString("#,##0"));
                        PrepareColumnsForApproval();
                        this.SetColumn("AvailableSKU", availableQty);
                        this.SetColumn("IsDeliveryNote", false);
                        this.SetColumn("TextID", string.Format("N{0}", this.ID));
                    }
                }



                // Load Activity Selections for Delivery Note Items.
                if (pricedUnpricedBoth == PriceSettings.DELIVERY_NOTE_ONLY || pricedUnpricedBoth == PriceSettings.BOTH)
                {
                    BLL.Order.MakeStockCalculations(userID, month, year, PriceSettings.DELIVERY_NOTE_ONLY, orderDetail,
                                                    userStore.ActivityID, orderDetail.ItemID, order, balance, unitID,
                                                    manufacturerPrefrence, expPreferrence, preferredPhysicalStoreID, out usableStock, out approved,
                                                    out availableQty, markStockoutBit);

                    avQuantity += availableQty;

                    if (availableQty > 0)
                    {
                        this.AddNew();
                        this.ID   = userStore.ActivityID; //Just to give it a different ID so we know there is a change only.
                        this.Name = string.Format("+-- {0} - Delivery Notes - ({1})", userStore.GetColumn("ActivityName"),
                                                  availableQty.ToString("#,##0"));
                        PrepareColumnsForApproval();
                        this.SetColumn("AvailableSKU", availableQty);
                        this.SetColumn("IsDeliveryNote", true);
                        this.SetColumn("TextID", string.Format("D{0}", this.ID));
                    }
                }
                userStore.MoveNext();
            }
            return(avQuantity);
        }
        // Submit Branch and Facility Issues
        private static void SubmitFacilityIssues(int hcmisOrderID)
        {
            var tsvc = new ServiceOrderClient();
            var issuedList = new Collection<Issuance>();

            BLL.OrderDetail hcmisOrderDetail = new OrderDetail();
            hcmisOrderDetail.LoadOrderDetailsWithIssueAndPicklistForPLITS(hcmisOrderID);

            while (!hcmisOrderDetail.EOF)
            {
                var issuance = new Issuance
                                 {
                                     DateIssued = Convert.ToDateTime(hcmisOrderDetail.GetColumn("EurDate")),
                                     ApprovedOrderDetailId = Convert.ToInt32(hcmisOrderDetail.GetColumn("HACTOrderDetailID")),
                                     QuantityIssued = Convert.ToInt32(hcmisOrderDetail.GetColumn("NoOfPack"))
                                 };
                issuedList.Add(issuance);
                hcmisOrderDetail.MoveNext();
            }

            var validationmessage = tsvc.SubmitFacilityIssues(GetBranchID(), issuedList, PlitsUserName, PlitsPassword);
            XtraMessageBox.Show(validationmessage[0].Message, "Issuance", MessageBoxButtons.OK);
        }
 private bool IsApprovalValid()
 {
     //Let's see if there are rows with identical preferrence
     BLL.OrderDetail validatedOrder = new OrderDetail();
     validatedOrder.ValidateOrderDetailForIdenticalPreference(_orderID);
     if (validatedOrder.RowCount > 0)
     {
         XtraMessageBox.Show(
             string.Format(
                 "The item {0} has a split entries with the same preference.  Please correct that to approve the order.",
                 validatedOrder.GetColumn("FullItemName").ToString()));
         return false;
     }
     return true;
 }
        private void OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (e != null && e.RowHandle < -1)
                return;

            var gv = (GridView)sender;
            var dr = gv.GetFocusedDataRow();
            _orderID = Convert.ToInt32(dr["ID"].ToString());

            order.LoadByPrimaryKey(_orderID);
            // populate the general order variables
            txtPickListFromStore.Text = order.GetFromStore();
            lblMode.Text = order.GetFromStore() ?? "-";

            txtPickListRequestedBy.Text = order.GetRequestedBy();
            labelControl9.Text = order.GetRequestedBy() ?? "-";

            var us = new BLL.User();

            us.LoadByPrimaryKey(order.FilledBy);
            lblFilledBy.Text = us.FullName ?? "-";
            string s = "";

            lblLetterNum.Text = String.IsNullOrEmpty(order.LetterNo) ? "-" : order.LetterNo;

            var orderDetail = new OrderDetail();
            orderDetail.LoadAllByOrderID(order.ID);

            var paymentType = new BLL.PaymentType();
            paymentType.LoadByPrimaryKey(order.PaymentTypeID);

            if (!orderDetail.IsColumnNull("StoreID"))
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(orderDetail.StoreID);
                lblMode.Text = activity.ModeName ?? "-";
            }

            lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-";
            lblIssueType.Text = (string)dr["Description"] ?? "-";

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                ins.LoadByPrimaryKey(order.RequestedBy);

                var ownership = new BLL.OwnershipType();
                ownership.LoadByPrimaryKey(ins.Ownership);

                int length = ins.Name.Length;
                HeaderSection.Text = ins.Name + s.PadRight(150 - length) + "Order Number: " + order.RefNo;
                lblOwnership.Text = ownership.Name ?? "-";
                lblZone.Text = ins.ZoneName ?? "-";
                lblWoreda.Text = ins.WoredaName ?? "-";
                lblRegion.Text = ins.RegionName ?? "-";
                lblInstitutionType.Text = ins.InstitutionTypeName ?? "-";
            }
            else
            {
                HeaderSection.Text =lblOwnership.Text = lblZone.Text =lblWoreda.Text =lblRegion.Text = lblInstitutionType.Text = "-";
            }

            lblPaymentType.Text = paymentType.Name;
            lblOrderDate.Text = order.Date.ToShortDateString();

            txtPickListOrderNumber.Text = order.RefNo;
            labelControl12.Text = order.RefNo;

            txtPickListApprovedBy.Text = order.GetApprovedBy();
            labelControl13.Text = order.GetApprovedBy();

            if (order.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED)
            {
                PickList pl = new PickList();
                gridPickListDetail.DataSource = pl.GetPickListDetailsForOrder(_orderID);

                btnPrintAndSavePickList.Text = @"Confirm";
                colPrice.FieldName = "Cost";
                colSKU.FieldName = "Packs";
                btnCancelPickList.Enabled = (BLL.Settings.UseNewUserManagement)? this.HasPermission("Cancel-Pick-List"):true;

                pl.LoadByOrderID(_orderID);
                if (!pl.IsColumnNull("PickedBy"))
                {
                    us.LoadByPrimaryKey(pl.PickedBy);
                    lblPicklistPrintedBy.Text = us.FullName;
                }
                else lblPicklistPrintedBy.Text = "-";

                lblPicklistPrintedDate.Text = !pl.IsColumnNull("SavedDate") ? pl.SavedDate.ToShortDateString() : "-";
                lblPicklistNo.Text = !pl.IsColumnNull("PrintedID") ? pl.PrintedID.ToString() : "-";

            }
            //gridPickListView.EndSummaryUpdate();
        }
        private void SavePickListItems(object sender, EventArgs e)
        {
            BLL.Order ord = new BLL.Order();
            BLL.Institution rus = new Institution();
            ord.LoadByPrimaryKey(_orderID);

            if (_dvPickListMakeup != null)
            {
                if (ValidatePickList()) return;
            }

            // if the pick list has already been printed ... go ahead and pass it to the next level
            if (ord.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED)
            {
                OrderDetail oDetail = new OrderDetail();
                oDetail.Where.OrderID.Value = ord.ID;
                oDetail.Query.Load();

                ord.ChangeStatus(OrderStatus.Constant.PICK_LIST_CONFIRMED,CurrentContext.UserId);
                this.LogActivity("Confirm-Pick-List", ord.ID);
                BindApprovedOrders();
                gridPickListDetail.DataSource = null;
                XtraMessageBox.Show("The Pick List has been Confirmed", "Confirmation", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }
        }
        private bool ValidatePickList()
        {
            foreach (DataRowView drv in _dvPickListMakeup)
            {
                int itemID = Convert.ToInt32(drv["ItemID"]);
                int storeID = Convert.ToInt32(drv["StoreID"]);
                int unitID = Convert.ToInt32(drv["UnitID"]);
                int manufacturerID = Convert.ToInt32(drv["ManufacturerID"]);

                ReceiveDoc rd = new ReceiveDoc();

                if (BLL.Settings.BlockWhenExpectingPriceChange && BLL.ReceiveDoc.DoesPriceNeedToBeChanged(storeID, itemID, unitID, manufacturerID) )
                {
                    OrderDetail odetail = new OrderDetail();
                    odetail.Where.ItemID.Value = itemID;
                    odetail.Where.OrderID.Value = _orderID;
                    odetail.Query.Load();
                    if (odetail.RowCount > 0)
                    {
                        if (odetail.ApprovedQuantity == 0)
                            continue;
                    }

                    Item itm = new Item();
                    itm.LoadByPrimaryKey(itemID);
                    XtraMessageBox.Show(
                        string.Format("The item {0} cannot be issued because it is waiting for price change.", itm.FullItemName),
                        "Price Pending", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return true;
                }
            }
            return false;
        }
        private void SaveOrder()
        {
            var order = GenerateOrder();
            var picklist = PickList.GeneratePickList(order.ID);

            int lineNo = 0;

            // This is a kind of initializing the data table.
            OrderDetail ord = new OrderDetail();
            PickListDetail pkDetail = new PickListDetail();
            DataView dv = orderGrid.DataSource as DataView;

            foreach (DataRowView r in dv)
            {
                if (r["ApprovedPacks"] != null && r["ApprovedPacks"] != DBNull.Value && r["ApprovedPacks"].ToString()!= "")
                    if (Convert.ToInt32(r["ApprovedPacks"]) != 0)
                    {
                        lineNo = lineNo + 1;
                        int itemID = Convert.ToInt32(r["ItemID"]);
                        int unitID = Convert.ToInt32(r["UnitID"]);
                        ord.AddNew();
                        ord.OrderID = order.ID;
                        ord.ItemID = itemID;
                        if (r["ApprovedPacks"] != DBNull.Value)
                        {
                            ord.Pack = Convert.ToInt32(r["ApprovedPacks"]);
                        }
                        if (r["QtyPerPack"] != DBNull.Value)
                        {
                            ord.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]);
                        }
                        ord.Quantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        ord.ApprovedQuantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        ord.UnitID = unitID;
                        ord.StoreID = Convert.ToInt32(lkAccountType.EditValue);

                        ord.Save();
                        pkDetail.AddNew();
                        pkDetail.PickListID = picklist.ID;
                        pkDetail.ItemID = itemID;
                        pkDetail.PalletLocationID = Convert.ToInt32(r["LocationID"]);
                        pkDetail.BatchNumber = r["BatchNo"].ToString();
                        if (r["ExpDate"] != DBNull.Value)
                            pkDetail.ExpireDate = DateTime.Parse(r["ExpDate"].ToString());

                        pkDetail.StoreID = Convert.ToInt32(r["StoreID"]);
                        pkDetail.UnitID = unitID;
                        pkDetail.ReceiveDocID = Convert.ToInt32(r["ReceiveDocID"]);
                        if (r["UnitPrice"] != DBNull.Value)
                        {
                            pkDetail.Cost = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]);
                            pkDetail.UnitPrice = Convert.ToDouble(r["UnitPrice"]);
                        }
                        pkDetail.Packs = Convert.ToInt32(r["ApprovedPacks"]);
                        pkDetail.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]);
                        pkDetail.QuantityInBU = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        pkDetail.StoreID = Convert.ToInt32(r["StoreID"]);
                        pkDetail.ReceivePalletID = Convert.ToInt32(r["ReceivingLocationID"]);
                        pkDetail.ManufacturerID = Convert.ToInt32(r["ManufacturerID"]);
                        pkDetail.BoxLevel = 0;
                        pkDetail.DeliveryNote = true;
                        pkDetail.Save();
                        //To Print The Picklist
                      //Then reserve Items
                        ReceivePallet receivepallet = new ReceivePallet();
                        receivepallet.LoadByPrimaryKey(Convert.ToInt32(r["ReceivingLocationID"]));
                        receivepallet.ReservedStock = receivepallet.ReservedStock + Convert.ToInt32(r["ApprovedPacks"]);
                        receivepallet.Save();

                        DataRow drvpl = dvPickList.NewRow();
                        drvpl["FullItemName"] = r["FullItemName"];
                        drvpl["StockCode"] = r["StockCode"];
                        drvpl["BatchNo"] = r["BatchNo"];
                        if (r["ExpDate"] != DBNull.Value)
                            drvpl["ExpDate"] = Convert.ToDateTime(r["ExpDate"]).ToString("MMM/yyyy");
                        else
                            drvpl["ExpDate"] = DBNull.Value;
                        drvpl["LineNum"] = lineNo + 1;
                        drvpl["ManufacturerName"] = r["Manufacturer"];
                        drvpl["Pack"] = r["ApprovedPacks"];
                        drvpl["UnitPrice"] = r["UnitPrice"];

                        drvpl["Unit"] = r["Unit"];
                        drvpl["PalletLocation"] = r["Location"];
                        drvpl["QtyInSKU"] = Convert.ToInt32(r["ApprovedPacks"]);
                        if (r["UnitPrice"] != DBNull.Value)
                        drvpl["CalculatedCost"] = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]);

                        PalletLocation palletLocation = new PalletLocation();
                        palletLocation.LoadByPrimaryKey(pkDetail.PalletLocationID);
                        drvpl["WarehouseName"] = palletLocation.WarehouseName;
                        drvpl["PhysicalStoreName"] = palletLocation.PhysicalStoreName;
                        var activity = new Activity();
                        activity.LoadByPrimaryKey(pkDetail.StoreID);
                        drvpl["ActivityConcat"] = activity.FullActivityName;
                        drvpl["AccountName"] = activity.AccountName;
                        dvPickList.Rows.Add(drvpl);

                    }

            }
            if (lineNo == 0)
                throw new System.ArgumentException("Please review your list,you haven't approved any Quantity");

            var plr = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(order, lkForHub.Text,
                                                                                       dvPickList.DefaultView);

            plr.PrintDialog();

            if (!BLL.Settings.IsCenter)
            {
                if (TransferTypeID == 3)
                {

                    XtraMessageBox.Show("Your Store To Store Transfer will be Printed now", "Store To Store Transfer");
                    Transfer.Move(picklist.ID);
                    HCMIS.Desktop.Reports.StoreTransferPrintOut STM =
                        new HCMIS.Desktop.Reports.StoreTransferPrintOut();
                    STM.LoadByPickListID(picklist.ID);
                    STM.PrintDialog();

                }
                else if (TransferTypeID == 2)
                {
                    XtraMessageBox.Show(ReceiveDoc.ReceiveFromAccountTransfer(picklist.ID,
                                                                              Convert.ToInt32(lkForHub.EditValue),
                                                                              CurrentContext.LoggedInUserName,
                                                                              CurrentContext.UserId));
                }
            }
            else
            {
                XtraMessageBox.Show("Picklist Prepared!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 19
0
 public void InsertOrderDetail(OrderDetail detail)
 {
     p.InsertOrderDetail(detail);
 }