Пример #1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            WMS.DataAccess.StockInfoCheckTicket stockInfoCheck = null;

            if (this.mode == FormMode.ALTER)
            {
                try
                {
                    stockInfoCheck = (from s in this.wmsEntities.StockInfoCheckTicket
                                      where s.ID == this.stockInfoCheckID
                                      select s).FirstOrDefault();
                    stockInfoCheck.LastUpdateUserID = Convert.ToString(userID);
                }
                catch
                {
                    MessageBox.Show("要修改的项目已不存在,请确认后操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    this.Close();
                    return;
                }
            }
            else if (mode == FormMode.ADD)
            {
                stockInfoCheck = new WMS.DataAccess.StockInfoCheckTicket();
                this.wmsEntities.StockInfoCheckTicket.Add(stockInfoCheck);
                stockInfoCheck.CreateUserID   = userID;
                stockInfoCheck.CheckDate      = Convert.ToDateTime(DateTime.Now.ToLongDateString());
                stockInfoCheck.CreateTime     = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
                stockInfoCheck.LastUpdateTime = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
            }

            stockInfoCheck.WarehouseID = warehouseID;
            stockInfoCheck.ProjectID   = projectID;

            stockInfoCheck.LastUpdateUserID = Convert.ToString(userID);

            wmsEntities.SaveChanges();
            //调用回调函数

            if (this.mode == FormMode.ALTER && this.modifyFinishedCallback != null)
            {
                this.modifyFinishedCallback(stockInfoCheck.ID);
            }
            else if (this.mode == FormMode.ADD && this.addFinishedCallback != null)
            {
                this.addFinishedCallback(stockInfoCheck.ID);
            }


            this.Close();
        }
Пример #2
0
        private void buttonModify_Click(object sender, EventArgs e)
        {
            TextBox textBoxPersonName = (TextBox)this.Controls.Find("textBoxPersonName", true)[0];

            if (textBoxPersonName.Text == string.Empty)
            {
                MessageBox.Show("请选择责任人", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);


                return;
            }
            WMS.DataAccess.StockInfoCheckTicket stockInfoCheck = null;

            if (this.mode == FormMode.ALTER)
            {
                try
                {
                    stockInfoCheck = (from s in this.wmsEntities.StockInfoCheckTicket
                                      where s.ID == this.stockInfoCheckID
                                      select s).FirstOrDefault();
                }
                catch
                {
                    MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    this.Close();
                    return;
                }
                if (stockInfoCheck == null)
                {
                    MessageBox.Show("修改失败,盘点单已不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                    return;
                }
            }
            else if (mode == FormMode.ADD)
            {
                stockInfoCheck = new WMS.DataAccess.StockInfoCheckTicket();
                this.wmsEntities.StockInfoCheckTicket.Add(stockInfoCheck);
            }

            if (Utilities.CopyTextBoxTextsToProperties(this, stockInfoCheck, StockInfoCheckTicketViewMetaData.KeyNames, out string errorMessage) == false)
            {
                MessageBox.Show(errorMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            if (this.mode == FormMode.ALTER)
            {
                stockInfoCheck.LastUpdateUserID = Convert.ToString(userID);
                stockInfoCheck.LastUpdateTime   = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
                if (this.personidc == 0)
                {
                    this.personid = Convert.ToInt32(stockInfoCheck.PersonID);
                }
            }
            else if (mode == FormMode.ADD)
            {
                stockInfoCheck.CreateUserID = userID;
                stockInfoCheck.CheckDate    = Convert.ToDateTime(DateTime.Now.ToLongDateString());
                //stockInfoCheck.CreateTime = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
                stockInfoCheck.LastUpdateTime = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
            }



            stockInfoCheck.WarehouseID = warehouseID;
            stockInfoCheck.ProjectID   = projectID;
            stockInfoCheck.PersonID    = this.personid;

            stockInfoCheck.LastUpdateUserID = Convert.ToString(userID);
            try
            {
                wmsEntities.SaveChanges();
            }
            catch
            {
                MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //调用回调函数

            if (this.mode == FormMode.ALTER && this.modifyFinishedCallback != null)
            {
                this.modifyFinishedCallback(stockInfoCheck.ID);
            }
            else if (this.mode == FormMode.ADD && this.addFinishedCallback != null)
            {
                this.addFinishedCallback(stockInfoCheck.ID);
            }


            this.Close();
        }