Ejemplo n.º 1
0
        private void LstTreeFocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            DateTime dt1 = new DateTime();
            DateTime dt2 = new DateTime();

            CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
            dtDate.CustomFormat = "MM/dd/yyyy";
            dtDate.Value        = DateTimeHelper.ServerDateTime;
            DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);

            DataRowView dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode);

            if (dr != null)
            {
                LossAndAdjustment disp  = new LossAndAdjustment();
                DataTable         dtRec = new DataTable();
                if (dr["ParentID"] == DBNull.Value)
                {
                    int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1);
                    dt1   = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1);
                    dt2   = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1);
                    dtRec = disp.GetTransactionByDateRange(Convert.ToInt32(lkActivity.EditValue), dt1, dt2);
                    string dateString = dr["RefNo"].ToString();
                    lblAdjDate.Text = dateString;
                }
                else
                {
                    dtRec           = disp.GetDocumentByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(lkActivity.EditValue), dr["Date"].ToString());
                    lblAdjDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy");
                }
                gridAdjustments.DataSource = dtRec;
            }
        }
Ejemplo n.º 2
0
 private void cboReasons_EditValueChanged(object sender, EventArgs e)
 {
     if (lkActivity.EditValue != null && cboReasons.EditValue != null)
     {
         LossAndAdjustment Adj   = new LossAndAdjustment();
         DataTable         dtRec = new DataTable();
         dtRec = Adj.GetTransactionByReason(Convert.ToInt32(lkActivity.EditValue), Convert.ToInt32(cboReasons.EditValue));
         gridAdjustments.DataSource = dtRec;
     }
 }
Ejemplo n.º 3
0
 private void cboStores_EditValueChanged(object sender, EventArgs e)
 {
     if (lkActivity.EditValue != null)
     {
         LossAndAdjustment Adj   = new LossAndAdjustment();
         DataTable         dtRec = Adj.GetDistinctAdjustmentDocments(Convert.ToInt32(lkActivity.EditValue));
         /*PopulateDocument(dtRec);*/ lstTree.DataSource = dtRec;
         DateTime dt1 = new DateTime();
         DateTime dt2 = new DateTime();
         CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
         dtDate.CustomFormat = "MM/dd/yyyy";
         dtDate.Value        = DateTimeHelper.ServerDateTime;
         DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);
         int      yr        = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1);
         dt1                        = new DateTime(yr, 11, 1);
         dt2                        = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day);
         dtRec                      = Adj.GetTransactionByDateRange(Convert.ToInt32(lkActivity.EditValue), dt1, dt2);
         lblAdjDate.Text            = "Current Year";
         gridAdjustments.DataSource = dtRec;
     }
 }
Ejemplo n.º 4
0
        private void dtTo_ValueChanged(object sender, EventArgs e)
        {
            LossAndAdjustment Adj   = new LossAndAdjustment();
            DataTable         dtRec = new DataTable();

            dtFrom.CustomFormat = "MM/dd/yyyy";
            dtTo.CustomFormat   = "MM/dd/yyyy";
            DateTime dteFrom = new DateTime();
            DateTime dteTo   = new DateTime();

            dteFrom = ConvertDate.DateConverter(dtFrom.Text);
            dteTo   = ConvertDate.DateConverter(dtTo.Text);

            if (dteFrom < dteTo)
            {
                dtRec = Adj.GetTransactionByDateRange(Convert.ToInt32(lkActivity.EditValue), dteFrom, dteTo);
            }
            else
            {
                dtRec = Adj.GetAllTransaction(Convert.ToInt32(lkActivity.EditValue));
            }
            gridAdjustments.DataSource = dtRec;
        }
        public Collection <Order> GetOrders()
        {
            var orders = new Collection <Order>();

            _tblRrf = (DataTable)gridItemsChoice.DataSource;
            tblRRF  = (DataTable)gridItemsChoice.DataSource;

            var info = new GeneralInfo();

            info.LoadAll();

            var client1 = new ServiceRRFLookupClient();
            var req     = new GetCurrentReportingPeriodRequest
            {
                Password          = RRFServiceIntegration.PlitsPassword,
                UserName          = RRFServiceIntegration.PlitsUserName,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var branchReq = new GetBranchRRFormRequest
            {
                UserName          = RRFServiceIntegration.PlitsUserName,
                Password          = RRFServiceIntegration.PlitsPassword,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var formReq = new GetFormsRequest
            {
                Password          = RRFServiceIntegration.PlitsPassword,
                UserName          = RRFServiceIntegration.PlitsUserName,
                Supplychainunitid = RRFServiceIntegration.GetBranchID()
            };

            var forms  = client1.GetForms(formReq).GetFormsResult;
            var formid = forms[0].Id;

            var periods = client1.GetCurrentReportingPeriod(req).GetCurrentReportingPeriodResult;
            var period  = periods[0].Id;


            branchReq.Formid            = formid;
            branchReq.Reportingperiodid = period;


            var chosenCatId        = 91;//RRFHelper.GetRrfCategoryId(cboStores.Text);
            var rrfs               = client1.GetBranchRRForm(branchReq).GetBranchRRFormResult;
            var formCategories     = rrfs.First().FormCategories;
            var chosenCategoryBody = formCategories.First(x => x.Id == chosenCatId); //Hard coding to be removed.
            var items              = chosenCategoryBody.Pharmaceuticals;             //Let's just store the items here (May not be required)

            var user = new User();

            user.LoadByPrimaryKey(CurrentContext.LoggedInUser.ID);
            var order = new HCMIS.Desktop.PLITSTransactionalService.Order
            {
                //Id = (int)rrf["Id"],
                RequestCompletedDate = BLL.DateTimeHelper.ServerDateTime,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]),
                OrderCompletedBy     = user.FullName,
                RequestVerifiedDate  = BLL.DateTimeHelper.ServerDateTime,
                OrderTypeId          = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency'
                SubmittedBy          = user.FullName,
                SubmittedDate        = BLL.DateTimeHelper.ServerDateTime,
                SupplyChainUnitId    = Helpers.RRFServiceIntegration.GetBranchID(),
                OrderStatus          = 1,   //TODO: hardcoding
                FormId            = formid, //TODO: hardcoding
                ReportingPeriodId = period  //TODO: hardcoding
            };

            // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"];
            // Set order properties

            //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense
            //  order.ReportingPeriodId = periods[0].Id; //Asked again here?  Because RRFForm already contains this.

            var details = new Collection <OrderDetail>();
            int i       = 0;
            var xx      = tblRRF.Rows.Count;

            foreach (DataRow rrfLine in tblRRF.Rows)
            {
                var detail               = new PLITSTransactionalService.OrderDetail();
                var hcmisItemID          = Convert.ToInt32(rrfLine["ID"]);
                var rrFormPharmaceutical = items.FirstOrDefault(x => x.PharmaceuticalId == Convert.ToInt32(rrfLine["ID"]));
                if (rrfLine != null && rrFormPharmaceutical != null)
                {
                    detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]);
                    //DaysOutOfStock daysOfStockOut = new DaysOutOfStock() { NumberOfDaysOutOfStock = 1 };
                    //detail.DaysOutOfStocks.Add(daysOfStockOut);//Convert.ToInt32(rrfLine["DaysOutOfStock"]);
                    int eBalance = Convert.ToInt32(rrfLine["SOH"]);
                    detail.EndingBalance = eBalance == 0 ? 1 : eBalance;  //To make sure ending balance is not zero.
                    //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table.
                    detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]);
                    detail.QuantityOrdered  = Convert.ToInt32(rrfLine["Quantity"]);
                    detail.LossAdjustment   = Convert.ToInt32(rrfLine["LossAdj"]);


                    if (rrFormPharmaceutical != null)
                    {
                        detail.ItemId = rrFormPharmaceutical.ItemId;
                    }
                    else
                    {
                        throw new Exception("Item ID Mismatch");
                    }


                    var rdDoc             = new ReceiveDoc();
                    var lossAndAdjustment = new LossAndAdjustment();
                    rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID);
                    lossAndAdjustment.GetLossAdjustmentsForLastRRFPeriod(hcmisItemID, _storeID, periods[0].StartDate,
                                                                         periods[0].EndDate);
                    int receiveDocEntries = rdDoc.RowCount;
                    int disposalEntries   = lossAndAdjustment.RowCount;



                    rdDoc.Rewind();
                    for (var j = 0; j < receiveDocEntries; j++)
                    {
                        var exp = new Expiry
                        {
                            Amount     = Convert.ToInt32(rdDoc.QuantityLeft),
                            BatchNo    = rdDoc.BatchNo,
                            ExpiryDate = rdDoc.ExpDate
                        };
                        detail.Expiries.Add(exp);
                        rdDoc.MoveNext();
                    }

                    lossAndAdjustment.Rewind();
                    for (var j = 0; j < disposalEntries; j++)
                    {
                        var adj = new Adjustment
                        {
                            Amount = Convert.ToInt32(lossAndAdjustment.Quantity), TypeId = 11, ReasonId = 39
                        };

                        detail.Adjustments.Add(adj);
                        lossAndAdjustment.MoveNext();
                    }

                    var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID);


                    for (int j = 0; j < stockoutIndexedLists.Count; j++)
                    {
                        var dos = new DaysOutOfStock
                        {
                            NumberOfDaysOutOfStock = stockoutIndexedLists[j].NumberOfDays,
                            StockOutReasonId       = 5
                        };

                        detail.DaysOutOfStocks.Add(dos);
                    }

                    details.Add(detail);
                }
            }
            order.OrderDetails = details;
            orders.Add(order);


            // loop through each record and create order & order details objects
            return(orders);

            //var user = new User();
            //user.LoadByPrimaryKey(NewMainWindow.LoggedInUser.ID);
            //foreach (DataRow rrf in tblRRF.Rows)
            //{
            //    var order = new HCMIS.Desktop.PLITSTransactionalService.Order
            //    {
            //        Id = (int)rrf["Id"],
            //        RequestCompletedDate = DateTime.Now,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]),
            //        OrderCompletedBy = user.FullName,
            //        RequestVerifiedDate = DateTime.Now,
            //        OrderTypeId = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency'
            //        SubmittedBy = user.FullName,
            //        SubmittedDate = DateTime.Now,
            //        SupplyChainUnitId = RRFServiceIntegration.BranchID,
            //        OrderStatus = 1,
            //        FormId = formid
            //    };
            //    // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"];
            //    // Set order properties

            //    //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense
            //    //  order.ReportingPeriodId = periods[0].Id; //Asked again here?  Because RRFForm already contains this.

            //    var details = new Collection<OrderDetail>();

            //    foreach (DataRow rrfLine in tblRRF.Rows)
            //    {
            //        var detail = new PLITSTransactionalService.OrderDetail();
            //        var rrFormPharmaceutical = items.FirstOrDefault(x => x.ItemId == Convert.ToInt32(rrfLine["ID"]));
            //        if (rrfLine != null && rrFormPharmaceutical != null)
            //        //detail.Adjustments[0].Amount =  (int)rrfLine["Adjustments"];
            //        {
            //            detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]);
            //            //detail.DaysOutOfStocks = Convert.ToInt32(rrfLine["DaysOutOfStock"]);
            //            detail.EndingBalance = Convert.ToInt32(rrfLine["SOH"]);
            //            //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table.
            //            detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]);
            //            detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]);
            //            detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]);

            //            if (rrFormPharmaceutical != null)
            //                detail.PharmaceuticalId = rrFormPharmaceutical.PharmaceuticalId;
            //            //  detail.PharmaceuticalId = Convert.ToInt32(rrfLine["ItemID"]);
            //            // detail.PharmaceuticalId = pharId;

            //        }
            //        details.Add(detail);
            //    }
            //    order.OrderDetails = details;
            //    orders.Add(order);
            //}

            //// loop through each record and create order & order details objects
            //return orders;
        }