Exemplo n.º 1
0
        private void Search(bool savePage = false, int selectID = -1)
        {
            this.pagerWidget.ClearCondition();
            if (this.key != null && this.value != null)
            {
                pagerWidget.AddCondition(this.key, this.value);
                pagerWidget.Search();
            }
            else
            {
                //pagerWidget.AddCondition("状态", "待上架");
                //pagerWidget.AddCondition("状态", "部分上架");
            }

            //if (this.putawayTicketID != -1)
            //{
            //    pagerWidget.AddCondition("上架单ID", this.putawayTicketID.ToString());
            //}

            this.pagerWidget.Search(savePage, selectID, (putawayTicket) => { this.RefreshTextBoxes(); });
            //this.pagerWidget.Show();
        }
Exemplo n.º 2
0
        private void toolStripButtonDelete_Click(object sender, EventArgs e)
        {
            var        worksheet = this.reoGridControlUser.Worksheets[0];
            List <int> deleteIDs = new List <int>();

            for (int i = 0; i < worksheet.SelectionRange.Rows; i++)
            {
                try
                {
                    int curID = int.Parse(worksheet[i + worksheet.SelectionRange.Row, 0].ToString());
                    deleteIDs.Add(curID);
                }
                catch
                {
                    continue;
                }
            }
            if (deleteIDs.Count == 0)
            {
                MessageBox.Show("请选择您要删除的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (MessageBox.Show("您真的要删除这些记录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            WMSEntities wmsEntities = new WMSEntities();

            foreach (int id in deleteIDs)
            {
                //if (MessageBox.Show("确定删除该上架单?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                //{
                PutawayTicket putawayTicket = (from pt in wmsEntities.PutawayTicket where pt.ID == id select pt).FirstOrDefault();
                if (putawayTicket == null)
                {
                    MessageBox.Show("该上架单已被删除,请刷新查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    return;
                }
                //if (putawayTicket.State != "待上架")
                //{
                //    MessageBox.Show("该上架单已有部分或者全部上架,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                //    continue;
                //}
                ReceiptTicket       receiptTicket      = (from rt in wmsEntities.ReceiptTicket where rt.ID == putawayTicket.ReceiptTicketID select rt).FirstOrDefault();
                PutawayTicketItem[] putawayTicketItems = putawayTicket.PutawayTicketItem.ToArray();
                int n = 0;
                foreach (PutawayTicketItem pti in putawayTicketItems)
                {
                    ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == pti.ReceiptTicketItemID select rti).FirstOrDefault();
                    if (receiptTicketItem != null)
                    {
                        receiptTicketItem.HasPutwayAmount -= (pti.ScheduledMoveCount == null ? 0 : pti.ScheduledMoveCount) - (pti.PutawayAmount == null ? 0 : pti.PutawayAmount);
                        //receiptTicketItem.HasPutwayAmount += pti.PutawayAmount;
                        if (receiptTicketItem.HasPutwayAmount == 0)
                        {
                            n++;
                        }
                    }
                }
                if (n == putawayTicketItems.Length)
                {
                    receiptTicket.HasPutawayTicket = "未生成上架单";
                }
                else
                {
                    receiptTicket.HasPutawayTicket = "部分生成上架单";
                }
                try
                {
                    wmsEntities.Database.ExecuteSqlCommand("DELETE FROM PutawayTicket WHERE ID = @putawayTicketID", new SqlParameter("putawayTicketID", id));
                }
                catch
                {
                    MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    return;
                }
                //}
            }
            MessageBox.Show("成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            try
            {
                new Thread(() =>
                {
                    wmsEntities.SaveChanges();
                    this.Invoke(new Action(() =>
                    {
                        if (this.key != null || this.value != null)
                        {
                            pagerWidget.AddCondition(this.key, this.value);
                        }
                        pagerWidget.Search();
                    }));
                }).Start();
            }
            catch
            {
                MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                return;
            }
            //var worksheet = this.reoGridControlUser.Worksheets[0];
            //try
            //{

            /*
             * if (worksheet.SelectionRange.Rows != 1)
             * {
             *  MessageBox.Show("请选择一项进行查看", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             * int putawayTicketID;
             * try
             * {
             *  putawayTicketID = int.Parse(worksheet[worksheet.SelectionRange.Row, 0].ToString());
             * }
             * catch
             * {
             *  MessageBox.Show("请选择一项进行查看", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }  */
            //FormShelvesItem formShelvesItem = new FormShelvesItem(putawayTicketID);

            /*
             * if (MessageBox.Show("确定删除该上架单?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             * {
             *  PutawayTicket putawayTicket = (from pt in wmsEntities.PutawayTicket where pt.ID == putawayTicketID select pt).FirstOrDefault();
             *  if (putawayTicket == null)
             *  {
             *      MessageBox.Show("该上架单已被删除,请刷新查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
             *      return;
             *  }
             *  if (putawayTicket.State != "待上架")
             *  {
             *      MessageBox.Show("该上架单已有部分或者全部上架,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
             *      return;
             *  }
             *  ReceiptTicket receiptTicket = (from rt in wmsEntities.ReceiptTicket where rt.ID == putawayTicket.ReceiptTicketID select rt).FirstOrDefault();
             *  PutawayTicketItem[] putawayTicketItems = putawayTicket.PutawayTicketItem.ToArray();
             *  int n = 0;
             *  foreach (PutawayTicketItem pti in putawayTicketItems)
             *  {
             *      ReceiptTicketItem receiptTicketItem = (from rti in wmsEntities.ReceiptTicketItem where rti.ID == pti.ReceiptTicketItemID select rti).FirstOrDefault();
             *      if (receiptTicketItem != null)
             *      {
             *          receiptTicketItem.HasPutwayAmount -= pti.ScheduledMoveCount;
             *          if (receiptTicketItem.HasPutwayAmount == 0)
             *          {
             *              n++;
             *          }
             *      }
             *  }
             *  if (n == putawayTicketItems.Length)
             *  {
             *      receiptTicket.HasPutawayTicket = "未生成上架单";
             *  }
             *  else
             *  {
             *      receiptTicket.HasPutawayTicket = "部分生成上架单";
             *  }
             *  try
             *  {
             *      new Thread(() =>
             *      {
             *          wmsEntities.Database.ExecuteSqlCommand("DELETE FROM PutawayTicket WHERE ID = @putawayTicketID", new SqlParameter("putawayTicketID", putawayTicketID));
             *          wmsEntities.SaveChanges();
             *          MessageBox.Show("成功");
             *          this.Invoke(new Action(() =>
             *          {
             *              if (this.key != null || this.value != null)
             *              {
             *                  pagerWidget.AddCondition(this.key, this.value);
             *              }
             *              pagerWidget.Search();
             *          }));
             *      }).Start();
             *  }
             *  catch (EntityException)
             *  {
             *      MessageBox.Show("该上架单已被删除!");
             *  }
             *  catch (Exception)
             *  {
             *      MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
             *      return;
             *  }
             * }
             * }
             * catch
             * {
             * MessageBox.Show("无法连接到数据库,请查看网络连接!", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
             * return;
             * }*/
        }