コード例 #1
0
        private void toolStripButtonToJobTicket_Click(object sender, EventArgs e)
        {
            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain);
            if (ids.Length != 1)
            {
                MessageBox.Show("请选择一项进行操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int id = ids[0];

            new Thread(() =>
            {
                try
                {
                    WMSEntities wmsEntities       = new WMSEntities();
                    ShipmentTicket shipmentTicket = (from s in wmsEntities.ShipmentTicket
                                                     where s.ID == id
                                                     select s).FirstOrDefault();
                    if (shipmentTicket == null)
                    {
                        MessageBox.Show("发货单不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.toJobTicketCallback("ShipmentTicketNo", shipmentTicket.No);
                }
                catch (Exception)
                {
                    MessageBox.Show("查询失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }).Start();
        }
コード例 #2
0
        private void FormShipmentTicketItem_Load(object sender, EventArgs e)
        {
            ShipmentTicket shipmentTicket = null;

            try
            {
                WMSEntities wmsEntities = new WMSEntities();
                shipmentTicket = (from s in wmsEntities.ShipmentTicket where s.ID == shipmentTicketID select s).FirstOrDefault();
            }
            catch
            {
                MessageBox.Show("加载数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            if (shipmentTicket == null)
            {
                MessageBox.Show("发货单信息不存在,请刷新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            InitComponents();
            this.Search();
        }
コード例 #3
0
        /// <summary>
        /// 无脑生成作业单,不选零件不填数量。
        /// </summary>
        /// <param name="shipmentTicketIDs"></param>
        /// <param name="wmsEntities"></param>
        public static bool GenerateJobTicketFullSync(int shipmentTicketID, WMSEntities wmsEntities, DateTime?createTime = null)
        {
            ShipmentTicket shipmentTicket = (from s in wmsEntities.ShipmentTicket
                                             where s.ID == shipmentTicketID
                                             select s).FirstOrDefault();

            if (shipmentTicket == null)
            {
                MessageBox.Show("发货单不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            ShipmentTicketItem[] shipmentTicketItems = (from s in wmsEntities.ShipmentTicketItem
                                                        where s.ShipmentTicketID == shipmentTicketID
                                                        select s).ToArray();
            List <JobTicketItem> newJobTicketItems = new List <JobTicketItem>();

            for (int i = 0; i < shipmentTicketItems.Length; i++)
            {
                ShipmentTicketItem shipmentTicketItem = shipmentTicketItems[i];
                if (shipmentTicketItem == null)
                {
                    MessageBox.Show("发货单条目不存在,可能已被删除,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                decimal restScheduableAmount = (shipmentTicketItem.ShipmentAmount - (shipmentTicketItem.ScheduledJobAmount ?? 0)) ?? 0;
                if (restScheduableAmount <= 0)
                {
                    continue;
                }
                var jobTicketItem = new JobTicketItem();
                jobTicketItem.ScheduledAmount      = restScheduableAmount;
                jobTicketItem.StockInfoID          = shipmentTicketItem.StockInfoID;
                jobTicketItem.ShipmentTicketItemID = shipmentTicketItem.ID;
                jobTicketItem.State      = JobTicketItemViewMetaData.STRING_STATE_UNFINISHED;
                jobTicketItem.Unit       = shipmentTicketItem.Unit;
                jobTicketItem.UnitAmount = shipmentTicketItem.UnitAmount;
                jobTicketItem.RealAmount = 0;
                shipmentTicketItem.ScheduledJobAmount = (shipmentTicketItem.ScheduledJobAmount ?? 0) + jobTicketItem.ScheduledAmount;
                newJobTicketItems.Add(jobTicketItem);
            }
            if (newJobTicketItems.Count == 0)
            {
                MessageBox.Show("发货单 " + shipmentTicket.No + " 中无可分配翻包的零件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            JobTicket newJobTicket = new JobTicket();

            foreach (JobTicketItem item in newJobTicketItems)
            {
                newJobTicket.JobTicketItem.Add(item);
            }
            wmsEntities.JobTicket.Add(newJobTicket);

            newJobTicket.State            = JobTicketViewMetaData.STRING_STATE_UNFINISHED;
            newJobTicket.ShipmentTicketID = shipmentTicket.ID;
            newJobTicket.ProjectID        = GlobalData.ProjectID;
            newJobTicket.WarehouseID      = GlobalData.WarehouseID;
            newJobTicket.CreateUserID     = GlobalData.UserID;
            newJobTicket.CreateTime       = createTime ?? DateTime.Now;

            if (string.IsNullOrWhiteSpace(newJobTicket.JobTicketNo))
            {
                DateTime createDay      = new DateTime(shipmentTicket.CreateTime.Value.Year, shipmentTicket.CreateTime.Value.Month, shipmentTicket.CreateTime.Value.Day);
                DateTime nextDay        = createDay.AddDays(1);
                int      maxRankOfToday = Utilities.GetMaxTicketRankOfDay((from j in wmsEntities.JobTicket
                                                                           where j.CreateTime >= createDay && j.CreateTime < nextDay
                                                                           select j.JobTicketNo).ToArray());
                newJobTicket.JobTicketNo = Utilities.GenerateTicketNo("Z", newJobTicket.CreateTime.Value, maxRankOfToday + 1);
            }
            wmsEntities.SaveChanges();
            //更新发货单状态
            ShipmentTicketUtilities.UpdateShipmentTicketStateSync(shipmentTicketID, wmsEntities, true);
            return(true);
        }
コード例 #4
0
        //private void textBoxSupplierName_Click(object sender, EventArgs e)
        //{
        //    FormSelectSupplier form = new FormSelectSupplier();
        //    form.SetSelectFinishCallback((supplierID)=>
        //    {
        //        if (this.IsDisposed) return;
        //        WMSEntities wmsEntities = new WMSEntities();
        //        try
        //        {
        //            SupplierView supplierView = (from s in wmsEntities.SupplierView
        //                                         where s.ID == supplierID
        //                                         select s).FirstOrDefault();
        //            if(supplierView == null)
        //            {
        //                MessageBox.Show("供应商不存在,请重新选择", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //                return;
        //            }
        //            this.curSupplierID = supplierID;
        //            this.textBoxSupplierName.Text = supplierView.Name;
        //        }
        //        catch
        //        {
        //            MessageBox.Show("加载供应商信息失败,请检查网络连接","提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //            return;
        //        }
        //    });
        //    form.Show();
        //}

        private void buttonOK_Click(object sender, EventArgs e)
        {
            ShipmentTicket shipmentTicket = null;
            WMSEntities    wmsEntities    = new WMSEntities();

            //若修改,则查询原对象。若添加,则新建一个对象。
            if (this.mode == FormMode.ALTER)
            {
                try
                {
                    shipmentTicket = (from s in wmsEntities.ShipmentTicket
                                      where s.ID == this.shipmentTicketID
                                      select s).FirstOrDefault();
                }
                catch
                {
                    MessageBox.Show("修改失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (shipmentTicket == null)
                {
                    MessageBox.Show("修改失败,发货单不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                shipmentTicket.LastUpdateUserID = this.userID;
                shipmentTicket.LastUpdateTime   = DateTime.Now;
            }
            else if (mode == FormMode.ADD)
            {
                shipmentTicket              = new ShipmentTicket();
                shipmentTicket.CreateTime   = DateTime.Now;
                shipmentTicket.CreateUserID = this.userID;
                wmsEntities.ShipmentTicket.Add(shipmentTicket);
            }

            shipmentTicket.ProjectID   = this.projectID;
            shipmentTicket.WarehouseID = this.warehouseID;
            //if(this.curSupplierID == -1)
            //{
            //    MessageBox.Show("请选择供应商!","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    return;
            //}
            //shipmentTicket.SupplierID = this.curSupplierID;
            if (this.curPersonID == -1)
            {
                shipmentTicket.PersonID = null;
            }
            else
            {
                shipmentTicket.PersonID = this.curPersonID;
            }

            //开始数据库操作
            if (Utilities.CopyTextBoxTextsToProperties(this, shipmentTicket, ShipmentTicketViewMetaData.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Utilities.CopyComboBoxsToProperties(this, shipmentTicket, ShipmentTicketViewMetaData.KeyNames);
            }

            new Thread(() =>
            {
                //生成单号和编号
                try
                {
                    if (string.IsNullOrWhiteSpace(shipmentTicket.No))
                    {
                        if (shipmentTicket.CreateTime.HasValue == false)
                        {
                            MessageBox.Show("单号生成失败(未知创建日期)!请手动填写单号");
                            return;
                        }

                        DateTime createDay = new DateTime(shipmentTicket.CreateTime.Value.Year, shipmentTicket.CreateTime.Value.Month, shipmentTicket.CreateTime.Value.Day);
                        DateTime nextDay   = createDay.AddDays(1);
                        int maxRankOfToday = Utilities.GetMaxTicketRankOfDay((from s in wmsEntities.ShipmentTicket
                                                                              where s.CreateTime >= createDay && s.CreateTime < nextDay
                                                                              select s.No).ToArray());
                        if (maxRankOfToday == -1)
                        {
                            MessageBox.Show("单号生成失败!请手动填写单号");
                            return;
                        }
                        shipmentTicket.No = Utilities.GenerateTicketNo("F", shipmentTicket.CreateTime.Value, maxRankOfToday + 1);
                    }
                    //if (string.IsNullOrWhiteSpace(shipmentTicket.Number))
                    //{
                    //    if (shipmentTicket.CreateTime.HasValue == false)
                    //    {
                    //        MessageBox.Show("编号生成失败(未知创建日期)!请手动填写编号");
                    //        return;
                    //    }
                    //    Supplier supplier = (from s in wmsEntities.Supplier
                    //                         where s.ID == shipmentTicket.SupplierID
                    //                         select s).FirstOrDefault();
                    //    if (supplier == null)
                    //    {
                    //        MessageBox.Show("编号生成失败(供应商信息不存在)!请手动填写编号");
                    //        return;
                    //    }
                    //    DateTime createMonth = new DateTime(shipmentTicket.CreateTime.Value.Year, shipmentTicket.CreateTime.Value.Month, 1);
                    //    DateTime nextMonth = createMonth.AddMonths(1);
                    //    var tmp = (from s in wmsEntities.ShipmentTicket
                    //               where s.CreateTime >= createMonth &&
                    //                     s.CreateTime < nextMonth &&
                    //                     s.SupplierID == shipmentTicket.SupplierID
                    //               select s.Number).ToArray();
                    //    int maxRankOfMonth = Utilities.GetMaxTicketRankOfSupplierAndMonth(tmp);
                    //    shipmentTicket.Number = Utilities.GenerateTicketNumber(supplier.Number, shipmentTicket.CreateTime.Value, maxRankOfMonth + 1);
                    //}
                    wmsEntities.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                this.Invoke(new Action(() =>
                {
                    //调用回调函数
                    if (this.mode == FormMode.ALTER && this.modifyFinishedCallback != null)
                    {
                        this.modifyFinishedCallback(shipmentTicket.ID);
                        MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (this.mode == FormMode.ADD && this.addFinishedCallback != null)
                    {
                        bool openTicket = false;
                        if (MessageBox.Show("添加成功!是否添加零件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            openTicket = true;
                        }
                        this.addFinishedCallback(shipmentTicket.ID, openTicket);
                    }
                    this.Close();
                }));
            }).Start();
        }