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 btnReturnToApprovalStep_Click(object sender, EventArgs e) { //int ordId = Convert.ToInt32(gridApprovedOrdersView.GetFocusedDataRow()["ID"].ToString()); Order ord = new Order(); ord.LoadByPrimaryKey(_orderID); if (ord.RowCount == 0) { XtraMessageBox.Show("You have to select an Order to return to approval, ", "Error - Select Order"); return; } if (!ord.IsColumnNull("OrderTypeID") && ord.OrderTypeID != OrderType.CONSTANTS.STANDARD_ORDER) { XtraMessageBox.Show("You cannot return this order to approval, you can either cancel or confirm this order", "Error - You cannot return this order"); return; } MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED) { ord.ChangeStatus(OrderStatus.Constant.ORDER_FILLED, CurrentContext.UserId); BindApprovedOrders(); } else if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED) { ord.ReleaseReservation(); ord.ChangeStatus(OrderStatus.Constant.ORDER_FILLED, CurrentContext.UserId); BindApprovedOrders(); } transaction.CommitTransaction(); } catch (Exception exp) { transaction.RollbackTransaction(); throw exp; } gridPickListDetail.DataSource = null; //HCMISLoader.MarkAsDirtyUsingOrderID(_orderID, NewMainWindow.UserId, true); if (BLL.Settings.IsCenter) { XtraMessageBox.Show("The Issue Order List has been returned to approval stage", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("The Pick list has been returned to approval stage", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Formats the STV. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="stvSentTo">The STV sent to.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID) { bool hasInsurance = chkIncludeInsurance.Checked; string accountName = txtConfirmFromStore.Text; string transferType = null; int? orderTypeID = null; BLL.Order order = new Order(); order.LoadByPrimaryKey(orderID); if (!order.IsColumnNull("OrderTypeID")) orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID")); string transferDetail = ""; if (orderTypeID.HasValue) { BLL.Transfer transfer = new Transfer(); if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { transfer.LoadByOrderID(orderID); PhysicalStore toStore = new PhysicalStore(); toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.Warehouse toWarehouse = new BLL.Warehouse(); toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID); transferType = "Store to Store Transfer"; stvSentTo = toWarehouse.Name; } if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { transfer.LoadByOrderID(orderID); Activity fromActivity = new Activity(); fromActivity.LoadByPrimaryKey(transfer.FromStoreID); Activity toActivity = new Activity(); toActivity.LoadByPrimaryKey(transfer.ToStoreID); transferType = "Account to Account Transfer"; transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName); } } if (!deliveryNote) { if(InstitutionIType.IsVaccine(GeneralInfo.Current)) { return WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); } var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); if (transferDetail != "") { stvReport.TransferDetails.Text = transferDetail; stvReport.TransferDetails.Visible = true; } else { stvReport.TransferDetails.Visible = false; } return stvReport; } else { return WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); } }
/// <summary> /// Handles the Click event of the btnConfirmIssue control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// <exception cref="System.Exception"></exception> private void btnConfirmIssue_Click(object sender, EventArgs e) { // This is where the Issue is actually recorded and the stv is printed. // Do all kinds of validations. XtraReport STVReport = null; XtraReport DeliveryNoteReport = null; btnConfirmIssue1.Enabled = false; if (!IssueValid()) { XtraMessageBox.Show("Please Correct the Items Marked in Red before Proceeding with Issue", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); return; } if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DateTimePickerEx dtDate = ConvertDate.GetCurrentEthiopianDateText(); DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); // The User is now sure that the STV has to be printed and that // the order is also good to save. // This is the section that does the saving. BLL.Order order = new Order(); order.LoadByPrimaryKey(_orderID); // what are the pick lists, do we have devliery notes too? DataView dv = _dvOutstandingPickList; DataTable dvUnpriced = new DataTable(); DataTable dvPriced = dv.ToTable(); if (BLL.Settings.HandleGRV) { if (BLL.Settings.IsCenter) dv.RowFilter = "(Cost is null or Cost=0)"; else dv.RowFilter = "DeliveryNote = true and (Cost is null or Cost=0)"; dvUnpriced = dv.ToTable(); dv.RowFilter = "Cost is not null and Cost <> 0"; dvPriced = dv.ToTable(); } else { dvPriced = dv.ToTable(); } string stvPrinterName = ""; string deliveryNotePrinter = ""; if (!ConfirmPrinterSettings(dvPriced, dvUnpriced, out stvPrinterName, out deliveryNotePrinter)) return; bool saveSuccessful = false; MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { if (dvPriced.Rows.Count == 0 && dvUnpriced.Rows.Count == 0) throw new Exception("The Items doesn’t meet the requirement: please check the price status for non-delivery notes!"); mgr.BeginTransaction(); if (dvPriced.Rows.Count > 0) { STVReport = SaveAndPrintSTV(dvPriced.DefaultView, false, stvPrinterName, dtDate, dtCurrent); } if (dvUnpriced.Rows.Count > 0) { DeliveryNoteReport = SaveAndPrintSTV(dvUnpriced.DefaultView, true, deliveryNotePrinter, dtDate, dtCurrent); } var ordr = new Order(); ordr.LoadByPrimaryKey(_orderID); if (!ordr.IsColumnNull("OrderTypeID") && (ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER || ordr.OrderTypeID == BLL.OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)) { var transfer = new Transfer(); DateTime convertedEthDate = ConvertDate.DateConverter(dtDate.Text); transfer.CommitAccountToAccountTransfer(ordr.ID, CurrentContext.UserId, convertedEthDate); } mgr.CommitTransaction(); saveSuccessful = true; } catch (Exception exp) { mgr.RollbackTransaction(); //Removed the reset logic //MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgrReset(); XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ErrorHandler.Handle(exp); saveSuccessful = false; } if (saveSuccessful) { if (STVReport != null) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { for (int i = 0; i < BLL.Settings.STVCopies; i++) { STVReport.Print(stvPrinterName); } } else { STVReport.Print(stvPrinterName); } } if (DeliveryNoteReport != null) { DeliveryNoteReport.Print(deliveryNotePrinter); } XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); BindOutstandingPicklists(); gridOutstandingPicklistDetail.DataSource = null; PalletLocation.GarbageCollection(); if (BLL.Settings.AllowOnlineOrders) { Helpers.RRFServiceIntegration.SubmitOnlineIssue(_orderID); } } }
private Order GenerateOrder() { var or = new Order(); if (OrderID == null) or.AddNew(); else or.LoadByPrimaryKey(OrderID.Value); or.RefNo = Order.GetNextOrderReference(); txtRefNo.Text = or.RefNo; var oldOrderStatus = or.IsColumnNull("OrderStatusID") ? (int?)null : or.OrderStatusID; or.OrderStatusID = OrderStatus.Constant.PICK_LIST_GENERATED; //or.Remark = txtRemark.Text; or.EurDate = or.Date = DateTimeHelper.ServerDateTime; //Both fields are assigned dates. if (TransferTypeID == 1) or.RequestedBy = Convert.ToInt32(lkForHub.EditValue); or.FilledBy = CurrentContext.UserId; or.ContactPerson = txtContactPerson.Text; var activity = new Activity(); activity.LoadByPrimaryKey(Convert.ToInt32(lkAccountType.EditValue)); or.FromStore = activity.ModeID; if (BLL.Settings.IsCenter) { //What the Hell is this? or.PaymentTypeID = PaymentType.Constants.STV; } else { or.PaymentTypeID = PaymentType.Constants.STV; } or.FiscalYearID = FiscalYear.Current.ID; or.Save(); or.LogRequisitionStatus(or.ID, oldOrderStatus, OrderStatus.Constant.PICK_LIST_GENERATED,CurrentContext.UserId); return or; }
/// <summary> /// Formats the STV. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="stvSentTo">The STV sent to.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID) { bool hasInsurance = chkIncludeInsurance.Checked; string accountName = txtConfirmFromStore.Text; string transferType = null; int?orderTypeID = null; BLL.Order order = new Order(); order.LoadByPrimaryKey(orderID); if (!order.IsColumnNull("OrderTypeID")) { orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID")); } string transferDetail = ""; if (orderTypeID.HasValue) { BLL.Transfer transfer = new Transfer(); if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { transfer.LoadByOrderID(orderID); PhysicalStore toStore = new PhysicalStore(); toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.Warehouse toWarehouse = new BLL.Warehouse(); toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID); transferType = "Store to Store Transfer"; stvSentTo = toWarehouse.Name; } if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { transfer.LoadByOrderID(orderID); Activity fromActivity = new Activity(); fromActivity.LoadByPrimaryKey(transfer.FromStoreID); Activity toActivity = new Activity(); toActivity.LoadByPrimaryKey(transfer.ToStoreID); transferType = "Account to Account Transfer"; transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName); } } if (!deliveryNote) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { return(WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); if (transferDetail != "") { stvReport.TransferDetails.Text = transferDetail; stvReport.TransferDetails.Visible = true; } else { stvReport.TransferDetails.Visible = false; } return(stvReport); } else { return(WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } }
/// <summary> /// Handles the Click event of the btnConfirmIssue control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// <exception cref="System.Exception"></exception> private void btnConfirmIssue_Click(object sender, EventArgs e) { // This is where the Issue is actually recorded and the stv is printed. // Do all kinds of validations. XtraReport STVReport = null; XtraReport DeliveryNoteReport = null; btnConfirmIssue1.Enabled = false; if (!IssueValid()) { XtraMessageBox.Show("Please Correct the Items Marked in Red before Proceeding with Issue", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); return; } if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DateTimePickerEx dtDate = ConvertDate.GetCurrentEthiopianDateText(); DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); // The User is now sure that the STV has to be printed and that // the order is also good to save. // This is the section that does the saving. BLL.Order order = new Order(); order.LoadByPrimaryKey(_orderID); // what are the pick lists, do we have devliery notes too? DataView dv = _dvOutstandingPickList; DataTable dvUnpriced = new DataTable(); DataTable dvPriced = dv.ToTable(); if (BLL.Settings.HandleGRV) { if (BLL.Settings.IsCenter) { dv.RowFilter = "(Cost is null or Cost=0)"; } else { dv.RowFilter = "DeliveryNote = true and (Cost is null or Cost=0)"; } dvUnpriced = dv.ToTable(); dv.RowFilter = "Cost is not null and Cost <> 0"; dvPriced = dv.ToTable(); } else { dvPriced = dv.ToTable(); } string stvPrinterName = ""; string deliveryNotePrinter = ""; if (!ConfirmPrinterSettings(dvPriced, dvUnpriced, out stvPrinterName, out deliveryNotePrinter)) { return; } bool saveSuccessful = false; MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { if (dvPriced.Rows.Count == 0 && dvUnpriced.Rows.Count == 0) { throw new Exception("The Items doesn’t meet the requirement: please check the price status for non-delivery notes!"); } mgr.BeginTransaction(); if (dvPriced.Rows.Count > 0) { STVReport = SaveAndPrintSTV(dvPriced.DefaultView, false, stvPrinterName, dtDate, dtCurrent); } if (dvUnpriced.Rows.Count > 0) { DeliveryNoteReport = SaveAndPrintSTV(dvUnpriced.DefaultView, true, deliveryNotePrinter, dtDate, dtCurrent); } var ordr = new Order(); ordr.LoadByPrimaryKey(_orderID); if (!ordr.IsColumnNull("OrderTypeID") && (ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER || ordr.OrderTypeID == BLL.OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)) { var transfer = new Transfer(); DateTime convertedEthDate = ConvertDate.DateConverter(dtDate.Text); transfer.CommitAccountToAccountTransfer(ordr.ID, CurrentContext.UserId, convertedEthDate); } mgr.CommitTransaction(); saveSuccessful = true; } catch (Exception exp) { mgr.RollbackTransaction(); //Removed the reset logic //MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgrReset(); XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ErrorHandler.Handle(exp); saveSuccessful = false; } if (saveSuccessful) { if (STVReport != null) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { for (int i = 0; i < BLL.Settings.STVCopies; i++) { STVReport.Print(stvPrinterName); } } else { STVReport.Print(stvPrinterName); } } if (DeliveryNoteReport != null) { DeliveryNoteReport.Print(deliveryNotePrinter); } XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); BindOutstandingPicklists(); gridOutstandingPicklistDetail.DataSource = null; PalletLocation.GarbageCollection(); if (BLL.Settings.AllowOnlineOrders) { Helpers.RRFServiceIntegration.SubmitOnlineIssue(_orderID); } } }
private void btnReturnToApprovalStep_Click(object sender, EventArgs e) { //int ordId = Convert.ToInt32(gridApprovedOrdersView.GetFocusedDataRow()["ID"].ToString()); Order ord = new Order(); ord.LoadByPrimaryKey(_orderID); if (ord.RowCount == 0) { XtraMessageBox.Show("You have to select an Order to return to approval, ", "Error - Select Order"); return; } if(!ord.IsColumnNull("OrderTypeID") && ord.OrderTypeID != OrderType.CONSTANTS.STANDARD_ORDER) { XtraMessageBox.Show("You cannot return this order to approval, you can either cancel or confirm this order", "Error - You cannot return this order"); return; } MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED) { ord.ChangeStatus(OrderStatus.Constant.ORDER_FILLED,CurrentContext.UserId); BindApprovedOrders(); } else if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED) { ord.ReleaseReservation(); ord.ChangeStatus(OrderStatus.Constant.ORDER_FILLED,CurrentContext.UserId); BindApprovedOrders(); } transaction.CommitTransaction(); } catch(Exception exp) { transaction.RollbackTransaction(); throw exp; } gridPickListDetail.DataSource = null; //HCMISLoader.MarkAsDirtyUsingOrderID(_orderID, NewMainWindow.UserId, true); if (BLL.Settings.IsCenter) { XtraMessageBox.Show("The Issue Order List has been returned to approval stage", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("The Pick list has been returned to approval stage", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } }