public static IrregularOrder ConvertToIrregularOrder(TIrregularOrder order) { IrregularOrder irregularOrder = new IrregularOrder(); DateTime tempDate; irregularOrder.id = order.OrderId; irregularOrder.created_by = order.CreateBy; irregularOrder.closed_date = DateTime.TryParse(order.CloseDate, out tempDate) ? tempDate : (DateTime?)null; irregularOrder.created_date = DateTime.Parse(order.CreateDate); irregularOrder.order_status = order.OrderStaus; irregularOrder.payment_status = order.PaymentStatus; irregularOrder.recipient_id_card_no = order.RecipientIdNo; irregularOrder.recipient_name = order.RecipientName; irregularOrder.recipient_phone = order.RecipientPhone; irregularOrder.recipient_address = string.Empty; irregularOrder.sender_id_card_no = order.SenderIdNo; irregularOrder.sender_name = order.SenderName; irregularOrder.sender_phone = order.SenderPhone; irregularOrder.sender_address = string.Empty; irregularOrder.total_cost = decimal.Parse(order.TotalCost.ToString());; irregularOrder.total_quantity = order.TotalQuantity; irregularOrder.total_value = decimal.Parse(order.TotalValue.ToString()); irregularOrder.tour_id = order.Destination; irregularOrder.confirmation_user_id = string.Empty; return(irregularOrder); }
public static TIrregularOrder ConvertToTIrregularOrder(IrregularOrder order, bool isDeleted) { TIrregularOrder tirregular = ConvertToTIrregularOrder(order); tirregular.IsDeleted = isDeleted; return(tirregular); }
public static OrderItemReportEntity ConvertFromReportEntity(OrderItem item, IrregularOrder order) { var reportEntity = ConvertFromReportEntity(item); reportEntity.RecipientIdNo = order.recipient_id_card_no; reportEntity.RecipientName = order.recipient_name; reportEntity.RecipientPhone = order.recipient_phone; return(reportEntity); }
private void LoadOrderInfo(IrregularOrder order, Collection <OrderItem> items) { lblOrderIDText.Text = order.id; lblOrderStatusText.Text = EnumHelper.Parse <Constants.DeliveryStatus>(order.order_status).GetDescription(); tbTotalItemsQuantity.Text = order.total_quantity.ToString(); tbTotalCost.Text = CurrencyUtil.ToString(order.total_cost); dgvItemsList.AutoGenerateColumns = false; dgvItemsList.DataSource = items; tbTotalPayment.Text = CurrencyUtil.ToString(order.total_cost); }
public override string Update(IrregularOrder order, Collection <OrderItem> orderItems) { string errorMessage = AutoSync.GetInstance().CheckServerIsFree(); if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ServerConnector.GetInstance().UpdateOrderInfoRequest(order, orderItems.ToList()); } errorMessage = HandleRequestResult(errorMessage); return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Update(order, orderItems)); }
public override string Update(IrregularOrder entity) { string errorMessage = AutoSync.GetInstance().CheckServerIsFree(); if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ServerConnector.GetInstance().UpdateSingleOrderInfoRequest(entity); } errorMessage = HandleRequestResult(errorMessage); return(base.Update(entity)); }
public override string Delete(string id) { IrregularOrder irregularOrder = new IrregularOrder(); irregularOrder.id = id; string errorMessage = AutoSync.GetInstance().CheckServerIsFree(); if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ServerConnector.GetInstance().DeleteOrderInfoRequest(irregularOrder); } errorMessage = HandleRequestResult(errorMessage); return(string.IsNullOrEmpty(errorMessage) == false ? errorMessage : base.Delete(id)); }
public static OrderReportEntity ConvertFromReportEntity(IrregularOrder order) { return(new OrderReportEntity() { OrderId = order.id, OrderStaus = order.order_status, RecipientIdNo = order.recipient_id_card_no, RecipientName = order.recipient_name, RecipientPhone = order.recipient_phone, SenderIdNo = order.sender_id_card_no, SenderName = order.sender_name, SenderPhone = order.sender_phone, TotalCost = Util.CurrencyUtil.ToString(order.total_cost), TotalQuantity = Util.CurrencyUtil.ToString(order.total_quantity), TotalValue = Util.CurrencyUtil.ToString(order.total_value) }); }
/// <summary> /// Converts to regular order. /// </summary> /// <returns>IrregularOrder.</returns> public IrregularOrder ToIrregular() { IrregularOrder irregularOrder = new IrregularOrder(); irregularOrder.id = this.id; irregularOrder.order_status = this.order_status; irregularOrder.payment_status = this.payment_status; irregularOrder.tour_id = this.tour_id; irregularOrder.total_quantity = this.total_quantity; irregularOrder.total_value = this.total_value; irregularOrder.total_cost = this.total_cost; irregularOrder.created_date = this.created_date; irregularOrder.created_by = this.created_by; irregularOrder.closed_date = this.closed_date; irregularOrder.confirmation_user_id = string.Empty; return(irregularOrder); }
private void PopulateOrderDetails(IrregularOrder order) { if (order != null) { tbSenderName.Text = order.sender_name; tbSenderPhoneNumber.Text = order.sender_phone; tbSenderIDCardNo.Text = order.sender_id_card_no; tbSenderAddress.Text = order.sender_address; tbRecipientName.Text = order.recipient_name; tbRecipientPhoneNumber.Text = order.recipient_phone; tbRecipientIDCardNo.Text = order.recipient_id_card_no; tbRecipientAddress.Text = order.recipient_address; lblOrderIdText.Text = order.id; lblCreatedDateText.Text = order.created_date.ToString("dd-MM-yyyy hh:mm:ss"); lblCreatedByText.Text = order.created_by; lblClosedDateText.Text = order.closed_date.HasValue ? order.closed_date.Value.ToString("dd-MM-yyyy hh:mm:ss") : string.Empty; cboTour.SelectedValue = order.tour_id; Constants.DeliveryStatus deliveryStatus; bool parseResult = Enum.TryParse <Constants.DeliveryStatus>(order.order_status, out deliveryStatus); if (parseResult) { CurrentDeliveryStatus = deliveryStatus; } Constants.PaymentStatus paymentStatus; parseResult = Enum.TryParse <Constants.PaymentStatus>(order.payment_status, out paymentStatus); if (parseResult) { CurrentPaymentStatus = paymentStatus; } Collection <OrderItem> items = (new OrderItemBusiness()).GetByOrderId(order.id); tbItemsQuantity.Text = items.Sum(item => item.quantity).ToString(); decimal totalCost = items.Sum(item => item.cost); tbTotalCost.Text = totalCost.ToString("N0"); this.ucItemsList.OrderID = order.id; this.ucItemsList.OrderItems = items; } }
public static TIrregularOrder ConvertToTIrregularOrder(IrregularOrder order) { TIrregularOrder torder = new TIrregularOrder(); torder.OrderId = order.id; torder.CloseDate = order.closed_date.ToString(); torder.CreateBy = order.created_by; torder.CreateDate = order.created_date.ToString(); torder.OrderStaus = order.order_status; torder.PaymentStatus = order.payment_status; torder.RecipientIdNo = order.recipient_id_card_no; torder.RecipientName = order.recipient_name; torder.RecipientPhone = order.recipient_phone; torder.SenderIdNo = order.sender_id_card_no; torder.SenderName = order.sender_name; torder.SenderPhone = order.sender_phone; torder.TotalCost = double.Parse(order.total_cost.ToString()); torder.TotalQuantity = order.total_quantity; torder.TotalValue = double.Parse(order.total_value.ToString()); torder.Destination = order.tour_id; return(torder); }
public override bool HandleSaveTask() { bool success = false; try { IrregularOrder order = SelectedOrder; if (order != null && ValidateInput()) { Constants.PaymentStatus currentPaymentStatus = EnumHelper.Parse <Constants.PaymentStatus>(order.payment_status); // Collects order information Collection <OrderItem> orderItems = new Collection <OrderItem>(); order.sender_name = tbSenderName.Text; order.sender_phone = tbSenderPhoneNumber.Text; order.sender_id_card_no = tbSenderIDCardNo.Text; order.sender_address = tbSenderAddress.Text; order.recipient_name = tbRecipientName.Text; order.recipient_phone = tbRecipientPhoneNumber.Text; order.recipient_id_card_no = tbRecipientIDCardNo.Text; order.recipient_address = tbRecipientAddress.Text; order.tour_id = cboTour.SelectedValue.ToString(); order.order_status = CurrentDeliveryStatus.ToString(); order.payment_status = CurrentPaymentStatus.ToString(); int totalQuantity = 0; decimal totalValue = 0; decimal totalCost = 0; foreach (var item in ucItemsList.OrderItems) { OrderItem newOrderItem = new OrderItem() { id = IDGenerator.NewOrderItemId(order.id, orderItems.Count + 1), order_id = order.id, name = item.name, weight = item.weight, size = item.size, quantity = item.quantity, value = item.value, description = item.description, cost = item.cost, order_item_number = item.order_item_number }; orderItems.Add(newOrderItem); totalQuantity += item.quantity; totalValue += item.value * item.quantity; totalCost += item.cost; } order.total_quantity = totalQuantity; order.total_value = totalValue; order.total_cost = decimal.Parse(tbTotalCost.Text); if (rbtnDeliveryStatus_Closed.Checked) { order.closed_date = DateTime.Now; } if (currentPaymentStatus == Constants.PaymentStatus.Unpaid && rbtnPaymentStatus_Paid.Checked && (new IrregularOrderPaymentView(order, orderItems)).ShowDialog() != DialogResult.OK) { return(false); } string result = _business.Update(order, orderItems); if (string.IsNullOrEmpty(result)) { MessageBox.Show("Đơn hàng đã cập nhật thành công.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None); ChangeOrderDetailsEditingStatus(false); _isEditing = false; success = true; DataBind(); PopulateOrderDetails(order); } else { MessageBox.Show(result, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { AppLogger.logError(this.ToString(), "Error occurs when saving order changes.", ex); MessageBox.Show("Có lỗi xảy ra trong khi cập nhập đơn hàng.", Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(success); }
public IrregularOrderPaymentView(IrregularOrder order, Collection <OrderItem> items) { InitializeComponent(); //Loads order info LoadOrderInfo(order, items); }
private void btnCreateOrder_Click(object sender, EventArgs e) { if (ValidateInput() && MessageBox.Show(Constants.Messages.CREATE_ORDER_CONFIRMATION_MESSAGE, Constants.Messages.CREATE_ORDER_CONFIRMATION_CAPTION, MessageBoxButtons.OKCancel) == DialogResult.OK) { bool success = true; string saveResult = string.Empty; try { // Creates OrderBase instance and gets general info OrderBase order = new OrderBase(); order.id = rbtnOrderType_Regular.Checked ? IDGenerator.NewId <RegularOrder>() : IDGenerator.NewId <IrregularOrder>(); AppLogger.logDebug(this.ToString(), string.Format("Id: {0}", order.id)); order.payment_status = this.rbtnPaymentStatus_Paid.Checked ? Constants.PaymentStatus.Paid.ToString() : Constants.PaymentStatus.Unpaid.ToString(); order.order_status = Constants.DeliveryStatus.Waiting.ToString(); order.tour_id = cboDestination.SelectedValue.ToString(); order.created_date = DateTime.Now; order.created_by = SystemParam.CurrentUser.user_name; int totalQuantity = 0; decimal totalValue = 0; decimal totalCost = 0; foreach (var item in ucItemsList.OrderItems) { item.id = IDGenerator.NewOrderItemId(order.id, ucItemsList.OrderItems.IndexOf(item) + 1); item.order_id = order.id; totalQuantity += item.quantity; totalValue += item.value * item.quantity; totalCost += item.cost; } order.total_quantity = totalQuantity; order.total_value = totalValue; order.total_cost = totalCost; // Convert order info per order type if (rbtnOrderType_Regular.Checked) { RegularOrder regularOrder = order.ToRegular(); regularOrder.sender_id = Sender.id; regularOrder.recipient_id = Recipient.id; saveResult = _regularBusiness.Insert(regularOrder, ucItemsList.OrderItems); } else { IrregularOrder irregularOrder = order.ToIrregular(); irregularOrder.sender_name = tbSenderName.Text; irregularOrder.sender_phone = tbSenderPhoneNumber.Text; irregularOrder.sender_id_card_no = tbSenderIDCardNo.Text; irregularOrder.sender_address = tbSenderAddress.Text; irregularOrder.recipient_name = tbRecipientName.Text; irregularOrder.recipient_phone = tbRecipientPhoneNumber.Text; irregularOrder.recipient_id_card_no = tbRecipientIDCardNo.Text; irregularOrder.recipient_address = tbRecipientAddress.Text; if (rbtnPaymentStatus_Paid.Checked && (new IrregularOrderPaymentView(irregularOrder, ucItemsList.OrderItems)).ShowDialog() != System.Windows.Forms.DialogResult.OK) { AppLogger.logDebug(this.ToString(), "Payment process cancelled."); return; } saveResult = _irregularBusiness.Insert(irregularOrder, ucItemsList.OrderItems); } } catch (Exception ex) { AppLogger.logError(this.ToString(), ex.Message, ex); success = false; } if (success && string.IsNullOrEmpty(saveResult)) { AppLogger.logInfo(this.ToString(), "Finish inserting new order into database."); MessageBox.Show("Đã tạo thành công đơn hàng mới.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { if (string.IsNullOrEmpty(saveResult)) { saveResult = Constants.Messages.CREATE_ORDER_ERROR_MESSAGE; } MessageBox.Show(saveResult, Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }