Example #1
0
        private void InitializeData()
        {
            _business          = new RegularOrderBusiness(SystemParam.CurrentUser);
            _orderItemBusiness = new OrderItemBusiness();
            _revenueBusiness   = new RevenueBusiness(SystemParam.CurrentUser);
            _checkedRows       = new Collection <DataGridViewRow>();

            dgvOrdersList.AutoGenerateColumns = false;
            dgvItemsList.AutoGenerateColumns  = false;

            chkUseAdjustment.Checked   = false;
            tbAdjustmentAmount.Enabled = false;
            tbAdjustmentReason.Enabled = false;

            // Initializes header checkbox
            _chkOrdersListHeaderSelectAll = new CheckBox();
            var orderListFirstColumnHeaderCell = this.dgvOrdersList.Columns[0].HeaderCell;

            _chkOrdersListHeaderSelectAll.BackColor       = orderListFirstColumnHeaderCell.Style.BackColor;
            _chkOrdersListHeaderSelectAll.Checked         = true;
            _chkOrdersListHeaderSelectAll.Location        = new Point(9, 5);
            _chkOrdersListHeaderSelectAll.Size            = new Size(16, 16);
            _chkOrdersListHeaderSelectAll.CheckedChanged += new EventHandler(chkOrdersListHeaderSelectAll_CheckedChanged);
            this.dgvOrdersList.Controls.Add(_chkOrdersListHeaderSelectAll);
        }
Example #2
0
        public CreateOrderView()
        {
            InitializeComponent();
            InitializeData();

            _regularBusiness   = new RegularOrderBusiness(SystemParam.CurrentUser);
            _irregularBusiness = new IrregularOrderBusiness(SystemParam.CurrentUser);
        }
Example #3
0
        private void InitializeData()
        {
            _business             = new CustomerBusiness(SystemParam.CurrentUser);
            _regularOrderBusiness = new RegularOrderBusiness(SystemParam.CurrentUser);

            dgvCustomersList.AutoGenerateColumns = false;
            dgvOpenOrders.AutoGenerateColumns    = false;
            dgvClosedOrders.AutoGenerateColumns  = false;

            ChangeControlStatus(false);
            btnCloseOrders.Enabled = false;
        }
        public string CreateOrder(TOrder torder, List <TOrderItem> torderItems, string userId)
        {
            try
            {
                //Check Order
                string errorMessage = CheckOrder(torder);

                //check OrderItem
                List <OrderItem> orderItems = ThriftUtil.ConvertToOrderItemList(torderItems);
                errorMessage += CheckOrderItems(orderItems);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                string orderId = string.Empty;
                //Insert Order
                if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    using (RegularOrderBusiness business = new RegularOrderBusiness())
                    {
                        business.Insert(ThriftUtil.ConvertToRegualrOrder(torder));
                    }
                }
                else
                {
                    using (IrregularOrderBusiness business = new IrregularOrderBusiness())
                    {
                        business.Insert(ThriftUtil.ConvertToIrregularOrder(torder));
                    }
                }

                using (OrderItemBusiness business = new OrderItemBusiness())
                {
                    business.Insert(orderItems);
                }

                //notify to the others client station
                //torder.OrderId = orderId;
                //BroadcastToClient(ClientAction.CreateOrder,order,orderItems);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[CreateOrder]", exc);
                return(exc.Message);
            }
        }
 public List <TRegularOrder> LoadRegularOrder()
 {
     try
     {
         using (RegularOrderBusiness business = new RegularOrderBusiness())
         {
             return(business.GetAll().ToList().Select(i => ThriftUtil.ConvertToThriftObject(i) as TRegularOrder).ToList());
         }
     }
     catch (Exception exc)
     {
         ServerLogger.logError("[LoadRegularOrder]", exc);
         return(new List <TRegularOrder>());
     }
 }
        public string UpdateOrderInfo(TOrder torder, List <TOrderItem> orderItems, string userId)
        {
            try
            {
                //Check Order
                string errorMessage = CheckOrder(torder, true);

                //check OrderItem
                errorMessage += orderItems.Count == 0 ? "Không có thông tin hàng hóa" : "";

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    using (RegularOrderBusiness business = new RegularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as RegularOrder);
                    }
                }
                else
                {
                    using (IrregularOrderBusiness business = new IrregularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as IrregularOrder);
                    }
                }

                using (OrderItemBusiness business = new OrderItemBusiness())
                {
                    business.DeleteByOrderId(torder.OrderId);

                    business.Insert(ThriftUtil.ConvertToOrderItemList(orderItems).Cast <OrderItem>());
                }

                //notify to the others client station
                //BroadcastToClient(ClientAction.UpdateOrder,order,orderItems);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[UpdateOrderInfo]", exc);
                return(exc.Message);
            }
        }
        public List <TRegularOrder> SyncRegularOrder()
        {
            try
            {
                IEnumerable <OrderHistory> changedOrderIds;

                using (ThanhVanTranSysEntities context = new ThanhVanTranSysEntities())
                    using (RegularOrderBusiness business = new RegularOrderBusiness())
                    {
                        //insert/update records
                        changedOrderIds = context.OrderHistories
                                          .Where(i => i.date_time.Year == DateTime.Now.Year && i.date_time.Month == DateTime.Now.Month && i.date_time.Day == DateTime.Now.Day)
                                          .OrderBy(i => i.order_id).ThenBy(i => i.date_time);

                        var orders = (from io in business.GetAll()
                                      join co in changedOrderIds on io.id equals co.order_id
                                      select ThriftUtil.ConvertToTRegularOrder(io, co.action == Constants.DELETE_ACTION)).ToList();

                        //deleted records
                        orders.AddRange((from o in changedOrderIds
                                         where o.action == Constants.DELETE_ACTION
                                         select new TRegularOrder()
                        {
                            OrderId = o.order_id,
                            IsDeleted = true,
                            CloseDate = DateTime.Now.ToString(),
                            CreateBy = string.Empty,
                            CreateDate = DateTime.Now.ToString(),
                            Destination = string.Empty,
                            OrderStaus = string.Empty,
                            PaymentStatus = string.Empty,
                            RecipientId = string.Empty,
                            SenderId = string.Empty,
                            TotalCost = 0,
                            TotalQuantity = 0,
                            TotalValue = 0,
                        }));

                        return(orders);
                    }
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[LoadRegularOrder]", exc);
                return(new List <TRegularOrder>());
            }
        }
        private void InistializeData()
        {
            // Initializes object instance
            _business         = new RegularOrderBusiness(SystemParam.CurrentUser);
            _customerBusiness = new CustomerBusiness();

            // Disables created date range criteria
            dtpCreatedDateFrom.Enabled = false;
            dtpCreatedDateTo.Enabled   = false;

            dgvOrdersList.AutoGenerateColumns = false;

            // Binds data source for delivery status drop-down list
            var deliveryStatusesList = typeof(Constants.DeliveryStatus).ToList <string>();

            deliveryStatusesList.Insert(0, new KeyValuePair <string, string>("--", "Tất cả"));
            this.cboDeliveryStatusCriteria.DisplayMember = "Value";
            this.cboDeliveryStatusCriteria.ValueMember   = "Key";
            this.cboDeliveryStatusCriteria.DataSource    = deliveryStatusesList;

            // Binds data source for destination drop-down list
            List <KeyValuePair <string, string> > destinations = new List <KeyValuePair <string, string> >();

            foreach (var tour in (new TourBusiness()).GetAll())
            {
                string displayText = string.Format("{0} - {1}", tour.start, tour.destination);
                if (!destinations.Exists(e => e.Key.Equals(tour.destination)))
                {
                    destinations.Add(new KeyValuePair <string, string>(tour.id, displayText));
                }
            }
            cboDestination.ValueMember   = "Key";
            cboDestination.DisplayMember = "Value";
            cboDestination.DataSource    = destinations;

            // Sets display text for Delivery Status radio buttons
            rbtnDeliveryStatus_Waiting.Text    = Constants.DeliveryStatus.Waiting.GetDescription();
            rbtnDeliveryStatus_Delivering.Text = Constants.DeliveryStatus.Delivering.GetDescription();
            rbtnDeliveryStatus_Arrived.Text    = Constants.DeliveryStatus.Arrived.GetDescription();
            rbtnDeliveryStatus_Delivered.Text  = Constants.DeliveryStatus.Delivered.GetDescription();
            rbtnDeliveryStatus_Closed.Text     = Constants.DeliveryStatus.Closed.GetDescription();

            // Disables order details
            ClearOrderDetails();
            ChangeOrderDetailsEditingStatus(false);
        }
        /// <summary>
        /// CompleteOrder (just using for Irregular Order)
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public string DeleteOrder(TOrder order, string userId)
        {
            try
            {
                // Check Order
                string errorMessage = CheckOrder(order, true);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                // Delete
                if (order.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    RegularOrderBusiness business = new RegularOrderBusiness();
                    business.Delete(order.OrderId);
                }
                else
                {
                    IrregularOrderBusiness business = new IrregularOrderBusiness();
                    business.Delete(order.OrderId);
                }

                OrderItemBusiness itemBusiness = new OrderItemBusiness();
                itemBusiness.DeleteByOrderId(order.OrderId);

                ////notify to the others client station
                ////BroadcastToClient(ClientAction.CompleteOrder,order);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[DeleteOrder]", exc);
                return(exc.Message);
            }
        }
        public string UpdateSingleOrderInfo(TOrder torder, string userId)
        {
            try
            {
                //Check Order
                string errorMessage = CheckOrder(torder, true);

                if (string.IsNullOrEmpty(errorMessage) == false)
                {
                    return(errorMessage);
                }

                if (torder.Type == Constants.VALUE_ORDER_TYPE_REGULAR)
                {
                    using (RegularOrderBusiness business = new RegularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as RegularOrder);
                    }
                }
                else
                {
                    using (IrregularOrderBusiness business = new IrregularOrderBusiness())
                    {
                        business.Update(ThriftUtil.ConvertToEntityObject(torder) as IrregularOrder);
                    }
                }

                //notify to the others client station
                //BroadcastToClient(ClientAction.UpdateOrder,order,orderItems);

                return("");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[UpdateSingleOrderInfo]", exc);
                return(exc.Message);
            }
        }
        protected string CheckOrder(TOrder torder, bool isUpdated = false)
        {
            StringBuilder errorMessage = new StringBuilder();

            if (isUpdated)
            {
                EntityObject existOrder = null;
                if (torder.Type == Constants.VALUE_ORDER_TYPE_IRREGULAR)
                {
                    existOrder = new IrregularOrderBusiness().Get(torder.OrderId);
                }
                else
                {
                    existOrder = new RegularOrderBusiness().Get(torder.OrderId);
                }

                if (existOrder == null)
                {
                    errorMessage.AppendLine(string.Format("{0}Hóa đơn vận chuyển không tồn tại", Constants.SERVER_ERROR_CODE_SINGLE_DATA_NOT_SYNC));
                }
            }

            return(errorMessage.ToString());
        }