Пример #1
0
        private bool CustomValidation()
        {
            bool hasError = true;

            errorProvider.Clear();

            if (drlVehicle.SelectedItem == null || Convert.ToInt32(drlVehicle.SelectedValue) == 0)
            {
                errorProvider.SetError(drlVehicle, Constants.Messages.RequireMessage);
                hasError = false;

                drlVehicle.Focus();
            }

            if (drlUser.SelectedItem == null || Convert.ToInt32(drlUser.SelectedValue) == 0)
            {
                errorProvider.SetError(drlUser, Constants.Messages.RequireMessage);
                hasError = false;

                drlUser.Focus();
            }

            if (listOrder.Count == 0)
            {
                errorProvider.SetError(dataGridView, Constants.Messages.RequireMessage);
                hasError = false;

                dataGridView.Focus();
            }

            string ids = string.Empty;

            foreach (var o in listOrder)
            {
                ids = string.Concat(ids, ",", o.Id);
            }

            ids = ids.TrimStart(',');

            var biz      = new DeliveryDetailBiz();
            var orderIds = biz.GetByOrders(ids, itemId);

            if (orderIds != null && orderIds.Count > 0)
            {
                hasError = false;

                for (int i = 0; i < listOrder.Count; i++)
                {
                    if (orderIds.Contains(listOrder[i].Id))
                    {
                        dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView.Refresh();
                    }
                }
            }

            return(hasError);
        }
Пример #2
0
        private void SaveOrders(Delivery delivery)
        {
            var biz = new DeliveryDetailBiz();

            biz.RemoveItemsByDeliveryId(delivery.Id);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                var item = row.DataBoundItem as SearchOrder;

                var detail = new DeliveryDetail();
                detail.DeliveryId = delivery.Id;
                detail.OrderId    = item.Id;
                if (item.DeliveryTime.HasValue)
                {
                    detail.Time = item.DeliveryTime.Value;
                }
                detail.Index = row.Index;

                biz.SaveItem(detail);
            }
        }
Пример #3
0
        private void SaveOrders(Delivery delivery)
        {
            var biz = new DeliveryDetailBiz();
            biz.RemoveItemsByDeliveryId(delivery.Id);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                var item = row.DataBoundItem as SearchOrder;

                var detail = new DeliveryDetail();
                detail.DeliveryId = delivery.Id;
                detail.OrderId = item.Id;
                if (item.DeliveryTime.HasValue)
                {
                    detail.Time = item.DeliveryTime.Value;
                }
                detail.Index = row.Index;

                biz.SaveItem(detail);
            }
        }
Пример #4
0
        private bool CustomValidation()
        {
            bool hasError = true;
            errorProvider.Clear();

            if (drlVehicle.SelectedItem == null || Convert.ToInt32(drlVehicle.SelectedValue) == 0)
            {
                errorProvider.SetError(drlVehicle, Constants.Messages.RequireMessage);
                hasError = false;

                drlVehicle.Focus();
            }

            if (drlUser.SelectedItem == null || Convert.ToInt32(drlUser.SelectedValue) == 0)
            {
                errorProvider.SetError(drlUser, Constants.Messages.RequireMessage);
                hasError = false;

                drlUser.Focus();
            }

            if (listOrder.Count == 0)
            {
                errorProvider.SetError(dataGridView, Constants.Messages.RequireMessage);
                hasError = false;

                dataGridView.Focus();
            }

            string ids = string.Empty;
            foreach(var o in listOrder)
            {
                ids = string.Concat(ids, ",", o.Id);
            }

            ids = ids.TrimStart(',');

            var biz = new DeliveryDetailBiz();
            var orderIds = biz.GetByOrders(ids, itemId);
            if(orderIds != null && orderIds.Count > 0)
            {
                hasError = false;

                for (int i = 0; i < listOrder.Count; i++)
                {
                    if (orderIds.Contains(listOrder[i].Id))
                    {
                        dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                        dataGridView.Refresh();
                    }
                }
            }

            return hasError;
        }