/// <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; }
/// <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 = "-"; }
/// <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 = "-"; } }
/// <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 OnApprovedOrderRowClicked(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { if (e != null && e.RowHandle < -1) { return; } var gv = (GridView)sender; var dr = gv.GetFocusedDataRow(); _orderID = Convert.ToInt32(dr["ID"].ToString()); order.LoadByPrimaryKey(_orderID); // populate the general order variables txtPickListFromStore.Text = order.GetFromStore(); lblMode.Text = order.GetFromStore() ?? "-"; txtPickListRequestedBy.Text = order.GetRequestedBy(); labelControl9.Text = order.GetRequestedBy() ?? "-"; var us = new BLL.User(); us.LoadByPrimaryKey(order.FilledBy); lblFilledBy.Text = us.FullName ?? "-"; string s = ""; lblLetterNum.Text = String.IsNullOrEmpty(order.LetterNo) ? "-" : order.LetterNo; var orderDetail = new OrderDetail(); orderDetail.LoadAllByOrderID(order.ID); var paymentType = new BLL.PaymentType(); paymentType.LoadByPrimaryKey(order.PaymentTypeID); if (!orderDetail.IsColumnNull("StoreID")) { var activity = new Activity(); activity.LoadByPrimaryKey(orderDetail.StoreID); lblMode.Text = activity.ModeName ?? "-"; } lblIssueStatus.Text = (string)dr["OrderStatus"] ?? "-"; lblIssueType.Text = (string)dr["Description"] ?? "-"; if (!order.IsColumnNull("RequestedBy")) { var ins = new Institution(); ins.LoadByPrimaryKey(order.RequestedBy); var ownership = new BLL.OwnershipType(); ownership.LoadByPrimaryKey(ins.Ownership); int length = ins.Name.Length; HeaderSection.Text = ins.Name + s.PadRight(150 - length) + "Order Number: " + order.RefNo; lblOwnership.Text = ownership.Name ?? "-"; lblZone.Text = ins.ZoneName ?? "-"; lblWoreda.Text = ins.WoredaName ?? "-"; lblRegion.Text = ins.RegionName ?? "-"; lblInstitutionType.Text = ins.InstitutionTypeName ?? "-"; } else { HeaderSection.Text = lblOwnership.Text = lblZone.Text = lblWoreda.Text = lblRegion.Text = lblInstitutionType.Text = "-"; } lblPaymentType.Text = paymentType.Name; lblOrderDate.Text = order.Date.ToShortDateString(); txtPickListOrderNumber.Text = order.RefNo; labelControl12.Text = order.RefNo; txtPickListApprovedBy.Text = order.GetApprovedBy(); labelControl13.Text = order.GetApprovedBy(); if (order.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED) { PickList pl = new PickList(); gridPickListDetail.DataSource = pl.GetPickListDetailsForOrder(_orderID); btnPrintAndSavePickList.Text = @"Confirm"; colPrice.FieldName = "Cost"; colSKU.FieldName = "Packs"; btnCancelPickList.Enabled = (BLL.Settings.UseNewUserManagement)? this.HasPermission("Cancel-Pick-List"):true; pl.LoadByOrderID(_orderID); if (!pl.IsColumnNull("PickedBy")) { us.LoadByPrimaryKey(pl.PickedBy); lblPicklistPrintedBy.Text = us.FullName; } else { lblPicklistPrintedBy.Text = "-"; } lblPicklistPrintedDate.Text = !pl.IsColumnNull("SavedDate") ? pl.SavedDate.ToShortDateString() : "-"; lblPicklistNo.Text = !pl.IsColumnNull("PrintedID") ? pl.PrintedID.ToString() : "-"; } //gridPickListView.EndSummaryUpdate(); }
private void 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); } }