Beispiel #1
0
        private void RefreshItems(object sender, EventArgs e)
        {
            var biz = new DeliveryBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Beispiel #2
0
        private Delivery SaveDelivery(Delivery item)
        {
            item.DeliveryDate     = dateStartDate.Value;
            item.StartTime        = TimeSpan.Parse(dateTimeStartTime.Value.ToString(@"hh\:mm"));
            item.OtherInformation = textOtherInformation.Text;
            item.VehicleId        = Convert.ToInt32(drlVehicle.SelectedValue);
            item.StaffId          = Convert.ToInt32(drlUser.SelectedValue);

            if (itemId > 0)
            {
                item.Id              = itemId;
                item.Created         = created;
                item.CreatedByUserId = createdBy;

                if (string.IsNullOrEmpty(item.IsSendEmail))
                {
                    item.IsSendEmail = labelSendEmail.Text;
                }

                if (string.IsNullOrEmpty(item.IsSendSms))
                {
                    item.IsSendSms = labelSendSms.Text;
                }

                item.DeliveryNo = labelDeliveryNo.Text;
                item.Status     = labelStatus.Text;

                item.Modified         = DateTime.Now;
                item.ModifiedByUserId = currentUser.Id;

                var biz = new DeliveryBiz();
                biz.UpdateItem(item);
            }
            else
            {
                item.Status          = Constants.DeliveryStatusDraft;
                item.Created         = DateTime.Now;
                item.CreatedByUserId = currentUser.Id;
                if (string.IsNullOrEmpty(item.IsSendEmail))
                {
                    item.IsSendEmail = Constants.DeliverySendEmail;
                }

                if (string.IsNullOrEmpty(item.IsSendSms))
                {
                    item.IsSendSms = Constants.DeliverySendSms;
                }

                item.Modified         = DateTime.Now;
                item.ModifiedByUserId = currentUser.Id;

                var biz = new DeliveryBiz();
                biz.SaveItem(item);
            }

            SaveOrders(item);

            return(item);
        }
Beispiel #3
0
        private void WorkAsyncCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var biz = new DeliveryBiz();

            dataGridView.DataSource = null;
            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();
        }
Beispiel #4
0
        private void CreateBoundHierarchy()
        {
            var deliveryBiz = new DeliveryBiz();

            using (this.radGridView.DeferRefresh())
            {
                this.radGridView.MasterTemplate.Reset();
                this.radGridView.AutoGenerateColumns  = true;
                this.radGridView.AllowCellContextMenu = false;
                this.radGridView.ReadOnly             = true;

                this.radGridView.TableElement.RowHeight = 20;
                this.radGridView.DataSource             = deliveryBiz.GetTemplateData();
                this.radGridView.MasterTemplate.Columns["Vehicle"].HeaderText      = "Xe";
                this.radGridView.MasterTemplate.Columns["DeliveryNo"].HeaderText   = "Số giao hàng";
                this.radGridView.MasterTemplate.Columns["DeliveryDate"].HeaderText = "Ngày giao";
                this.radGridView.MasterTemplate.Columns["StartTime"].HeaderText    = "Giờ giao";
                this.radGridView.MasterTemplate.Columns["Status"].HeaderText       = "Tình trạng";
                this.radGridView.MasterTemplate.Columns["Id"].IsVisible            = false;
                this.radGridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

                var orderBiz = new OrderBiz();

                GridViewTemplate template = new GridViewTemplate();

                template.AutoGenerateColumns  = true;
                template.AllowAddNewRow       = false;
                template.AllowCellContextMenu = false;
                template.ReadOnly             = true;

                template.DataSource = orderBiz.GetTemplateData();
                this.radGridView.Templates.Add(template);
                template.Columns["OrderNo"].HeaderText          = "Mã đơn hàng";
                template.Columns["Status"].HeaderText           = "Tình trạng";
                template.Columns["Customer"].HeaderText         = "Khách hàng";
                template.Columns["DeliveryDate"].HeaderText     = "Ngày giao";
                template.Columns["DeliveryInternal"].HeaderText = "Hình thức vận chuyển";
                template.Columns["SendMessage"].HeaderText      = "Tin nhắn";
                template.Columns["SendEmail"].HeaderText        = "Email";
                template.Columns["SendReport"].HeaderText       = "Thông báo";
                template.Columns["Id"].IsVisible         = false;
                template.Columns["ParentId"].IsVisible   = false;
                template.Columns["Recipient"].IsVisible  = false;
                template.Columns["CustomerId"].IsVisible = false;

                template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

                GridViewRelation relation = new GridViewRelation(radGridView.MasterTemplate, template);
                relation.RelationName = "SuppliersProducts";
                relation.ParentColumnNames.Add("Id");
                relation.ChildColumnNames.Add("ParentId");
                this.radGridView.Relations.Add(relation);

                FormatCell();
            }
        }
Beispiel #5
0
        public void DeleteSingleItem(object sender, EventArgs e)
        {
            if (selectedId > 0)
            {
                var biz = new DeliveryBiz();

                biz.RemoveSingleItem(selectedId);
                RefreshItems(sender, e);
            }
        }
Beispiel #6
0
        public void DeliverItem(object sender, EventArgs e)
        {
            if (selectedId > 0)
            {
                var biz = new DeliveryBiz();
                biz.UpdateStatus(selectedId, ECommon.Constants.DeliveryStatusDelivered);

                RefreshItems(sender, e);
            }
        }
Beispiel #7
0
        void SendSms(int id)
        {
            var biz    = new DeliveryBiz();
            var status = biz.SendSms(id, currentUser.FullName);

            if (!string.IsNullOrEmpty(status.Error))
            {
                MessageBox.Show(status.Error);
            }
            biz.UpdateSmsStatus(id, status.Status);
        }
Beispiel #8
0
        public DeliveryView(User user)
        {
            InitializeComponent();
            selectedRow = -1;

            dataGridView.AutoGenerateColumns = false;

            var biz = new DeliveryBiz();
            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();

            currentUser = user;
            flagSendMail = false;
            flagSendSms = false;

            backgroundWorker.DoWork += new DoWorkEventHandler(WorkAsync);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkAsyncCompleted);
        }
Beispiel #9
0
        public DeliveryView(User user)
        {
            InitializeComponent();
            selectedRow = -1;

            dataGridView.AutoGenerateColumns = false;

            var biz = new DeliveryBiz();

            dataGridView.DataSource = biz.LoadItems();
            dataGridView.Refresh();

            currentUser  = user;
            flagSendMail = false;
            flagSendSms  = false;

            backgroundWorker.DoWork             += new DoWorkEventHandler(WorkAsync);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkAsyncCompleted);
        }
Beispiel #10
0
        private bool CheckSecurity(int id)
        {
            if (id == 0)
            {
                return(false);
            }

            var biz     = new DeliveryBiz();
            var current = biz.LoadItem(id);

            if (current != null)
            {
                if (current.Modified.Value != modified.Value)
                {
                    MessageBox.Show(Constants.Messages.ConflictOrderMessage);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #11
0
        public DeliveryView(User user, bool isSendMail = false, bool isSendSms = false, int itemId = 0)
        {
            InitializeComponent();
            selectedRow = -1;

            dataGridView.AutoGenerateColumns = false;

            var biz  = new DeliveryBiz();
            var list = biz.LoadItems();

            dataGridView.DataSource = list;
            dataGridView.Refresh();

            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].Id == itemId)
                    {
                        selectedRow = i;
                        break;
                    }
                }
            }

            currentUser = user;

            backgroundWorker.DoWork             += new DoWorkEventHandler(WorkAsync);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkAsyncCompleted);
            this.flagSendMail = isSendMail;
            this.flagSendSms  = isSendSms;

            if (isSendMail || isSendSms)
            {
                backgroundWorker.RunWorkerAsync(itemId);
            }
        }
Beispiel #12
0
        public DeliveryView(User user, bool isSendMail = false, bool isSendSms = false, int itemId = 0)
        {
            InitializeComponent();
            selectedRow = -1;

            dataGridView.AutoGenerateColumns = false;

            var biz = new DeliveryBiz();
            var list = biz.LoadItems();
            dataGridView.DataSource = list;
            dataGridView.Refresh();

            if(list != null && list.Count > 0)
            {
                for(int i=0;i<list.Count;i++)
                {
                    if (list[i].Id == itemId)
                    {
                        selectedRow = i;
                        break;
                    }
                }
            }

            currentUser = user;

            backgroundWorker.DoWork += new DoWorkEventHandler(WorkAsync);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkAsyncCompleted);
            this.flagSendMail = isSendMail;
            this.flagSendSms = isSendSms;

            if (isSendMail || isSendSms)
            {
                backgroundWorker.RunWorkerAsync(itemId);
            }
        }
Beispiel #13
0
 private void RefreshItems(object sender, EventArgs e)
 {
     var biz = new DeliveryBiz();
     dataGridView.DataSource = biz.LoadItems();
     dataGridView.Refresh();
 }
Beispiel #14
0
 private void WorkAsyncCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     var biz = new DeliveryBiz();
     dataGridView.DataSource = null;
     dataGridView.DataSource = biz.LoadItems();
     dataGridView.Refresh();
 }
Beispiel #15
0
        public DeliveryForm(int id, User user)
        {
            InitializeComponent();

            InitForm(user);

            var lockBiz  = new LockingBiz();
            var lockItem = lockBiz.LoadItem(Constants.TableNameDelivery, user.Id, id);

            if (lockItem == null)
            {
                lockBiz.LockItem(Constants.TableNameDelivery, id, user.Id);
            }
            else
            {
                groupBox1.Enabled = false;
                groupBox3.Enabled = false;
                groupBox4.Enabled = false;

                buttonSave.Enabled      = false;
                buttonSendEmail.Enabled = false;
                buttonSendSms.Enabled   = false;

                var userBiz    = new UserBiz();
                var lockedUser = userBiz.LoadItem(lockItem.CurrentUserId);
                lockedUserName = lockedUser.FullName;
                isLocked       = true;
            }

            drlVehicle.Focus();
            itemId = id;

            var biz  = new DeliveryBiz();
            var item = biz.LoadItem(id);

            created    = item.Created;
            createdBy  = item.CreatedByUserId;
            modified   = item.Modified;
            modifiedBy = item.ModifiedByUserId;

            labelDeliveryNo.Text = item.DeliveryNo;
            labelStatus.Text     = item.Status;
            labelSendSms.Text    = item.IsSendSms;
            labelSendEmail.Text  = item.IsSendEmail;

            if (item.DeliveryDate.HasValue)
            {
                dateStartDate.Value = item.DeliveryDate.Value;
            }
            if (item.StartTime.HasValue)
            {
                dateTimeStartTime.Value = DateTime.Now + item.StartTime.Value;
            }

            textOtherInformation.Text = item.OtherInformation;
            if (item.VehicleId.HasValue)
            {
                drlVehicle.SelectedValue = item.VehicleId.Value;
            }
            if (item.StaffId.HasValue)
            {
                drlUser.SelectedValue = item.StaffId.Value;
            }

            LoadOrders(item);

            this.Text = "Cập nhật thông tin giao hàng";
        }
Beispiel #16
0
        private Delivery SaveDelivery(Delivery item)
        {
            item.DeliveryDate = dateStartDate.Value;
            item.StartTime = TimeSpan.Parse(dateTimeStartTime.Value.ToString(@"hh\:mm"));
            item.OtherInformation = textOtherInformation.Text;
            item.VehicleId = Convert.ToInt32(drlVehicle.SelectedValue);
            item.StaffId = Convert.ToInt32(drlUser.SelectedValue);

            if (itemId > 0)
            {
                item.Id = itemId;
                item.Created = created;
                item.CreatedByUserId = createdBy;

                if (string.IsNullOrEmpty(item.IsSendEmail))
                {
                    item.IsSendEmail = labelSendEmail.Text;
                }

                if (string.IsNullOrEmpty(item.IsSendSms))
                {
                    item.IsSendSms = labelSendSms.Text;
                }

                item.DeliveryNo = labelDeliveryNo.Text;
                item.Status = labelStatus.Text;

                item.Modified = DateTime.Now;
                item.ModifiedByUserId = currentUser.Id;

                var biz = new DeliveryBiz();
                biz.UpdateItem(item);
            }
            else
            {
                item.Status = Constants.DeliveryStatusDraft;
                item.Created = DateTime.Now;
                item.CreatedByUserId = currentUser.Id;
                if (string.IsNullOrEmpty(item.IsSendEmail))
                {
                    item.IsSendEmail = Constants.DeliverySendEmail;
                }

                if (string.IsNullOrEmpty(item.IsSendSms))
                {
                    item.IsSendSms = Constants.DeliverySendSms;
                }

                item.Modified = DateTime.Now;
                item.ModifiedByUserId = currentUser.Id;

                var biz = new DeliveryBiz();
                biz.SaveItem(item);
            }

            SaveOrders(item);

            return item;
        }
Beispiel #17
0
        private bool CheckSecurity(int id)
        {
            if (id == 0) return false;

            var biz = new DeliveryBiz();
            var current = biz.LoadItem(id);
            if (current != null)
            {
                if (current.Modified.Value != modified.Value)
                {
                    MessageBox.Show(Constants.Messages.ConflictOrderMessage);
                    return true;
                }
            }

            return false;
        }
Beispiel #18
0
        public void DeliverItem(object sender, EventArgs e)
        {
            if (selectedId > 0)
            {
                var biz = new DeliveryBiz();
                biz.UpdateStatus(selectedId, ECommon.Constants.DeliveryStatusDelivered);

                RefreshItems(sender, e);
            }
        }
Beispiel #19
0
        public DeliveryForm(int id, User user)
        {
            InitializeComponent();

            InitForm(user);

            var lockBiz = new LockingBiz();
            var lockItem = lockBiz.LoadItem(Constants.TableNameDelivery, user.Id, id);
            if (lockItem == null)
            {
                lockBiz.LockItem(Constants.TableNameDelivery, id, user.Id);
            }
            else
            {
                groupBox1.Enabled = false;
                groupBox3.Enabled = false;
                groupBox4.Enabled = false;

                buttonSave.Enabled = false;
                buttonSendEmail.Enabled = false;
                buttonSendSms.Enabled = false;

                var userBiz = new UserBiz();
                var lockedUser = userBiz.LoadItem(lockItem.CurrentUserId);
                lockedUserName = lockedUser.FullName;
                isLocked = true;
            }

            drlVehicle.Focus();
            itemId = id;

            var biz = new DeliveryBiz();
            var item = biz.LoadItem(id);

            created = item.Created;
            createdBy = item.CreatedByUserId;
            modified = item.Modified;
            modifiedBy = item.ModifiedByUserId;

            labelDeliveryNo.Text = item.DeliveryNo;
            labelStatus.Text = item.Status;
            labelSendSms.Text = item.IsSendSms;
            labelSendEmail.Text = item.IsSendEmail;

            if (item.DeliveryDate.HasValue)
            {
                dateStartDate.Value = item.DeliveryDate.Value;
            }
            if (item.StartTime.HasValue)
            {
                dateTimeStartTime.Value = DateTime.Now + item.StartTime.Value;
            }

            textOtherInformation.Text = item.OtherInformation;
            if (item.VehicleId.HasValue)
            {
                drlVehicle.SelectedValue = item.VehicleId.Value;
            }
            if (item.StaffId.HasValue)
            {
                drlUser.SelectedValue = item.StaffId.Value;
            }

            LoadOrders(item);

            this.Text = "Cập nhật thông tin giao hàng";
        }
Beispiel #20
0
        public void DeleteSingleItem(object sender, EventArgs e)
        {
            if (selectedId > 0)
            {
                var biz = new DeliveryBiz();

                biz.RemoveSingleItem(selectedId);
                RefreshItems(sender, e);
            }
        }
Beispiel #21
0
        private void WorkAsync(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (flagSendMailOrder)
            {
                var biz = new OrderBiz();
                var status = biz.SendEmail(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
                biz.UpdateEmailStatus(Convert.ToInt32(e.Argument), status.Status);
            }

            if (flagSendSmsOrder)
            {
                var biz = new OrderBiz();

                string content = biz.GetSmsContent(Convert.ToInt32(e.Argument));
                var result = MessageBox.Show(content, string.Empty, MessageBoxButtons.OKCancel);
                if(result == System.Windows.Forms.DialogResult.OK)
                {
                    var status = biz.SendSms(Convert.ToInt32(e.Argument), currentUser.FullName);
                    if (!string.IsNullOrEmpty(status.Error))
                    {
                        MessageBox.Show(status.Error);
                    }
                    biz.UpdateSmsStatus(Convert.ToInt32(e.Argument), status.Status);
                }
            }

            if (flagSendSmsNotification)
            {
                var biz = new OrderBiz();
                string content = biz.GetContentReport(Convert.ToInt32(e.Argument));

                var result = MessageBox.Show(content, string.Empty, MessageBoxButtons.OKCancel);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    var status = biz.SendReport(Convert.ToInt32(e.Argument));

                    if (!string.IsNullOrEmpty(status.Error))
                    {
                        MessageBox.Show(status.Error);
                    }
                    biz.UpdateNotificationStatus(Convert.ToInt32(e.Argument), status.Status);
                }
            }

            if (flagSendMail)
            {
                var biz = new DeliveryBiz();
                var status = biz.SendEmail(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
            }

            if (flagSendSms)
            {
                var biz = new DeliveryBiz();
                var status = biz.SendSms(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
            }
        }
Beispiel #22
0
        private void CreateBoundHierarchy()
        {
            var deliveryBiz = new DeliveryBiz();

            using (this.radGridView.DeferRefresh())
            {
                this.radGridView.MasterTemplate.Reset();
                this.radGridView.AutoGenerateColumns = true;
                this.radGridView.AllowCellContextMenu = false;
                this.radGridView.ReadOnly = true;

                this.radGridView.TableElement.RowHeight = 20;
                this.radGridView.DataSource = deliveryBiz.GetTemplateData();
                this.radGridView.MasterTemplate.Columns["Vehicle"].HeaderText = "Xe";
                this.radGridView.MasterTemplate.Columns["DeliveryNo"].HeaderText = "Số giao hàng";
                this.radGridView.MasterTemplate.Columns["DeliveryDate"].HeaderText = "Ngày giao";
                this.radGridView.MasterTemplate.Columns["StartTime"].HeaderText = "Giờ giao";
                this.radGridView.MasterTemplate.Columns["Status"].HeaderText = "Tình trạng";
                this.radGridView.MasterTemplate.Columns["Id"].IsVisible = false;
                this.radGridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

                var orderBiz = new OrderBiz();

                GridViewTemplate template = new GridViewTemplate();

                template.AutoGenerateColumns = true;
                template.AllowAddNewRow = false;
                template.AllowCellContextMenu = false;
                template.ReadOnly = true;

                template.DataSource = orderBiz.GetTemplateData();
                this.radGridView.Templates.Add(template);
                template.Columns["OrderNo"].HeaderText = "Mã đơn hàng";
                template.Columns["Status"].HeaderText = "Tình trạng";
                template.Columns["Customer"].HeaderText = "Khách hàng";
                template.Columns["DeliveryDate"].HeaderText = "Ngày giao";
                template.Columns["DeliveryInternal"].HeaderText = "Hình thức vận chuyển";
                template.Columns["SendMessage"].HeaderText = "Tin nhắn";
                template.Columns["SendEmail"].HeaderText = "Email";
                template.Columns["SendReport"].HeaderText = "Thông báo";
                template.Columns["Id"].IsVisible = false;
                template.Columns["ParentId"].IsVisible = false;
                template.Columns["Recipient"].IsVisible = false;
                template.Columns["CustomerId"].IsVisible = false;

                template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

                GridViewRelation relation = new GridViewRelation(radGridView.MasterTemplate, template);
                relation.RelationName = "SuppliersProducts";
                relation.ParentColumnNames.Add("Id");
                relation.ChildColumnNames.Add("ParentId");
                this.radGridView.Relations.Add(relation);

                FormatCell();
            }
        }
Beispiel #23
0
 void SendSms(int id)
 {
     var biz = new DeliveryBiz();
     var status = biz.SendSms(id, currentUser.FullName);
     if (!string.IsNullOrEmpty(status.Error))
     {
         MessageBox.Show(status.Error);
     }
     biz.UpdateSmsStatus(id, status.Status);
 }
Beispiel #24
0
        private void WorkAsync(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (flagSendMailOrder)
            {
                var biz    = new OrderBiz();
                var status = biz.SendEmail(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
                biz.UpdateEmailStatus(Convert.ToInt32(e.Argument), status.Status);
            }

            if (flagSendSmsOrder)
            {
                var biz = new OrderBiz();

                string content = biz.GetSmsContent(Convert.ToInt32(e.Argument));
                var    result  = MessageBox.Show(content, string.Empty, MessageBoxButtons.OKCancel);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    var status = biz.SendSms(Convert.ToInt32(e.Argument), currentUser.FullName);
                    if (!string.IsNullOrEmpty(status.Error))
                    {
                        MessageBox.Show(status.Error);
                    }
                    biz.UpdateSmsStatus(Convert.ToInt32(e.Argument), status.Status);
                }
            }

            if (flagSendSmsNotification)
            {
                var    biz     = new OrderBiz();
                string content = biz.GetContentReport(Convert.ToInt32(e.Argument));

                var result = MessageBox.Show(content, string.Empty, MessageBoxButtons.OKCancel);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    var status = biz.SendReport(Convert.ToInt32(e.Argument));

                    if (!string.IsNullOrEmpty(status.Error))
                    {
                        MessageBox.Show(status.Error);
                    }
                    biz.UpdateNotificationStatus(Convert.ToInt32(e.Argument), status.Status);
                }
            }

            if (flagSendMail)
            {
                var biz    = new DeliveryBiz();
                var status = biz.SendEmail(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
            }

            if (flagSendSms)
            {
                var biz    = new DeliveryBiz();
                var status = biz.SendSms(Convert.ToInt32(e.Argument), currentUser.FullName);
                if (!string.IsNullOrEmpty(status.Error))
                {
                    MessageBox.Show(status.Error);
                }
            }
        }