예제 #1
0
 private void checkBoxAuthoritySupplier_Click(object sender, EventArgs e)
 {
     if (this.checkBoxAuthoritySupplier.Checked)
     {
         this.checkBoxAuthoritySupplier.Checked = false; //假设用户直接关闭了选择供应商的窗口,则不选中供应商权限
         var formSelectSupplier = new FormSelectSupplier();
         formSelectSupplier.SetSelectFinishedCallback((selectedID) =>
         {
             WMSEntities wmsEntities = new WMSEntities();
             string supplierName     = null;
             try
             {
                 supplierName = (from s in wmsEntities.SupplierView
                                 where s.ID == selectedID
                                 select s.Name).FirstOrDefault();
             }
             catch
             {
                 MessageBox.Show("无法连接服务器,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             if (supplierName == null)
             {
                 MessageBox.Show("选择供应商失败,供应商不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             this.textBoxAuthorityName.Text = "供应商";
             this.curSupplierID             = selectedID;
             this.Controls.Find("textBoxSupplierName", true)[0].Text = supplierName;
             this.checkBoxAuthoritySupplier.Checked = true;
             this.checkBoxAuthorityManager.Enabled  = false;
             this.checkBoxAuthorityManager.Checked  = false;
             this.checkBoxAuthorityReceipt.Enabled  = false;
             this.checkBoxAuthorityReceipt.Checked  = false;
             this.checkBoxAuthorityShipment.Enabled = false;
             this.checkBoxAuthorityShipment.Checked = false;
             this.checkBoxAuthorityStock.Enabled    = false;
             this.checkBoxAuthorityStock.Checked    = false;
         });
         formSelectSupplier.Show();
     }
     else
     {
         DeleteAuthorityName(this.textBoxAuthorityName, "供应商");
         this.curSupplierID = -1;
         this.Controls.Find("textBoxSupplierName", true)[0].Text = "";
         this.checkBoxAuthorityReceipt.Enabled  = true;
         this.checkBoxAuthorityShipment.Enabled = true;
         this.checkBoxAuthorityStock.Enabled    = true;
         this.checkBoxAuthorityManager.Enabled  = true;
     }
 }
예제 #2
0
        private void textBoxSupplierID_Click(object sender, EventArgs e)
        {
            FormSelectSupplier formSelectSupplier = new FormSelectSupplier();

            formSelectSupplier.SetSelectFinishedCallback(new Action <int>((int ID) =>
            {
                //this.Controls.Find("textBoxSupplierNo", true)[0].Text = ID.ToString();
                Supplier supplier = (from s in wmsEntities.Supplier where s.ID == ID select s).FirstOrDefault();
                if (supplier == null)
                {
                    MessageBox.Show("该供应商已被删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    if (supplier.ContractState == "待审核" || supplier.ContractState == "过截止的日期")
                    {
                        if (MessageBox.Show("该供应商的状态为“待审核”或“过截止的日期”,是否继续添加?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            this.supplierID = ID;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                this.supplierID = ID;
                //Supplier supplier = (from s in wmsEntities.Supplier where s.ID == ID select s).FirstOrDefault();
                if (supplier != null)
                {
                    this.Controls.Find("textBoxSupplierName", true)[0].Text   = supplier.Name;
                    this.Controls.Find("textBoxSupplierNumber", true)[0].Text = supplier.Number;
                    //this.Controls.Find("textBoxSupplierNo", true)[0].Text
                }
            }));
            formSelectSupplier.ShowDialog();
        }