Beispiel #1
0
        private void buttonFinish_Click(object sender, EventArgs e)
        {
            const string STRING_FINISHED = "已完成";

            int[] selectedIDs = Utilities.GetSelectedIDs(this.reoGridControlMain);
            if (selectedIDs.Length == 0)
            {
                MessageBox.Show("请选择您要操作的条目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            new Thread(new ThreadStart(() =>
            {
                WMSEntities wmsEntities = new WMSEntities();
                try
                {
                    //将状态置为已完成
                    foreach (int id in selectedIDs)
                    {
                        wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE ShipmentTicketItem SET State = '{0}' WHERE ID = {1};", STRING_FINISHED, id));
                    }
                    wmsEntities.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //如果作业单中所有条目都完成,询问是否将作业单标记为完成
                int unfinishedShipmentTicketItemCount = wmsEntities.Database.SqlQuery <int>(String.Format("SELECT COUNT(*) FROM ShipmentTicketItem WHERE ShipmentTicketID = {0} AND State <> '{1}'", this.shipmentTicketID, STRING_FINISHED)).Single();
                if (unfinishedShipmentTicketItemCount == 0)
                {
                    if (MessageBox.Show("检测到所有的零件都已经收货完成,是否将出库单状态更新为完成?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        try
                        {
                            wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE ShipmentTicket SET State = '{0}' WHERE ID = {1}", STRING_FINISHED, this.shipmentTicketID));
                            wmsEntities.SaveChanges();
                        }
                        catch
                        {
                            MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    this.shipmentTicketStateChangedCallback?.Invoke();
                }

                this.Invoke(new Action(() =>
                {
                    this.Search();
                }));
                MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            })).Start();
        }
        public ActionResult Create([Bind(Include = "client_name,contact_person,phone,email,consumer_email,claim_email,fax,add_1,add_2,city,province,country,zip")] tbl_client tbl_client)
        {
            if (ModelState.IsValid)
            {
                db.tbl_client.Add(tbl_client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_client));
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            int[] ids = this.GetSelectedIDs();
            if (ids.Length == 0)
            {
                MessageBox.Show("请选择要删除的项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (MessageBox.Show("确定删除选中的项目吗?\n重要提示:\n删除后所有零件的计划装车数量将会退回翻包作业单,无视实际装车数量!\n请谨慎操作!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            WMSEntities wmsEntities = new WMSEntities();

            try
            {
                //删除每个选中的出库单
                foreach (int id in ids)
                {
                    PutOutStorageTicket putOutStorageTicket = (from p in wmsEntities.PutOutStorageTicket
                                                               where p.ID == id
                                                               select p).FirstOrDefault();
                    if (putOutStorageTicket == null)
                    {
                        continue;
                    }
                    if (putOutStorageTicket.State != PutOutStorageTicketViewMetaData.STRING_STATE_NOT_LOADED)
                    {
                        MessageBox.Show("删除失败,只能删除未装车的出库单!\n如果需要强行删除,请使用修改功能将出库单的状态改为未装车", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    //把没完成出库的条目在作业单的已分配出库数量里减去
                    var items = putOutStorageTicket.PutOutStorageTicketItem;
                    foreach (var item in items)
                    {
                        JobTicketItem jobTicketItem = (from j in wmsEntities.JobTicketItem
                                                       where j.ID == item.JobTicketItemID
                                                       select j).FirstOrDefault();
                        if (jobTicketItem == null)
                        {
                            continue;
                        }
                        jobTicketItem.ScheduledPutOutAmount -= ((item.ScheduledAmount ?? 0) * (item.UnitAmount ?? 1)) / (jobTicketItem.UnitAmount ?? 1);
                    }
                    wmsEntities.PutOutStorageTicket.Remove(putOutStorageTicket);
                }
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("删除失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Invoke(new Action(() =>
            {
                this.Search(true);
            }));
            MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #4
0
        /// <summary>
        /// connect user
        /// </summary>
        public object ConnectUser(string userName)
        {
            try
            {
                using (var db = new WMSEntities())
                {
                    // Check if there if a connection for the specified user name have ever been made
                    var existingConnection = db.Connections.Where(x => x.UserName.ToLower() == userName.ToLower()).SingleOrDefault();
                    if (existingConnection != null)
                    {
                        // If there's an old connection only the connection id and the online status are changed.
                        existingConnection.ConnectionId = Context.ConnectionId;
                        existingConnection.IsOnline     = true;
                    }
                    else
                    {
                        // If not, then a new connection is created
                        db.Connections.Add(new Entity.Models.Connection {
                            ConnectionId = Context.ConnectionId, UserName = userName, IsOnline = true
                        });
                    }

                    db.SaveChanges();
                }

                UsersOnline();
                return(new { Success = true });
            }
            catch (Exception ex)
            {
                return(new { Success = false, ErrorMessage = ex.Message });
            }
        }
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain);
     if (ids.Length == 0)
     {
         MessageBox.Show("请选择要删除的项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (MessageBox.Show("确定要删除选中项吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     new Thread(() =>
     {
         WMSEntities wmsEntities = new WMSEntities();
         try
         {
             foreach (int id in ids)
             {
                 wmsEntities.Database.ExecuteSqlCommand("DELETE FROM JobTicketItem WHERE ID = @id", new SqlParameter("id", id));
             }
             wmsEntities.SaveChanges();
         }
         catch
         {
             MessageBox.Show("删除失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         this.Invoke(new Action(() => this.Search()));
         MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }).Start();
 }
        private void buttonFinishAll_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要全额完成所有条目吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            WMSEntities wmsEntities = new WMSEntities();

            try
            {
                wmsEntities.Database.ExecuteSqlCommand(
                    String.Format(@"UPDATE JobTicketItem
                                        SET State = '{0}',
                                        RealAmount = ScheduledAmount,
                                        HappenTime='{1}' 
                                        WHERE JobTicketID = {2} 
                                        AND (RealAmount <> ScheduledAmount OR State<>'{3}');",
                                  JobTicketItemViewMetaData.STRING_STATE_ALL_FINISHED,
                                  DateTime.Now.ToString(),
                                  this.jobTicketID,
                                  JobTicketItemViewMetaData.STRING_STATE_ALL_FINISHED));
                wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE JobTicket SET State = '{0}' WHERE ID = {1}", JobTicketViewMetaData.STRING_STATE_ALL_FINISHED, this.jobTicketID));
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.jobTicketStateChangedCallback?.Invoke();
            this.Invoke(new Action(() => this.Search()));
            MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private SubmissionTicket[] idsToSubmissionTickets(int[] ids)
        {
            List <SubmissionTicket> submissionTicketList = new List <SubmissionTicket>();

            try
            {
                WMSEntities wmsEntities = new WMSEntities();

                foreach (int id in ids)
                {
                    SubmissionTicket submissionTicket = (from s in wmsEntities.SubmissionTicket where s.ID == id select s).FirstOrDefault();
                    if (submissionTicket != null)
                    {
                        submissionTicket.PaintTime = DateTime.Now;
                        submissionTicketList.Add(submissionTicket);
                    }
                }
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                return(null);
            }

            return(submissionTicketList.ToArray());
        }
Beispiel #8
0
        private void modifyMode(int putawayTicketID)
        {
            WMSEntities   wmsEntities   = new WMSEntities();
            PutawayTicket putawayTicket = (from pt in wmsEntities.PutawayTicket where pt.ID == putawayTicketID select pt).FirstOrDefault();

            if (putawayTicket == null)
            {
                return;
            }
            int all  = (from pti in wmsEntities.PutawayTicketItem where pti.PutawayTicketID == putawayTicketID select pti).ToArray().Length;
            int yes  = (from pti in wmsEntities.PutawayTicketItem where pti.PutawayTicketID == putawayTicketID && pti.State == "已上架" select pti).ToArray().Length;
            int part = (from pti in wmsEntities.PutawayTicketItem where pti.PutawayTicketID == putawayTicketID && pti.State == "部分上架" select pti).ToArray().Length;
            int no   = (from pti in wmsEntities.PutawayTicketItem where pti.PutawayTicketID == putawayTicketID && pti.State == "待上架" select pti).ToArray().Length;

            if (all == yes)
            {
                putawayTicket.State = "已上架";
            }
            else if (all == no)
            {
                putawayTicket.State = "待上架";
            }
            else
            {
                putawayTicket.State = "部分上架";
            }

            wmsEntities.SaveChanges();
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            JobTicket jobTicket = null;

            try
            {
                jobTicket = (from s in this.wmsEntities.JobTicket
                             where s.ID == this.jobTicketID
                             select s).FirstOrDefault();
            }
            catch
            {
                MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (jobTicket == null)
            {
                MessageBox.Show("作业单不存在,请刷新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.curPersonID == -1)
            {
                jobTicket.PersonID = null;
            }
            else
            {
                jobTicket.PersonID = this.curPersonID;
            }
            jobTicket.LastUpdateUserID = this.userID;
            jobTicket.LastUpdateTime   = DateTime.Now;


            //开始数据库操作
            if (Utilities.CopyTextBoxTextsToProperties(this, jobTicket, JobTicketViewMetaData.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Utilities.CopyComboBoxsToProperties(this, jobTicket, JobTicketViewMetaData.KeyNames) == false)
            {
                MessageBox.Show("内部错误:读取复选框数据失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //调用回调函数
            if (this.modifyFinishedCallback != null)
            {
                this.modifyFinishedCallback();
            }
            MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
        public static void UpdateShipmentTicketStateSync(int shipmentTicketID, WMSEntities wmsEntities, bool saveChanges = true)
        {
            int total             = (from s in wmsEntities.ShipmentTicketItem where s.ShipmentTicketID == shipmentTicketID select s).Count();
            int fullAssignedCount = (from s in wmsEntities.ShipmentTicketItem where s.ShipmentTicketID == shipmentTicketID && s.ScheduledJobAmount == s.ShipmentAmount select s).Count();
            int notAssignedCount  = (from s in wmsEntities.ShipmentTicketItem where s.ShipmentTicketID == shipmentTicketID && s.ScheduledJobAmount == 0 select s).Count();

            Console.WriteLine("未分配:" + notAssignedCount + "  总数:" + total);
            if (notAssignedCount == total)
            {
                wmsEntities.Database.ExecuteSqlCommand(string.Format(
                                                           @"UPDATE ShipmentTicket SET State = '{0}' WHERE ID = {1}", ShipmentTicketViewMetaData.STRING_STATE_NOT_ASSIGNED_JOB, shipmentTicketID));
            }
            else if (fullAssignedCount == total)
            {
                wmsEntities.Database.ExecuteSqlCommand(string.Format(
                                                           @"UPDATE ShipmentTicket SET State = '{0}' WHERE ID = {1}", ShipmentTicketViewMetaData.STRING_STATE_ALL_ASSIGNED_JOB, shipmentTicketID));
            }
            else
            {
                wmsEntities.Database.ExecuteSqlCommand(string.Format(
                                                           @"UPDATE ShipmentTicket SET State = '{0}' WHERE ID = {1}", ShipmentTicketViewMetaData.STRING_STATE_PART_ASSIGNED_JOB, shipmentTicketID));
            }
            if (saveChanges)
            {
                wmsEntities.SaveChanges();
            }
        }
Beispiel #11
0
 private void buttonGenerateJobTicket_MouseDown(object sender, MouseEventArgs e)
 {
     //按下右键,选中发货单全部生成作业单
     if (e.Button == MouseButtons.Right)
     {
         int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain);
         if (ids.Length == 0)
         {
             MessageBox.Show("请选择要生成翻包作业单的项!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         if (MessageBox.Show("确定为所有选中发货单满额生成翻包作业单吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
         {
             return;
         }
         WMSEntities wmsEntities      = new WMSEntities();
         DateTime    createTime       = DateTime.Now;
         bool        hasSucceededItem = false;
         foreach (int id in ids)
         {
             hasSucceededItem |= JobTicketUtilities.GenerateJobTicketFullSync(id, wmsEntities, createTime);
         }
         if (hasSucceededItem == false)
         {
             return;
         }
         wmsEntities.SaveChanges();
         MessageBox.Show("生成成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
     }
 }
Beispiel #12
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            StockInfo stockInfo = null;

            //若修改,则查询原StockInfo对象。若添加,则新建一个StockInfo对象。
            if (this.mode == FormMode.ALTER)
            {
                try
                {
                    stockInfo = (from s in this.wmsEntities.StockInfo
                                 where s.ID == this.stockInfoID
                                 select s).FirstOrDefault();
                }
                catch
                {
                    MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (stockInfo == null)
                {
                    MessageBox.Show("库存信息不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (mode == FormMode.ADD)
            {
                stockInfo = new StockInfo();
                this.wmsEntities.StockInfo.Add(stockInfo);
            }

            //开始数据库操作
            if (Utilities.CopyTextBoxTextsToProperties(this, stockInfo, StockInfoViewMetaData.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //调用回调函数
            if (this.mode == FormMode.ALTER && this.modifyFinishedCallback != null)
            {
                this.modifyFinishedCallback();
                MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (this.mode == FormMode.ADD && this.addFinishedCallback != null)
            {
                this.addFinishedCallback();
            }
            this.Close();
        }
        private void buttonDeliver_Click(object sender, EventArgs e)
        {
            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain);
            if (ids.Length == 0)
            {
                MessageBox.Show("请选择要发运的出库单!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            WMSEntities wmsEntities = new WMSEntities();

            try
            {
                foreach (int id in ids)
                {
                    PutOutStorageTicket putOutStorageTicket = (from p in wmsEntities.PutOutStorageTicket
                                                               where p.ID == id
                                                               select p).FirstOrDefault();
                    string no = putOutStorageTicket.No;
                    if (putOutStorageTicket == null)
                    {
                        MessageBox.Show("出库单不存在,可能已被删除,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (putOutStorageTicket.State == PutOutStorageTicketViewMetaData.STRING_STATE_DELIVERED)
                    {
                        MessageBox.Show("单据" + no + "已经发运,请不要重复发运", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (putOutStorageTicket.State == PutOutStorageTicketViewMetaData.STRING_STATE_PART_LOADED)
                    {
                        MessageBox.Show("单据" + no + "正在装车中,必须全部装车完成才可以发运", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (putOutStorageTicket.State != PutOutStorageTicketItemViewMetaData.STRING_STATE_ALL_LOADED)
                    {
                        MessageBox.Show("未装车完成的出库单" + no + "不能发运!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    putOutStorageTicket.State       = PutOutStorageTicketViewMetaData.STRING_STATE_DELIVERED;
                    putOutStorageTicket.DeliverTime = DateTime.Now;
                }//End For

                if (MessageBox.Show("确定要发运选中项吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Search(true);
            MessageBox.Show("发运成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return;
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SubmissionTicket submissionTicket = new SubmissionTicket();
            string           errorInfo;

            if (Utilities.CopyTextBoxTextsToProperties(this, submissionTicket, ReceiptMetaData.submissionTicketKeyName, out errorInfo) == false)
            {
                MessageBox.Show(errorInfo);
                return;
            }
            else
            {
                new Thread(() =>
                {
                    ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == this.receiptTicketID select rt).FirstOrDefault();
                    if (receiptTicket != null)
                    {
                        submissionTicket.ProjectID   = receiptTicket.ProjectID;
                        submissionTicket.WarehouseID = receiptTicket.WarehouseID;
                    }
                    submissionTicket.CreateUserID     = this.userID;
                    submissionTicket.LastUpdateUserID = this.userID;
                    submissionTicket.LastUpdateTime   = DateTime.Now;
                    submissionTicket.CreateTime       = DateTime.Now;
                    submissionTicket.State            = "待检";
                    submissionTicket.ReceiptTicketID  = receiptTicketID;
                    wmsEntities.SubmissionTicket.Add(submissionTicket);
                    wmsEntities.SaveChanges();
                    submissionTicket.No = Utilities.GenerateNo("J", submissionTicket.ID);
                    try
                    {
                        wmsEntities.SaveChanges();
                        this.Invoke(new Action(() => Search()));
                        MessageBox.Show("成功");
                    }
                    catch
                    {
                        MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        return;
                    }
                }).Start();
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DataAccess.StockInfoCheckTicketItem StockInfoCheckTicketItem = null;



            StockInfoCheckTicketItem = new DataAccess.StockInfoCheckTicketItem();
            this.wmsEntities.StockInfoCheckTicketItem.Add(StockInfoCheckTicketItem);


            StockInfoCheckTicketItem.StockInfoCheckTicketID = this.stockinfocheckid;
            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlComponen);

            if (ids.Length != 1)
            {
                MessageBox.Show("请选择一项");
                return;
            }
            else if ((ids.Length == 1))
            {
                int stockiofocheckid = ids[0];
            }
            this.stockinfoid = ids[0];
            //TODO StockInfoCheckTicketItem.StockInfoID = this.stockinfoid;

            TextBox textBoxOverflowAreaAmount = (TextBox)this.Controls.Find("textBoxOverflowAreaAmount", true)[0];
            TextBox textBoxShipmentAreaAmount = (TextBox)this.Controls.Find("textBoxShipmentAreaAmount", true)[0];

            if (textBoxOverflowAreaAmount.Text != string.Empty)
            {
                StockInfoCheckTicketItem.ExcpetedOverflowAreaAmount = Convert.ToDecimal(textBoxOverflowAreaAmount.Text);
            }
            if (textBoxShipmentAreaAmount.Text != string.Empty)
            {
                StockInfoCheckTicketItem.ExpectedShipmentAreaAmount = Convert.ToDecimal(textBoxShipmentAreaAmount.Text);
            }

            //开始数据库操作
            if (Utilities.CopyTextBoxTextsToProperties(this, StockInfoCheckTicketItem, StockInfoCheckTicksModifyMetaDate.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Utilities.CopyComboBoxsToProperties(this, StockInfoCheckTicketItem, StockInfoCheckTicksModifyMetaDate.KeyNames);
            }
            wmsEntities.SaveChanges();
            MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            if (this.addFinishedCallback != null)
            {
                this.addFinishedCallback();
            }
        }
Beispiel #16
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            PutOutStorageTicket putOutStorageTicket = null;

            try
            {
                putOutStorageTicket = (from s in this.wmsEntities.PutOutStorageTicket
                                       where s.ID == this.putOutStorageTicketID
                                       select s).FirstOrDefault();
            }
            catch
            {
                MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (putOutStorageTicket == null)
            {
                MessageBox.Show("出库单不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            putOutStorageTicket.LastUpdateUserID = this.userID;
            putOutStorageTicket.LastUpdateTime   = DateTime.Now;
            int personID = this.personIDGetter();

            putOutStorageTicket.PersonID = personID == -1 ? null : (int?)personID;


            //开始数据库操作
            if (Utilities.CopyTextBoxTextsToProperties(this, putOutStorageTicket, PutOutStorageTicketViewMetaData.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Utilities.CopyComboBoxsToProperties(this, putOutStorageTicket, PutOutStorageTicketViewMetaData.KeyNames) == false)
            {
                MessageBox.Show("内部错误,读取选择框数据失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //调用回调函数
            if (this.modifyFinishedCallback != null)
            {
                this.modifyFinishedCallback();
            }
            this.Close();
        }
Beispiel #17
0
 /// <summary>
 /// PutUsersOffline
 /// </summary>
 public static void PutUsersOffline()
 {
     using (var db = new WMSEntities())
     {
         foreach (var connection in db.Connections)
         {
             connection.IsOnline = false;
         }
         db.SaveChanges();
     }
 }
        private void UpdatePutOutStorageTicketStateSync()
        {
            WMSEntities         wmsEntities         = new WMSEntities();
            PutOutStorageTicket putOutStorageTicket = (from p in wmsEntities.PutOutStorageTicket where p.ID == this.putOutStorageTicketID select p).FirstOrDefault();

            if (putOutStorageTicket == null)
            {
                return;
            }
            //已发运的单子不改变已发运状态
            if (putOutStorageTicket.State == PutOutStorageTicketViewMetaData.STRING_STATE_DELIVERED)
            {
                return;
            }
            //否则更新装车状态
            int    totalItemCount           = wmsEntities.Database.SqlQuery <int>(string.Format("SELECT COUNT(*) FROM PutOutStorageTicketItem WHERE PutOutStorageTicketID = {0}", this.putOutStorageTicketID)).Single();
            int    allfinishedItemCount     = wmsEntities.Database.SqlQuery <int>(String.Format("SELECT COUNT(*) FROM PutOutStorageTicketItem WHERE PutOutStorageTicketID = {0} AND State = '{1}'", this.putOutStorageTicketID, PutOutStorageTicketItemViewMetaData.STRING_STATE_ALL_LOADED)).Single();
            int    unfinishedItemCount      = wmsEntities.Database.SqlQuery <int>(String.Format("SELECT COUNT(*) FROM PutOutStorageTicketItem WHERE PutOutStorageTicketID = {0} AND State = '{1}'", this.putOutStorageTicketID, PutOutStorageTicketItemViewMetaData.STRING_STATE_WAIT_FOR_LOAD)).Single();
            string putOutStorageTicketState = null;

            if (unfinishedItemCount == totalItemCount)
            {
                putOutStorageTicketState = PutOutStorageTicketViewMetaData.STRING_STATE_NOT_LOADED;
            }
            else if (allfinishedItemCount == totalItemCount)
            {
                putOutStorageTicketState = PutOutStorageTicketViewMetaData.STRING_STATE_ALL_LOADED;
            }
            else
            {
                putOutStorageTicketState = PutOutStorageTicketViewMetaData.STRING_STATE_PART_LOADED;
            }

            try
            {
                wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE PutOutStorageTicket SET State = '{0}' WHERE ID = {1}", putOutStorageTicketState, this.putOutStorageTicketID));
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("更新出库单状态失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.IsDisposed)
            {
                return;
            }
            this.Invoke(new Action(() =>
            {
                this.putOutStorageTicketStateChangedCallback?.Invoke(this.putOutStorageTicketID);
            }));
        }
Beispiel #19
0
        private void buttonCreatePutaway_Click(object sender, EventArgs e)
        {
            PutawayTicket putawayTicket = new PutawayTicket();
            string        errorInfo;

            if (Utilities.CopyTextBoxTextsToProperties(this, putawayTicket, ReceiptMetaData.putawayTicketKeyName, out errorInfo) == false)
            {
                MessageBox.Show(errorInfo);
                return;
            }
            else
            {
                putawayTicket.ReceiptTicketID  = this.receiptTicketID;
                putawayTicket.CreateTime       = DateTime.Now;
                putawayTicket.CreateUserID     = this.userID;
                putawayTicket.LastUpdateTime   = DateTime.Now;
                putawayTicket.LastUpdateUserID = this.userID;
                putawayTicket.WarehouseID      = this.warehouseID;
                putawayTicket.ProjectID        = this.projectID;
                putawayTicket.State            = "待上架";
                new Thread(() =>
                {
                    try
                    {
                        wmsEntities.PutawayTicket.Add(putawayTicket);
                        wmsEntities.SaveChanges();
                        putawayTicket.No = Utilities.GenerateNo("P", putawayTicket.ID);
                        wmsEntities.SaveChanges();
                        this.Invoke(new Action(() => Search()));
                        MessageBox.Show("成功");
                    }
                    catch
                    {
                        MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                        return;
                    }
                }).Start();
            }
        }
Beispiel #20
0
        // PUT: odata/SQL_DASH(5)
        public IHttpActionResult Put([FromODataUri] decimal key, Delta <SQL_DASH> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SQL_DASH sQL_DASH = db.SQL_DASH.Find(key);

            if (sQL_DASH == null)
            {
                return(NotFound());
            }

            patch.Put(sQL_DASH);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SQL_DASHExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(sQL_DASH));
        }
Beispiel #21
0
        /// <summary>
        /// reconnect
        /// </summary>
        public override Task OnReconnected()
        {
            using (var db = new WMSEntities())
            {
                var connection = db.Connections.Where(x => x.ConnectionId == Context.ConnectionId).SingleOrDefault();
                if (connection != null)
                {
                    connection.IsOnline = true;
                    db.SaveChanges();
                }
            }

            UsersOnline();
            return(base.OnReconnected());
        }
Beispiel #22
0
        public ActionResult Create([Bind(Include = "client_name,SKU1,description,length,width,height,rate,supplier,cost,category,notes")] SKU sKU, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Images/"), fileName);
                    file.SaveAs(path);

                    sKU.image_url = Url.Content("~/Images/" + fileName);
                }
                try
                {
                    db.SKUs.Add(sKU);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Trace.TraceError("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                         eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Trace.TraceError("- Property: \"{0}\", Error: \"{1}\"",
                                             ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.client_name = new SelectList(db.tbl_client, "client_name", "contact_person", sKU.client_name);
            return(View(sKU));
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string errorInfo;

            //PutawayTicket putawayTicket = (from pt in wmsEntities.PutawayTicket where pt.ID == this.putawayTicketID select pt).FirstOrDefault();
            //if (putwayTicket)
            if (Utilities.CopyTextBoxTextsToProperties(this, putawayTicket, ReceiptMetaData.putawayTicketKeyName, out errorInfo) == true)
            {
                if (Utilities.CopyComboBoxsToProperties(this, putawayTicket, ReceiptMetaData.putawayTicketKeyName) == true)
                {
                    if (this.PersonIDGetter() != -1)
                    {
                        putawayTicket.PersonID = this.PersonIDGetter();
                    }
                    //wmsEntities.PutawayTicket.Add(putawayTicket);
                    new Thread(() =>
                    {
                        try
                        {
                            wmsEntities.SaveChanges();
                            MessageBox.Show("成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Invoke(new Action(() =>
                            {
                                CallBack();
                                this.Hide();
                            }));
                        }
                        catch
                        {
                            MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                            return;
                        }
                    }).Start();
                }
                else
                {
                    MessageBox.Show("单据类型读取失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show(errorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private bool importHandler(List <ReturnSupply> results, Dictionary <string, string[]> unimportedColumns)
        {
            WMSEntities wmsEntities = new WMSEntities();

            for (int i = 0; i < results.Count; i++)
            {
                ReturnSupply returnSupply = results[i];
                if (Utilities.GetSupplyOrComponentAmbiguous(returnSupply.SupplyNo, out DataAccess.Component component, out Supply supply, out string errorMessage, -1, wmsEntities) == false)
                {
                    MessageBox.Show("行" + (i + 1) + ":" + errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (component != null)
                {
                    MessageBox.Show("行" + (i + 1) + ":退件只接受零件代号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (returnSupply.ReturnQualityAmount + returnSupply.ReturnRejectAmount == 0)
                {
                    MessageBox.Show("行" + (i + 1) + ":正品退件数和不良品退件数不可以全为0!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                StockInfo newStockInfo = new StockInfo()
                {
                    ProjectID               = this.projectID,
                    WarehouseID             = this.warehouseID,
                    SupplyID                = supply.ID,
                    ReceiptTicketNo         = "退件返库",
                    InventoryDate           = DateTime.Now,
                    ReceiptAreaAmount       = 0,
                    SubmissionAmount        = 0,
                    OverflowAreaAmount      = 0,
                    RejectAreaAmount        = returnSupply.ReturnRejectAmount * returnSupply.ReturnRejectUnitAmount,
                    ShipmentAreaAmount      = returnSupply.ReturnQualityAmount * returnSupply.ReturnQualityUnitAmount,
                    ScheduledShipmentAmount = 0
                };
                StockInfoUtilities.AddStockInfo(newStockInfo, wmsEntities, false);
            }
            wmsEntities.SaveChanges();
            MessageBox.Show("退件成功!请到库存批次中查看", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            formImport.Close();
            return(false);
        }
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            if (WarehouseID.Text == string.Empty)
            {
                MessageBox.Show("仓库ID不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (SupplierID.Text == string.Empty)
            {
                MessageBox.Show("供应商ID不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //添加
            DataAccess.Component objcomponen = new DataAccess.Component();
            {
                objcomponen.WarehouseID               = Convert.ToInt32(WarehouseID.Text);
                objcomponen.SupplierID                = Convert.ToInt32(SupplierID.Text);
                objcomponen.ContainerNo               = ContainerNo.Text;
                objcomponen.Factroy                   = Factroy.Text;
                objcomponen.WorkPosition              = WorkPosition.Text;
                objcomponen.No                        = No.Text;
                objcomponen.Name                      = Name1.Text;
                objcomponen.SupplierType              = SupplierType.Text;
                objcomponen.Type                      = Type.Text;
                objcomponen.Size                      = Size.Text;
                objcomponen.Category                  = Category.Text;
                objcomponen.GroupPrincipal            = GroupPrincipal.Text;
                objcomponen.SingleCarUsageAmount      = Convert.ToDecimal(SingleCarUsageAmount.Text);
                objcomponen.Charge1                   = Convert.ToDecimal(ChargeBelow50000.Text);
                objcomponen.Charge1                   = Convert.ToDecimal(ChargeAbove50000.Text);
                objcomponen.InventoryRequirement1Day  = Convert.ToDecimal(InventoryRequirement1Day.Text);
                objcomponen.InventoryRequirement3Day  = Convert.ToDecimal(InventoryRequirement3Day.Text);
                objcomponen.InventoryRequirement5Day  = Convert.ToDecimal(InventoryRequirement5Day.Text);
                objcomponen.InventoryRequirement10Day = Convert.ToDecimal(InventoryRequirement10Day.Text);
            }
            WMSEntities wms = new WMSEntities();

            wms.Component.Add(objcomponen);
            wms.SaveChanges();
            MessageBox.Show("添加零件成功");
            this.Close();
        }
        private void buttonAllLoad_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要全额装车所有条目吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            WMSEntities wmsEntities = new WMSEntities();

            try
            {
                PutOutStorageTicketItem[] items = (from p in wmsEntities.PutOutStorageTicketItem
                                                   where p.PutOutStorageTicketID == this.putOutStorageTicketID &&
                                                   (p.RealAmount != p.ScheduledAmount || p.State != PutOutStorageTicketItemViewMetaData.STRING_STATE_ALL_LOADED)
                                                   select p).ToArray();
                for (int i = 0; i < items.Length; i++)
                {
                    PutOutStorageTicketItem item = items[i];
                    item.State       = PutOutStorageTicketItemViewMetaData.STRING_STATE_ALL_LOADED;
                    item.LoadingTime = DateTime.Now;
                    decimal deltaRealAmountNoUnit = (items[i].ScheduledAmount - (items[i].RealAmount ?? 0)) * (items[i].UnitAmount ?? 1) ?? 0;
                    item.RealAmount = items[i].ScheduledAmount;
                    StockInfo stockInfo = (from s in wmsEntities.StockInfo
                                           where s.ID == item.StockInfoID
                                           select s).FirstOrDefault();
                    stockInfo.ShipmentAreaAmount      -= deltaRealAmountNoUnit;
                    stockInfo.ScheduledShipmentAmount -= deltaRealAmountNoUnit;
                }

                wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE PutOutStorageTicket SET State = '{0}' WHERE ID = {1}", PutOutStorageTicketViewMetaData.STRING_STATE_ALL_LOADED, this.putOutStorageTicketID));
                wmsEntities.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作失败,请检查网络连接\n请将下面的错误信息反馈给我们:\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.putOutStorageTicketStateChangedCallback?.Invoke(this.putOutStorageTicketID);
            this.Invoke(new Action(() => this.Search()));
            MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static bool DeleteItemsSync(int[] itemIDs, out string errorMessage)
        {
            try
            {
                using (WMSEntities wmsEntities = new WMSEntities())
                {
                    foreach (int id in itemIDs)
                    {
                        ShipmentTicketItem item = (from s in wmsEntities.ShipmentTicketItem where s.ID == id select s).FirstOrDefault();
                        if (item == null)
                        {
                            continue;
                        }
                        if (item.ScheduledJobAmount > 0)
                        {
                            errorMessage = "不能删除已分配翻包的零件!";
                            return(false);
                        }

                        //把库存已分配发货数减回去
                        decimal?  amount    = item.ShipmentAmount * item.UnitAmount;
                        StockInfo stockInfo = (from s in wmsEntities.StockInfo where s.ID == item.StockInfoID select s).FirstOrDefault();
                        if (stockInfo == null)
                        {
                            continue;
                        }
                        stockInfo.ScheduledShipmentAmount -= amount ?? 0;
                        wmsEntities.ShipmentTicketItem.Remove(item);
                    }
                    wmsEntities.SaveChanges();
                    errorMessage = null;
                    return(true);
                }
            }
            catch
            {
                errorMessage = "操作失败,请检查网络连接";
                return(false);
            }
        }
        private void UpdateJobTicketStateSync()
        {
            WMSEntities wmsEntities                   = new WMSEntities();
            int         totalJobTicketItemCount       = wmsEntities.Database.SqlQuery <int>(string.Format("SELECT COUNT(*) FROM JobTicketItem WHERE JobTicketID = {0}", this.jobTicketID)).Single();
            int         allfinishedJobTicketItemCount = wmsEntities.Database.SqlQuery <int>(String.Format("SELECT COUNT(*) FROM JobTicketItem WHERE JobTicketID = {0} AND State = '{1}'", this.jobTicketID, JobTicketItemViewMetaData.STRING_STATE_ALL_FINISHED)).Single();
            int         unfinishedJobTicketItemCount  = wmsEntities.Database.SqlQuery <int>(String.Format("SELECT COUNT(*) FROM JobTicketItem WHERE JobTicketID = {0} AND State = '{1}'", this.jobTicketID, JobTicketItemViewMetaData.STRING_STATE_UNFINISHED)).Single();
            string      jobTicketState                = null;

            if (unfinishedJobTicketItemCount == totalJobTicketItemCount)
            {
                jobTicketState = JobTicketViewMetaData.STRING_STATE_UNFINISHED;
            }
            else if (allfinishedJobTicketItemCount == totalJobTicketItemCount)
            {
                jobTicketState = JobTicketViewMetaData.STRING_STATE_ALL_FINISHED;
            }
            else
            {
                jobTicketState = JobTicketViewMetaData.STRING_STATE_PART_FINISHED;
            }

            try
            {
                wmsEntities.Database.ExecuteSqlCommand(String.Format("UPDATE JobTicket SET State = '{0}' WHERE ID = {1}", jobTicketState, this.jobTicketID));
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("更新作业单状态失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.IsDisposed)
            {
                return;
            }
            this.Invoke(new Action(() =>
            {
                this.jobTicketStateChangedCallback?.Invoke();
            }));
        }
Beispiel #29
0
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            if (SupplierID.Text == string.Empty)
            {
                MessageBox.Show("供应商ID不能为空!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //修改
            WMSEntities wms = new WMSEntities();

            DataAccess.Component objuser = (from s in wms.Component
                                            where s.Name == Name1.Text
                                            select s).First();

            objuser.SupplierID                = Convert.ToInt32(SupplierID.Text);
            objuser.ContainerNo               = ContainerNo.Text;
            objuser.Factroy                   = Factroy.Text;
            objuser.WorkPosition              = WorkPosition.Text;
            objuser.No                        = No.Text;
            objuser.SupplierType              = SupplierType.Text;
            objuser.Type                      = Type.Text;
            objuser.Size                      = Size.Text;
            objuser.Category                  = Category.Text;
            objuser.GroupPrincipal            = GroupPrincipal.Text;
            objuser.SingleCarUsageAmount      = Convert.ToDecimal(SingleCarUsageAmount.Text);
            objuser.Charge1                   = Convert.ToDecimal(ChargeBelow50000.Text);
            objuser.Charge2                   = Convert.ToDecimal(ChargeAbove50000.Text);
            objuser.InventoryRequirement1Day  = Convert.ToDecimal(InventoryRequirement1Day.Text);
            objuser.InventoryRequirement3Day  = Convert.ToDecimal(InventoryRequirement3Day.Text);
            objuser.InventoryRequirement5Day  = Convert.ToDecimal(InventoryRequirement5Day.Text);
            objuser.InventoryRequirement10Day = Convert.ToDecimal(InventoryRequirement10Day.Text);

            wms.SaveChanges();
            MessageBox.Show("修改零件成功");
            this.Close();
        }