/// <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);
            }
        }
        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);

            }
        }
        /// <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 = "-";
            }
        }
示例#5
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);
            }
        }