Пример #1
0
        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);
        }
Пример #2
0
        private void buttonGeneratePutOutStorageTicket_Click(object sender, EventArgs e)
        {
            int[]       ids         = Utilities.GetSelectedIDs(this.reoGridControlMain);
            WMSEntities wmsEntities = new WMSEntities();

            foreach (int jobTicketID in ids)
            {
                JobTicket jobTicket = (from j in wmsEntities.JobTicket where j.ID == jobTicketID select j).FirstOrDefault();
                if (jobTicket == null)
                {
                    MessageBox.Show("选中作业单不存在,可能已被删除,请重新查询!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (jobTicket.State != JobTicketViewMetaData.STRING_STATE_ALL_FINISHED)
                {
                    if (MessageBox.Show("选中作业单未全部完成,确定生成出库单吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                }
                FormPutOutStorageTicketNew form = new FormPutOutStorageTicketNew(jobTicketID, this.userID, this.projectID, this.warehouseID);
                form.SetToPutOutStorageTicketCallback(this.toPutOutStorageTicketCallback);
                form.Show();
            }
        }
Пример #3
0
        private void RefreshTextBoxes()
        {
            this.ClearTextBoxes();
            var worksheet = this.reoGridControlMain.Worksheets[0];

            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlMain);
            if (ids.Length == 0)
            {
                Utilities.FillTextBoxDefaultValues(this.tableLayoutPanelProperties, JobTicketItemViewMetaData.KeyNames);
                return;
            }
            int id = ids[0];
            JobTicketItemView jobTicketItemView = null;

            try
            {
                WMSEntities wmsEntities = new WMSEntities();
                jobTicketItemView = (from jti in wmsEntities.JobTicketItemView
                                     where jti.ID == id
                                     select jti).FirstOrDefault();
            }
            catch
            {
                MessageBox.Show("加载数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (jobTicketItemView == null)
            {
                MessageBox.Show("作业单项目不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Utilities.CopyPropertiesToTextBoxes(jobTicketItemView, this);
            Utilities.CopyPropertiesToComboBoxes(jobTicketItemView, this);
        }
        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();
            }
        }
Пример #5
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);
     }
 }
Пример #6
0
        private void FormStockInfo_Load(object sender, EventArgs e)
        {
            InitComponents();
            try
            {
                WMSEntities wmsEntities = new WMSEntities();
                User        user        = (from u in wmsEntities.User where u.ID == this.userID select u).FirstOrDefault();
                if (user == null)
                {
                    MessageBox.Show("登录失效,请重新登录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //如果登录失效,不能查出任何数据。
                    this.pagerWidget.AddStaticCondition("SupplierID", "-1");
                    return;
                }
                if (user.Supplier != null)
                {
                    this.pagerWidget.AddStaticCondition("SupplierID", user.SupplierID.ToString());
                    this.buttonAlter.Enabled  = false;
                    this.buttonImport.Enabled = false;
                }
            }
            catch
            {
                MessageBox.Show("加载失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //如果加载失败,不能查出任何数据。
                this.pagerWidget.AddStaticCondition("SupplierID", "-1");
                return;
            }

            this.pagerWidget.Search();
        }
        private void buttonZhongDuFlow_Click(object sender, EventArgs e)
        {
            StandardFormPreviewExcel formPreview = new StandardFormPreviewExcel("出库流水预览");

            WMSEntities wmsEntities = new WMSEntities();
            List <PutOutStorageTicketItemView> items = new List <PutOutStorageTicketItemView>();

            foreach (int id in putOutStorageTicketIDs)
            {
                PutOutStorageTicketItemView[] putOutStorageTicketItemViews =
                    (from p in wmsEntities.PutOutStorageTicketItemView
                     where p.PutOutStorageTicketID == id
                     select p).ToArray();
                items.AddRange(putOutStorageTicketItemViews);
            }
            if (formPreview.AddPatternTable(@"Excel\patternPutOutStorageTicketZhongDuFlow.xlsx") == false)
            {
                this.Close();
                return;
            }
            formPreview.AddData("putOutStorageTicketItems", items.ToArray());
            formPreview.SetPrintScale(1.2f);
            formPreview.Show();
            this.Close();
        }
        private void FormReceiptSubmissionNew_Load(object sender, EventArgs e)
        {
            this.ItemKeyName = (from kn in ReceiptMetaData.itemsKeyName where kn.Key != "Component" select kn).ToArray();
            InitComponents();
            Search();
            InitPanel();
            WMSEntities   wmsEntities   = new WMSEntities();
            User          user          = (from u in wmsEntities.User where u.ID == userID select u).FirstOrDefault();
            ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == this.receiptTicketID select rt).FirstOrDefault();

            if (user != null)
            {
                this.Controls.Find("textBoxCreateUserUsername", true)[0].Text     = user.Username;
                this.Controls.Find("textBoxLastUpdateUserUsername", true)[0].Text = user.Username;
            }
            if (receiptTicket != null)
            {
                this.Controls.Find("textBoxReceiptTicketNo", true)[0].Text = receiptTicket.No;
                this.Controls.Find("textBoxSubmissionDate", true)[0].Text  = receiptTicket.ReceiptDate.ToString();
            }
            this.Controls.Find("textBoxState", true)[0].Text = "待检";

            this.Controls.Find("textBoxCreateTime", true)[0].Text     = DateTime.Now.ToString();
            this.Controls.Find("textBoxLastUpdateTime", true)[0].Text = DateTime.Now.ToString();
        }
Пример #9
0
        private void RefreshTextBoxes()
        {
            //WMSEntities wmsEntities = new WMSEntities();
            this.ClearTextBoxes();
            var worksheet = this.reoGridControlPutaway.Worksheets[0];

            int[] ids = Utilities.GetSelectedIDs(this.reoGridControlPutaway);
            if (ids.Length == 0)
            {
                this.putawayTicketItemID = -1;
                return;
            }
            int                   id                    = ids[0];
            WMSEntities           wmsEntities           = new WMSEntities();
            PutawayTicketItemView putawayTicketItemView =
                (from s in wmsEntities.PutawayTicketItemView
                 where s.ID == id
                 select s).FirstOrDefault();

            this.jobPersonID     = putawayTicketItemView.JobPersonID == null ? -1 : (int)putawayTicketItemView.JobPersonID;
            this.confirmPersonID = putawayTicketItemView.ConfirmPersonID == null ? -1 : (int)putawayTicketItemView.ConfirmPersonID;
            if (putawayTicketItemView == null)
            {
                MessageBox.Show("系统错误,未找到相应上架单项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.putawayTicketItemID = int.Parse(putawayTicketItemView.ID.ToString());
            Utilities.CopyPropertiesToTextBoxes(putawayTicketItemView, this);
            Utilities.CopyPropertiesToComboBoxes(putawayTicketItemView, this);
        }
        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());
        }
Пример #11
0
        private void buttonToPutOutStorageTicket_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();
                    JobTicket jobTicket     = (from s in wmsEntities.JobTicket
                                               where s.ID == id
                                               select s).FirstOrDefault();
                    if (jobTicket == null)
                    {
                        MessageBox.Show("作业单不存在,请重新查询", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.toPutOutStorageTicketCallback("JobTicketJobTicketNo", jobTicket.JobTicketNo);
                }
                catch (Exception)
                {
                    MessageBox.Show("查询失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }).Start();
        }
Пример #12
0
 private void buttonGeneratePutOutStorageTicket_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();
         if (PutOutStorageTicketUitilities.GeneratePutOutStorageTicketFullSync(ids, wmsEntities))
         {
             MessageBox.Show("生成成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             return;
         }
     }
 }
Пример #13
0
 /// <summary>
 /// yeni finsat
 /// </summary>
 public Finsat(WMSEntities db, string sirketKodu, SqlExper sqlExper, FaturaKayit faturaKayit)
 {
     Db         = db;
     SirketKodu = sirketKodu;
     SqlExper   = sqlExper;
     FtrKayit   = faturaKayit;
 }
Пример #14
0
 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 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);
        }
Пример #16
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 });
            }
        }
Пример #17
0
        private void FormShelvesItem_Load(object sender, EventArgs e)
        {
            if (this.key != null && this.value != null)
            {
                this.SetTableLayOut();
            }
            new Thread(() =>
            {
                if (this.IsDisposed)
                {
                    return;
                }
                this.Invoke(new Action(() =>
                {
                    this.tableLayoutPanelProperties.Visible = false;
                    InitPanel();
                    this.tableLayoutPanelProperties.Visible = true;
                    TextBox textBoxPutawayAmount            = (TextBox)this.Controls.Find("textBoxPutawayAmount", true)[0];
                    textBoxPutawayAmount.TextChanged       += textBoxPuawayAmount_TextChanged;
                }));
            }).Start();
            WMSEntities wmsEntities = new WMSEntities();

            pagerWidget = new PagerWidget <PutawayTicketItemView>(this.reoGridControlPutaway, ReceiptMetaData.putawayTicketItemKeyName, projectID, warehouseID);
            this.panel4.Controls.Add(pagerWidget);
            pagerWidget.ClearCondition();
            pagerWidget.AddOrderBy("StockInfoShipmentAreaAmount / (ComponentDailyProduction * ComponentSingleCarUsageAmount)");
            pagerWidget.AddOrderBy("ReceiptTicketItemInventoryDate");
            Search();
            this.pagerWidget.Show();

            //this.RefreshTextBoxes();
        }
Пример #18
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();
        }
Пример #19
0
        private void FormSelectComponen_Load(object sender, EventArgs e)
        {
            InitComponents();
            if (this.defaultComponenID != -1)
            {
                try
                {
                    WMSEntities wmsEntities = new WMSEntities();

                    this.textBoxComponenName.Text = (from s in wmsEntities.ComponentView where s.ID == defaultComponenID select s.Name).FirstOrDefault();
                    this.Search(defaultComponenID);
                }

                catch
                {
                    MessageBox.Show("加载数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                    return;
                }
            }
            else
            {
                this.Search();
            }
        }
Пример #20
0
        private void FormPutaway_Load(object sender, EventArgs e)
        {
            InitComponents();
            InitPanel();
            WMSEntities wmsEntities = new WMSEntities();

            Search();
        }
Пример #21
0
 public static void AddStockInfo(StockInfo stockInfo, WMSEntities wmsEntities, bool saveChanges = true)
 {
     wmsEntities.StockInfo.Add(stockInfo);
     if (saveChanges)
     {
         wmsEntities.SaveChanges();
     }
 }
Пример #22
0
        private JobTicketView GetJobTicketViewByNo(string jobTicketNo)
        {
            WMSEntities wmsEntities = new WMSEntities();

            return((from jt in wmsEntities.JobTicketView
                    where jt.JobTicketNo == jobTicketNo
                    select jt).FirstOrDefault());
        }
Пример #23
0
 public static bool GetPersonByNameAmbiguous(string name, out Person person, out string errorMessage, WMSEntities wmsEntities = null)
 {
     if (wmsEntities == null)
     {
         wmsEntities = new WMSEntities();
     }
     //如果输入的名字是空的,直接抛出异常。这儿不允许传入空的
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new Exception("GetPersonByNameAmbiguous()函数不允许传入空的零件名字(代号)!空格也不行!请使用string.IsNullOrWhiteSpace()自行判空");
     }
     //首先精确查询,如果没有,再模糊查询
     person = (from p in wmsEntities.Person
               where p.Name == name
               select p).FirstOrDefault();
     //如果搜到了,直接返回
     if (person != null)
     {
         errorMessage = null;
         return(true);
     }
     //如果没搜到,模糊搜索
     Person[] persons = (from p in wmsEntities.Person
                         where p.Name.Contains(name)
                         select p).ToArray();
     //如果模糊搜索也没搜到,提示错误
     if (persons.Length == 0)
     {
         person       = null;
         errorMessage = "未找到人员:" + name;
         return(false);
     }
     //正好一个就太好了,直接返回这一个
     if (persons.Length == 1)
     {
         person       = persons[0];
         errorMessage = null;
         return(true);
     }
     else //如果搜到了多个,那就得让用户选是哪一个了
     {
         Person selectedPerson =
             FormChooseAmbiguousPerson.ChoosePerson(
                 persons,
                 name);
         if (selectedPerson == null)
         {
             errorMessage = "用户取消了导入";
             return(false);
         }
         else
         {
             person       = selectedPerson;
             errorMessage = null;
             return(true);
         }
     }
 }
        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;
        }
Пример #25
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();
        }
Пример #26
0
        private void Search(int selectID = -1)
        {
            WMSEntities wmsEntities = new WMSEntities();
            var         worksheet   = this.reoGridControlMain.Worksheets[0];

            worksheet[0, 1] = "加载中...";
            new Thread(new ThreadStart(() =>
            {
                ShipmentTicketItemView[] shipmentTicketItemViews = null;
                try
                {
                    shipmentTicketItemViews = (from s in wmsEntities.ShipmentTicketItemView
                                               where s.ShipmentTicketID == this.shipmentTicketID
                                               orderby s.ID descending
                                               select s).ToArray();
                }
                catch
                {
                    MessageBox.Show("查询数据失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (this.IsDisposed == false)
                    {
                        this.Invoke(new Action(this.Close));
                    }
                    return;
                }

                this.Invoke(new Action(() =>
                {
                    this.labelStatus.Text = "加载完成";
                    worksheet.DeleteRangeData(RangePosition.EntireRange);
                    worksheet.Rows = shipmentTicketItemViews.Length < 10 ? 10 : shipmentTicketItemViews.Length;
                    if (shipmentTicketItemViews.Length == 0)
                    {
                        worksheet[0, 1] = "没有符合条件的记录";
                    }
                    for (int i = 0; i < shipmentTicketItemViews.Length; i++)
                    {
                        var curShipmentTicketViews = shipmentTicketItemViews[i];
                        object[] columns           = Utilities.GetValuesByPropertieNames(
                            curShipmentTicketViews,
                            (from kn in usedKeyNames where (kn.Visible == true || kn.Key == "ID") select kn.Key).ToArray()
                            );
                        for (int j = 0; j < columns.Length; j++)
                        {
                            worksheet[i, j] = columns[j] == null ? "" : columns[j].ToString();
                        }
                    }
                    if (selectID != -1)
                    {
                        Utilities.SelectLineByID(this.reoGridControlMain, selectID);
                    }
                    this.Invoke(new Action(this.RefreshTextBoxes));
                }));
            })).Start();
        }
Пример #27
0
        public static Func <int> BindTextBoxSelect <TFormSelect, TSelectObject>(Form form, string textBoxName, string fieldName) where TFormSelect : Form, IFormSelect, new()
        {
            int selectedID = -1;

            if (textBoxName.StartsWith("textBox") == false)
            {
                throw new Exception("编辑框名称必须为\"textBox字段名\"形式");
            }
            Control[] foundControls = form.Controls.Find(textBoxName, true);
            if (foundControls.Length == 0)
            {
                throw new Exception(string.Format("窗口{0}中没有名为{1}的编辑框!请检查代码!", form.Text, textBoxName));
            }
            TextBox      textBox  = (TextBox)foundControls[0];
            PropertyInfo property = typeof(TSelectObject).GetProperty(fieldName);

            if (property == null)
            {
                throw new Exception(string.Format("类型{0}中没有字段{1},请检查代码!", typeof(TSelectObject).Name, fieldName));
            }

            TFormSelect formSelect = new TFormSelect();

            formSelect.SetSelectFinishedCallback((id) =>
            {
                selectedID = id;
                if (!form.IsDisposed)
                {
                    WMSEntities wmsEntities      = new WMSEntities();
                    TSelectObject selectedObject = wmsEntities.Database.SqlQuery <TSelectObject>(string.Format("SELECT * FROM {0} WHERE ID = {1}", typeof(TSelectObject).Name, id)).FirstOrDefault();
                    if (selectedObject == null)
                    {
                        MessageBox.Show("选中项目不存在,请重新选择", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    textBox.Text = property.GetValue(selectedObject, null).ToString();
                }
            });

            textBox.Click += (obj, e) =>
            {
                formSelect.Show();
            };

            textBox.KeyDown += (obj, e) =>
            {
                if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
                {
                    selectedID   = -1;
                    textBox.Text = "";
                }
            };

            return(new Func <int>(() => selectedID));
        }
Пример #28
0
 public ActionResult Login()
 {
     using (var db = new WMSEntities())
     {
         ViewBag.settings = db.Settings.FirstOrDefault();
         var sirkets = db.GetSirkets().ToList();
         ViewBag.SirketKodu = new SelectList(sirkets, "Kod", "Ad");
         ViewBag.sayi       = sirkets.Count;
         return(View("Login"));
     }
 }
Пример #29
0
 /// <summary>
 /// dispose
 /// </summary>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (db != null)
         {
             db.Dispose();
             db = null;
         }
     }
 }
Пример #30
0
 /// <summary>
 /// PutUsersOffline
 /// </summary>
 public static void PutUsersOffline()
 {
     using (var db = new WMSEntities())
     {
         foreach (var connection in db.Connections)
         {
             connection.IsOnline = false;
         }
         db.SaveChanges();
     }
 }