Beispiel #1
0
        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 void btnCancelPickList_Click(object sender, EventArgs e)
        {
            DataRow dr = gridApprovedOrdersView.GetFocusedDataRow();

            if (dr != null)
            {
                if (DialogResult.Yes == XtraMessageBox.Show(String.Format("Are you sure you want to cancel the Request: {0}?", dr["RefNo"]), "Confirm Cancelation!", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    int       ordID = Convert.ToInt32(dr["ID"]);
                    BLL.Order ord   = new BLL.Order();
                    ord.LoadByPrimaryKey(ordID);
                    ord.OrderStatusID = OrderStatus.Constant.CANCELED;
                    ord.Save();
                    if (BLL.Settings.IsCenter)
                    {
                        XtraMessageBox.Show("Issue Order List canceled", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XtraMessageBox.Show("Pick List canceled", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    BindApprovedOrders();
                    gridPickListDetail.DataSource = null;
                }
            }
        }
        private void OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            GridView gv = (GridView)sender;

            BLL.Order or = new BLL.Order();
            _orderID = Convert.ToInt32(gv.GetFocusedDataRow()["ID"].ToString());

            order.LoadByPrimaryKey(_orderID);
            // populate the general order variables
            txtPickListFromStore.Text   = order.GetFromStore();
            txtPickListRequestedBy.Text = order.GetRequestedBy();
            txtPickListOrderNumber.Text = order.RefNo;
            txtPickListApprovedBy.Text  = order.GetApprovedBy();

            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);
            }
        }
Beispiel #4
0
        private void OnSaveApproval(object sender, EventArgs e)
        {
            if (
                XtraMessageBox.Show("Are you sure you would like to save this approval?", "Confirm Approval",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (uxApproval.ApproveOrder(CurrentContext.UserId))
                {
                    var order = new BLL.Order();
                    order.LoadByPrimaryKey(_orderID);

                    if (!BLL.Settings.IsCenter && uxApproval.HasStockOut() &&
                        XtraMessageBox.Show("Would you like to print the stockout report?",
                                            "Stockout Report Confirmation",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                        System.Windows.Forms.DialogResult.Yes)
                    {
                        StockOutReport(_orderID).ShowPreviewDialog();
                    }


                    gridViewOrder.OptionsSelection.EnableAppearanceFocusedRow = false;
                    BindOutstandingOrders();
                    uxApproval.Flush();
                    this.LogActivity("Approve-Order", ApprovalOrder.ID);
                    XtraMessageBox.Show("Approval Confirmed for User", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Beispiel #5
0
        private void PrintPicklistItems(object sender, EventArgs e)
        {
            BLL.Order ord = new BLL.Order();
            ord.LoadByPrimaryKey(_orderID);
            BLL.Institution rus = new Institution();
            rus.LoadByPrimaryKey(ord.RequestedBy);
            XtraReport pickList;

            pickList = WorkflowReportFactory.CreatePicklistReport(ord, rus.Name, _dvPickListMakeup);
            pickList.ShowPreviewDialog();
        }
        private void PrintPicklistItems(object sender, EventArgs e)
        {
            var ord = new BLL.Order();

            ord.LoadByPrimaryKey(_orderID);

            var rus = new Institution();

            rus.LoadByPrimaryKey(ord.RequestedBy);

            var pl = Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(ord, rus, _dvPickListMakeup);

            pl.ShowPreviewDialog();
        }
Beispiel #7
0
        private void OnOutstandingOrdersRowClicked(object sender, RowClickEventArgs e)
        {
            gridViewOrder.OptionsSelection.EnableAppearanceFocusedRow = true;
            _orderID = Convert.ToInt32(gridViewOrder.GetFocusedDataRow()["ID"].ToString());

            ApprovalOrder.LoadByPrimaryKey(_orderID);
            gridOrderDetailForFacility.DataSource = null;

            tabFacility.Text = String.Format("{0} History", ApprovalOrder.GetRequestedBy());

            uxApproval.LoadOrder(_orderID, BLL.Settings.IsCenter);
            _isFirstTimeLoad = true;
            tabControlOrderDetail.SelectedTabPage = tabGeneral;
            tabControlOrderDetail_SelectedPageChanged(null, null);
        }
Beispiel #8
0
        private void BtnCancelClicked(object sender, EventArgs e)
        {
            // cancel order from the approve order screen
            DataRow dr = gridViewOrder.GetFocusedDataRow();

            if (dr != null)
            {
                if (DialogResult.Yes ==
                    XtraMessageBox.Show(
                        String.Format("Are you sure you want to cancel the Request: {0}?", dr["RefNo"]),
                        "Confirm Cancelation!", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    //TOFIX: this could have been written in the business Logic
                    int       ordID = Convert.ToInt32(dr["ID"]);
                    BLL.Order ord   = new BLL.Order();
                    ord.LoadByPrimaryKey(ordID);
                    ord.ChangeStatus(OrderStatus.Constant.CANCELED, CurrentContext.UserId);
                    this.LogActivity("Cancel-Approval", ord.ID);
                    XtraMessageBox.Show("Request canceled", "Confirmation", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    BindOutstandingOrders();
                }
            }
        }
        private void BtnCancelClicked(object sender, EventArgs e)
        {
            // cancel order from the approve order screen
            DataRow dr = gridViewOrder.GetFocusedDataRow();
            if (dr != null)
            {
                if (DialogResult.Yes ==
                    XtraMessageBox.Show(
                        String.Format("Are you sure you want to cancel the Request: {0}?", dr["RefNo"]),
                        "Confirm Cancelation!", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {

                    //TOFIX: this could have been written in the business Logic
                    int ordID = Convert.ToInt32(dr["ID"]);
                    BLL.Order ord = new BLL.Order();
                    ord.LoadByPrimaryKey(ordID);
                    ord.ChangeStatus(OrderStatus.Constant.CANCELED,CurrentContext.UserId);
                    this.LogActivity("Cancel-Approval", ord.ID);
                    XtraMessageBox.Show("Request canceled", "Confirmation", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    BindOutstandingOrders();
                }
            }
        }
        /// <summary>
        /// Called when [outstanding picklist selected].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Grid.RowClickEventArgs" /> instance containing the event data.</param>
        private void OnOutstandingPicklistSelected(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var dr = gridOutstandingPickListView.GetFocusedDataRow();

            _orderID = Convert.ToInt32(dr["ID"]);

            var order = new BLL.Order();

            order.LoadByPrimaryKey(_orderID);


            // load payment type options
            int?requestedBy = null;

            var usr = new User();

            lblIssueStatus.Text = (string)dr["OrderStatus"];
            lblIssueTypes.Text  = (string)dr["Description"];

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                requestedBy = order.RequestedBy;
                lkPaymentType.Properties.DataSource = PaymentType.GetAllowedTypes(order.FromStore, requestedBy);
                ins.LoadByPrimaryKey(order.RequestedBy);

                try
                {
                    lblWoreda.Text          = ins.WoredaName ?? "-";
                    lblRegion.Text          = ins.RegionName ?? "-";
                    lblZone.Text            = ins.ZoneName ?? "-";
                    lblInstitutionType.Text = ins.InstitutionTypeName ?? "-";

                    var ownership = new BLL.OwnershipType();
                    if (!ins.IsColumnNull("Ownership"))
                    {
                        ownership.LoadByPrimaryKey(ins.Ownership);
                        lblOwnership.Text = ownership.Name;
                    }
                }
                catch (NullReferenceException ex)
                {
                    //when transfer, institution has no woreda, zone or region, ignore the error
                }
            }
            else
            {
                lblWoreda.Text = lblRegion.Text = lblZone.Text = lblInstitutionType.Text = lblOwnership.Text = "NA";
            }


            //usr.LoadByPrimaryKey(NewMainWindow.UserId);
            usr = CurrentContext.LoggedInUser;
            txtIssuedBy.Text = usr.FullName ?? "-";


            PickList pl = new PickList();

            _dvOutstandingPickList = pl.GetPickListDetailsForOrder(_orderID, CurrentContext.LoggedInUserName);
            gridOutstandingPicklistDetail.DataSource = _dvOutstandingPickList;



            if (order.FromStore != Mode.Constants.HEALTH_PROGRAM)
            {
                colSKUPicked.Visible = false;
            }
            else
            {
                colSKUPicked.Visible = true;
            }


            txtConfirmFromStore.Text   = order.GetFromStore();
            txtConfirmRequestedBy.Text = order.GetRequestedBy();

            int length = order.GetRequestedBy().Length;


            string s = "";

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

            txtConfirmOrderNumber.Text = order.RefNo;
            //txtConfirmApprovedBy.Text = order.GetApprovedBy() ?? "-";
            lblApprovedBy.Text = order.GetApprovedBy() ?? "-";

            lkPaymentType.EditValue = order.PaymentTypeID;
            // Temporarily copy the STV
            txtIssueRefNo.Text = order.RefNo; //"";
            lblRefNo.Text      = order.RefNo ?? "-";

            var paymentType = new BLL.PaymentType();

            paymentType.LoadByPrimaryKey(order.PaymentTypeID);
            lblPaymentType.Text = paymentType.Name ?? "-";

            lblMode.Text                = order.GetFromStore() ?? "-";
            lblissuedDate.Text          = order.Date.ToShortDateString();
            lblIssuedBy.Text            = order.GetFilledBy();
            lblPicklistPrintedDate.Text = pl.PickedDate.ToShortDateString() != "" ? pl.PickedDate.ToShortDateString() : "-";

            var us = new User();

            pl.LoadByOrderID(_orderID);
            if (!pl.IsColumnNull("PickedBy"))
            {
                us.LoadByPrimaryKey(pl.PickedBy);
                lblPicklistConfirmedBy.Text = us.FullName;
            }
            else
            {
                lblPicklistConfirmedBy.Text = "-";
            }
        }
        private void gridRequisitionListView_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            if (e != null && e.PrevFocusedRowHandle < -1)
            {
                return;
            }


            try
            {
                DataRow dr = gridRequisitionListView.GetFocusedDataRow();
                if (dr == null)
                {
                    return;
                }
                int orderID = Convert.ToInt32(dr["ID"]);
                gridRequisitionDetails.DataSource = Order.GetRequisitionDetails(orderID);
                //lblOrderStatus.Text = Order.GetOrderStatus(orderID);

                BLL.Order order = new BLL.Order();
                order.LoadByPrimaryKey(orderID);


                Institution ins = new Institution();

                ins.LoadByPrimaryKey(order.RequestedBy);

                lblWoreda.Text        = ins.WoredaName;
                lblZone.Text          = ins.ZoneName;
                lblRegion.Text        = ins.RegionName;
                lblRequestedDate.Text = order.EurDate.ToShortDateString();
                lblRequestedBy.Text   = order.GetFilledBy();


                OrderStatus os = new OrderStatus();
                os.LoadByPrimaryKey(order.OrderStatusID);

                lblStatus.Text = os.OrderStatus;

                int length = order.GetRequestedBy().Length;

                string s = "";

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

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

                var paymentType = new BLL.PaymentType();
                paymentType.LoadByPrimaryKey(order.PaymentTypeID);
                lblPaymentType.Text = paymentType.Name;
                lblMode.Text        = order.GetFromStore();
                DataRow facilityHis = BLL.Issue.GetVisitHistoryForFacility(Convert.ToInt32(dr["InstitutionID"]));

                if (facilityHis != null)
                {
                    lblLastVisit.Text = Convert.ToDateTime(facilityHis["LastVisit"]).TimeAgo() ?? "-";
                    lblNoOfReq.Text   = Convert.ToString(facilityHis["VisitCount"]) ?? "-";
                    lblIssueType.Text = Convert.ToString(facilityHis["Description"]) ?? "-";
                }

                else
                {
                    lblLastVisit.Text = lblNoOfReq.Text = lblIssueType.Text = "-";
                }
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #12
0
        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 OnSaveApproval(object sender, EventArgs e)
        {
            if (
                XtraMessageBox.Show("Are you sure you would like to save this approval?", "Confirm Approval",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (uxApproval.ApproveOrder(CurrentContext.UserId))
                {

                    var order = new BLL.Order();
                    order.LoadByPrimaryKey(_orderID);

                    if (!BLL.Settings.IsCenter && uxApproval.HasStockOut() &&
                        XtraMessageBox.Show("Would you like to print the stockout report?",
                                            "Stockout Report Confirmation",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                        System.Windows.Forms.DialogResult.Yes)
                    {
                        StockOutReport(_orderID).ShowPreviewDialog();
                    }

                    gridViewOrder.OptionsSelection.EnableAppearanceFocusedRow = false;
                    BindOutstandingOrders();
                    uxApproval.Flush();
                    this.LogActivity("Approve-Order", ApprovalOrder.ID);
                    XtraMessageBox.Show("Approval Confirmed for User","Confirmation",MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
            }
        }
        private void SavePickListItems(object sender, EventArgs e)
        {
            BLL.Order       ord = new BLL.Order();
            BLL.Institution rus = new Institution();
            ord.LoadByPrimaryKey(_orderID);


            // 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)
            {
                ord.OrderStatusID = OrderStatus.Constant.PICK_LIST_CONFIRMED;
                ord.Save();
                BindApprovedOrders();
                gridPickListDetail.DataSource = null;
                XtraMessageBox.Show("The Pick List has been Confirmed", "Confirmation", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }

            if (_dvPickListMakeup != null)
            {
                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    mgr.BeginTransaction();
                    // First of all .. print the pick list

                    rus.LoadByPrimaryKey(ord.RequestedBy);

                    var pl = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(ord, rus,
                                                                                              _dvPickListMakeup);
                    pl.PrintDialog();
                    var pls = new PickList();

                    pls.SavePickList(_orderID, _dvPickListMakeup, CurrentContext.UserId);

                    // Refresh the current window
                    BindApprovedOrders();
                    // clear the working grid
                    gridPickListDetail.DataSource = null;
                    mgr.CommitTransaction();
                    XtraMessageBox.Show("Your pick list has been saved! please continue to the next step or prepare another Picklist here.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    BLL.User user = new User();
                    //user.LoadByPrimaryKey(NewMainWindow.UserId);
                    user = CurrentContext.LoggedInUser;
                    if (user.UserType == UserType.Constants.ADMIN || user.UserType == UserType.Constants.SUPER_ADMINISTRATOR)
                    {
                        XtraMessageBox.Show(exp.Message);
                    }
                    else
                    {
                        XtraMessageBox.Show("System couldn't save the Pick List, Please contact administrator for additional help", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    ErrorHandler.Handle(exp);
                }
            }
        }
        private void btnCancelPickList_Click(object sender, EventArgs e)
        {
            DataRow dr = gridApprovedOrdersView.GetFocusedDataRow();
            if (dr != null)
            {
                if (DialogResult.Yes == XtraMessageBox.Show(String.Format("Are you sure you want to cancel the Request: {0}?", dr["RefNo"]), "Confirm Cancelation!", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    int ordID = Convert.ToInt32(dr["ID"]);
                    BLL.Order ord = new BLL.Order();
                    ord.LoadByPrimaryKey(ordID);
                    ord.ChangeStatus(OrderStatus.Constant.CANCELED,CurrentContext.UserId);
                    if (BLL.Settings.IsCenter)
                    {
                        XtraMessageBox.Show("Issue Order List canceled", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }else
                    {
                        XtraMessageBox.Show("Pick List canceled", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    BindApprovedOrders();
                    gridPickListDetail.DataSource = null;
                }
            }
        }
        /// <summary>
        /// Called when [outstanding picklist selected].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Grid.RowClickEventArgs" /> instance containing the event data.</param>
        private void OnOutstandingPicklistSelected(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var dr = gridOutstandingPickListView.GetFocusedDataRow();
            _orderID = Convert.ToInt32(dr["ID"]);

            var order = new BLL.Order();
            order.LoadByPrimaryKey(_orderID);

            // load payment type options
            int? requestedBy = null;

            var usr = new User();

            lblIssueStatus.Text = (string)dr["OrderStatus"];
            lblIssueTypes.Text = (string) dr["Description"];

            if (!order.IsColumnNull("RequestedBy"))
            {
                var ins = new Institution();
                requestedBy = order.RequestedBy;
                lkPaymentType.Properties.DataSource = PaymentType.GetAllowedTypes(order.FromStore, requestedBy);
                ins.LoadByPrimaryKey(order.RequestedBy);

                try
                {
                    lblWoreda.Text = ins.WoredaName ?? "-";
                    lblRegion.Text = ins.RegionName ?? "-";
                    lblZone.Text = ins.ZoneName ?? "-";
                    lblInstitutionType.Text = ins.InstitutionTypeName ?? "-";

                    var ownership = new BLL.OwnershipType();
                    if (!ins.IsColumnNull("Ownership"))
                    {
                        ownership.LoadByPrimaryKey(ins.Ownership);
                        lblOwnership.Text = ownership.Name;
                    }

                }
                catch (NullReferenceException ex)
                {
                    //when transfer, institution has no woreda, zone or region, ignore the error
                }
            }
            else
                lblWoreda.Text = lblRegion.Text = lblZone.Text = lblInstitutionType.Text = lblOwnership.Text = "NA";

            //usr.LoadByPrimaryKey(NewMainWindow.UserId);
            usr = CurrentContext.LoggedInUser;
            txtIssuedBy.Text = usr.FullName ?? "-";

            PickList pl = new PickList();
            _dvOutstandingPickList = pl.GetPickListDetailsForOrder(_orderID, CurrentContext.LoggedInUserName);
            gridOutstandingPicklistDetail.DataSource = _dvOutstandingPickList;

            if (order.FromStore != Mode.Constants.HEALTH_PROGRAM)
            {
                colSKUPicked.Visible = false;
            }
            else
            {
                colSKUPicked.Visible = true;
            }

            txtConfirmFromStore.Text = order.GetFromStore();
            txtConfirmRequestedBy.Text = order.GetRequestedBy();

            int length = order.GetRequestedBy().Length;

            string s = "";

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

            txtConfirmOrderNumber.Text = order.RefNo;
            //txtConfirmApprovedBy.Text = order.GetApprovedBy() ?? "-";
            lblApprovedBy.Text = order.GetApprovedBy() ?? "-";

            lkPaymentType.EditValue = order.PaymentTypeID;
            // Temporarily copy the STV
            txtIssueRefNo.Text = order.RefNo; //"";
            lblRefNo.Text = order.RefNo ?? "-";

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

            lblMode.Text = order.GetFromStore() ?? "-";
            lblissuedDate.Text = order.Date.ToShortDateString();
            lblIssuedBy.Text = order.GetFilledBy();
            lblPicklistPrintedDate.Text = pl.PickedDate.ToShortDateString()!="" ? pl.PickedDate.ToShortDateString() : "-";

            var us = new User();
            pl.LoadByOrderID(_orderID);
            if (!pl.IsColumnNull("PickedBy"))
            {
                us.LoadByPrimaryKey(pl.PickedBy);
                lblPicklistConfirmedBy.Text = us.FullName;
            }
            else lblPicklistConfirmedBy.Text = "-";
        }
        private void SavePickListItems(object sender, EventArgs e)
        {
            BLL.Order ord = new BLL.Order();
            BLL.Institution rus = new Institution();
            ord.LoadByPrimaryKey(_orderID);

            // 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)
            {
                ord.OrderStatusID = OrderStatus.Constant.PICK_LIST_CONFIRMED;
                ord.Save();
                BindApprovedOrders();
                gridPickListDetail.DataSource = null;
                XtraMessageBox.Show("The Pick List has been Confirmed", "Confirmation", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }

            if (_dvPickListMakeup != null)
            {

                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    mgr.BeginTransaction();
                    // First of all .. print the pick list

                    rus.LoadByPrimaryKey(ord.RequestedBy);

                    var pl = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(ord, rus,
                                                                                              _dvPickListMakeup);
                    pl.PrintDialog();
                    var pls = new PickList();

                    pls.SavePickList(_orderID, _dvPickListMakeup, CurrentContext.UserId);

                    // Refresh the current window
                    BindApprovedOrders();
                    // clear the working grid
                    gridPickListDetail.DataSource = null;
                    mgr.CommitTransaction();
                    XtraMessageBox.Show("Your pick list has been saved! please continue to the next step or prepare another Picklist here.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    BLL.User user = new User();
                    //user.LoadByPrimaryKey(NewMainWindow.UserId);
                    user = CurrentContext.LoggedInUser;
                    if (user.UserType == UserType.Constants.ADMIN || user.UserType == UserType.Constants.SUPER_ADMINISTRATOR)
                    {
                        XtraMessageBox.Show(exp.Message);
                    }
                    else
                    {
                        XtraMessageBox.Show("System couldn't save the Pick List, Please contact administrator for additional help", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    ErrorHandler.Handle(exp);
                }
            }
        }
        /// <summary>
        /// Saves the and print STV.
        /// </summary>
        /// <param name="pickListDetail">The pick list detail.</param>
        /// <param name="deliveryNotePrinter">The delivery note printer.</param>
        /// <param name="stvPrinterName">Name of the STV printer.</param>
        /// <param name="dtDate">The dt date.</param>
        /// <param name="dtCurrent">The dt current.</param>
        /// <exception cref="System.Exception"></exception>
        private XtraReport SaveAndPrintSTV(DataView pickListDetail, bool isDeliveryNote, string printerName, DateTimePickerEx dtDate, DateTime dtCurrent)
        {
            HCMIS.Core.Distribution.Services.PrintLogService pLogService = new HCMIS.Core.Distribution.Services.PrintLogService();

            pLogService.StartPrintingSession();

            Order ord = IssueDoc.SaveIssueTransaction(_orderID, ref pickListDetail, txtRemarks.Text,
                                                      CurrentContext.LoggedInUserName, dtCurrent);



            if (pickListDetail.Count == 0)
            {
                throw new Exception("An error occurred during saving the issue.  Please contact your administrator.");
            }

            string sendToString = "";

            BLL.Order ordr = new BLL.Order();
            ordr.LoadByPrimaryKey(_orderID);
            BLL.Institution rus = new Institution();
            if (!ordr.IsColumnNull("RequestedBy"))
            {
                rus.LoadByPrimaryKey(ordr.RequestedBy);
                sendToString = rus.Name;
            }

            else if (!ordr.IsColumnNull("OrderTypeID") &&
                     ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
            {
                BLL.Transfer transfer = new Transfer();
                transfer.LoadByOrderID(_orderID);
                var activity = new Activity();
                activity.LoadByPrimaryKey(transfer.ToStoreID);
                sendToString = activity.FullActivityName;
            }

            PickList pl = new PickList();

            pl.LoadByOrderID(ord.ID);

            var xtraReport = new XtraReport();

            if (ord.PaymentTypeID == PaymentType.Constants.CASH)
            {
                xtraReport = FormatCashInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote,
                                               printerName, pLogService);
            }
            else if (ord.PaymentTypeID == PaymentType.Constants.CREDIT)
            {
                xtraReport = FormatCreditInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote,
                                                 printerName, pLogService);
            }
            else if (ord.PaymentTypeID == PaymentType.Constants.STV)
            {
                xtraReport = FormatSTV(ord, pickListDetail.Table, sendToString, pl, isDeliveryNote,
                                       printerName,
                                       pLogService, _orderID);
            }



            SavePdfReport(pLogService, xtraReport);
            pLogService.CommitPrintLog();
            return(xtraReport);
        }
        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 void PrintPicklistItems(object sender, EventArgs e)
 {
     BLL.Order ord = new BLL.Order();
     ord.LoadByPrimaryKey(_orderID);
     BLL.Institution rus = new Institution();
     rus.LoadByPrimaryKey(ord.RequestedBy);
     XtraReport pickList;
     pickList = WorkflowReportFactory.CreatePicklistReport(ord, rus.Name,_dvPickListMakeup);
     pickList.ShowPreviewDialog();
 }
        private void gridRequisitionListView_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            if (e != null && e.PrevFocusedRowHandle < -1)
                return;

            try
            {
                DataRow dr = gridRequisitionListView.GetFocusedDataRow();
                if (dr == null)
                    return;
                int orderID = Convert.ToInt32(dr["ID"]);
                gridRequisitionDetails.DataSource = Order.GetRequisitionDetails(orderID);
                //lblOrderStatus.Text = Order.GetOrderStatus(orderID);

                BLL.Order order = new BLL.Order();
                order.LoadByPrimaryKey(orderID);

                Institution ins = new Institution();

                ins.LoadByPrimaryKey(order.RequestedBy);

                lblWoreda.Text = ins.WoredaName;
                lblZone.Text = ins.ZoneName;
                lblRegion.Text = ins.RegionName;
                lblRequestedDate.Text = order.EurDate.ToShortDateString();
                lblRequestedBy.Text = order.GetFilledBy();

                OrderStatus os = new OrderStatus();
                os.LoadByPrimaryKey(order.OrderStatusID);

                lblStatus.Text = os.OrderStatus;

                int length = order.GetRequestedBy().Length;

                string s = "";

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

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

                var paymentType = new BLL.PaymentType();
                paymentType.LoadByPrimaryKey(order.PaymentTypeID);
                lblPaymentType.Text = paymentType.Name;
                lblMode.Text = order.GetFromStore();
                DataRow facilityHis = BLL.Issue.GetVisitHistoryForFacility(Convert.ToInt32(dr["InstitutionID"]));

                if (facilityHis != null)
                {
                    lblLastVisit.Text = Convert.ToDateTime(facilityHis["LastVisit"]).TimeAgo() ?? "-";
                    lblNoOfReq.Text = Convert.ToString(facilityHis["VisitCount"]) ?? "-";
                    lblIssueType.Text = Convert.ToString(facilityHis["Description"]) ?? "-";
                }

                else
                {
                    lblLastVisit.Text = lblNoOfReq.Text = lblIssueType.Text = "-";

                }
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
Beispiel #22
0
        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();
        }
        /// <summary>
        /// Saves the and print STV.
        /// </summary>
        /// <param name="pickListDetail">The pick list detail.</param>
        /// <param name="deliveryNotePrinter">The delivery note printer.</param>
        /// <param name="stvPrinterName">Name of the STV printer.</param>
        /// <param name="dtDate">The dt date.</param>
        /// <param name="dtCurrent">The dt current.</param>
        /// <exception cref="System.Exception"></exception>
        private XtraReport SaveAndPrintSTV(DataView pickListDetail, bool isDeliveryNote, string printerName, DateTimePickerEx dtDate, DateTime dtCurrent)
        {
            HCMIS.Core.Distribution.Services.PrintLogService pLogService = new HCMIS.Core.Distribution.Services.PrintLogService();

            pLogService.StartPrintingSession();

            Order ord = IssueDoc.SaveIssueTransaction(_orderID, ref pickListDetail, txtRemarks.Text,
                                                      CurrentContext.LoggedInUserName, dtCurrent);

            if (pickListDetail.Count == 0)
                throw new Exception("An error occurred during saving the issue.  Please contact your administrator.");

            string sendToString = "";
            BLL.Order ordr = new BLL.Order();
            ordr.LoadByPrimaryKey(_orderID);
            BLL.Institution rus = new Institution();
            if (!ordr.IsColumnNull("RequestedBy"))
            {
                rus.LoadByPrimaryKey(ordr.RequestedBy);
                sendToString = rus.Name;
            }

            else if (!ordr.IsColumnNull("OrderTypeID") &&
                     ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
            {
                BLL.Transfer transfer = new Transfer();
                transfer.LoadByOrderID(_orderID);
                var activity = new Activity();
                activity.LoadByPrimaryKey(transfer.ToStoreID);
                sendToString = activity.FullActivityName;
            }

            PickList pl = new PickList();
            pl.LoadByOrderID(ord.ID);

            var xtraReport = new XtraReport();

            if (ord.PaymentTypeID == PaymentType.Constants.CASH)
            {
                xtraReport = FormatCashInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote,
                                  printerName, pLogService);
            }
            else if (ord.PaymentTypeID == PaymentType.Constants.CREDIT)
            {
                xtraReport = FormatCreditInvoice(ord, pickListDetail.Table, rus, pl, isDeliveryNote,
                                    printerName, pLogService);
            }
            else if (ord.PaymentTypeID == PaymentType.Constants.STV)
            {
                xtraReport = FormatSTV(ord, pickListDetail.Table, sendToString, pl, isDeliveryNote,
                          printerName,
                          pLogService, _orderID);
            }

            SavePdfReport(pLogService, xtraReport);
            pLogService.CommitPrintLog();
            return xtraReport;
        }
        private void PrintPicklistItems(object sender, EventArgs e)
        {
            var ord = new BLL.Order();
            ord.LoadByPrimaryKey(_orderID);

            var rus = new Institution();
            rus.LoadByPrimaryKey(ord.RequestedBy);

            var pl = Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(ord, rus, _dvPickListMakeup);
            pl.ShowPreviewDialog();
        }