public FormWareHouseZonePosition_Editor(List <Models.Warehouse> w, List <Models.WarehouseZone> wz)
        {
            InitializeComponent();

            PositionRowCol prc = new PositionRowCol
            {
                NamePrefix = "货位"
            };

            this.textBox1.DataBindings.Add("Text", prc, "Row");
            this.textBox2.DataBindings.Add("Text", prc, "Col");
            this.textBox3.DataBindings.Add("Text", prc, "NamePrefix");
            this.textBox4.DataBindings.Add("Text", prc, "Capacity");

            this.comboBox1.ValueMember   = "Id";
            this.comboBox1.DisplayMember = "Name";
            this.comboBox1.DataSource    = w;
            this.comboBox1.SelectedIndex = 0;

            this.comboBox1.SelectedIndexChanged += (sender, e) =>
            {
                this.comboBox2.ValueMember   = "Id";
                this.comboBox2.DisplayMember = "Name";
                this.comboBox2.DataSource    = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).OrderBy(r => r.Name).ToList();
            };
            #region  钮事件
            this.button2.Click += (sender, e) =>
            {
                this.Dispose();
            };

            #region 提交事件
            this.button1.Click += (sender, e) =>
            {
                #region 提交前检查
                this.button1.Enabled = !this.button1.Enabled;
                this.Validate();

                if ((Guid)this.comboBox1.SelectedValue == Guid.Empty)
                {
                    MessageBox.Show("请选择仓库!");
                    this.button1.Enabled = !this.button1.Enabled;
                    return;
                }
                if (this.comboBox2.SelectedValue == null || (Guid)this.comboBox2.SelectedValue == Guid.Empty)
                {
                    MessageBox.Show("请选择货架!");
                    this.button1.Enabled = !this.button1.Enabled;
                    return;
                }

                if (prc.Row <= 0)
                {
                    MessageBox.Show("请设定货架层数!");
                    this.button1.Enabled = !this.button1.Enabled;
                    return;
                }
                if (prc.Col <= 0)
                {
                    MessageBox.Show("请设定货架列数!");
                    this.button1.Enabled = !this.button1.Enabled;
                    return;
                }
                #endregion

                if (MessageBox.Show("确定要批量新增库位吗?", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.button1.Enabled = !this.button1.Enabled;
                    return;
                }

                List <Models.WarehouseZonePosition> ListPositions = new List <Models.WarehouseZonePosition>();
                Models.WarehouseZonePosition        p             = null;
                int count = 0;
                for (int i = 0; i < prc.Row; i++)
                {
                    for (int j = 0; j < prc.Col; j++)
                    {
                        count++;
                        p = new Models.WarehouseZonePosition
                        {
                            Id              = Guid.NewGuid(),
                            Capacity        = prc.Capacity,
                            CreateUserId    = BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id,
                            Deleted         = false,
                            Memo            = ((Models.WarehouseZone) this.comboBox2.SelectedItem).Name,
                            Name            = prc.NamePrefix + (i + 1).ToString() + "层" + (j + 1).ToString() + "列",
                            PIndex          = count,
                            RowCol          = "第" + (i + 1) + "层,第" + (j + 1).ToString() + "列",
                            UpdateUserId    = BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id,
                            WareHouseZoneId = (Guid)this.comboBox2.SelectedValue
                        };
                        ListPositions.Add(p);
                    }
                }

                bool b = this.PharmacyDatabaseService.AddWareHouseZonePositions(ListPositions.ToArray(), out msg);

                if (b)
                {
                    MessageBox.Show("批量操作成功!");
                    this.PharmacyDatabaseService.WriteLog(BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id, "批量新增库位,所属货架:" + ((Models.WarehouseZone) this.comboBox2.SelectedItem).Name);
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("批量操作失败,请联系管理员!");
                    this.button1.Enabled = !this.button1.Enabled;
                }
            };
            #endregion
            #endregion
        }
        public FormWareHouseZonePositionEdit(List <Models.Warehouse> w, List <Models.WarehouseZone> wz, Business.Models.WareHouseZonePositionModel wzp) : this()
        {
            #region 绑定货位
            var            rc  = wzp.RowCol.Split(',');
            int            row = int.Parse(rc[0].Substring(1, rc[0].Length - 2));
            int            col = int.Parse(rc[1].Substring(1, rc[1].Length - 2));
            PositionRowCol prc = new PositionRowCol
            {
                Capacity   = wzp.Capacity,
                Row        = row,
                Col        = col,
                NamePrefix = wzp.Name
            };
            this.textBox1.DataBindings.Add("Text", prc, "Row");
            this.textBox2.DataBindings.Add("Text", prc, "Col");
            this.textBox3.DataBindings.Add("Text", prc, "NamePrefix");
            this.textBox4.DataBindings.Add("Text", prc, "Capacity");
            #endregion

            #region 绑定仓库,货架
            this.comboBox1.ValueMember   = "Id";
            this.comboBox1.DisplayMember = "Name";
            this.comboBox1.DataSource    = w;
            this.comboBox1.SelectedValue = wzp.WareHouseId;

            Action <object, EventArgs> Combo1SelectedIndexChanged = (sender, ex) =>
            {
                this.comboBox2.ValueMember   = "Id";
                this.comboBox2.DisplayMember = "Name";
                var u = wz.Where(r => r.WarehouseId == (Guid)this.comboBox1.SelectedValue).ToList();
                this.comboBox2.DataSource = u;
                if (u.FirstOrDefault(r => r.Id == wzp.Id) == null)
                {
                    this.comboBox2.SelectedIndex = 0;
                }
                else
                {
                    this.comboBox2.SelectedValue = wzp.WareHouseZoneId;
                }
            };

            Combo1SelectedIndexChanged(null, null);

            this.comboBox1.SelectedIndexChanged += (sender, e) => Combo1SelectedIndexChanged(sender, e);
            #endregion

            #region 提交修改
            this.button1.Click += (sender, e) =>
            {
                if (string.IsNullOrEmpty(prc.NamePrefix))
                {
                    MessageBox.Show("货位名称不能为空"); return;
                }
                if (prc.Row <= 0 || prc.Col <= 0)
                {
                    MessageBox.Show("货位行或列不得小于或等于0"); return;
                }
                var re = MessageBox.Show("确定需要更改该货位信息吗?", "提示", MessageBoxButtons.OKCancel);
                if (re == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                var c = this.PharmacyDatabaseService.GetWarehouseZonePositionById(wzp.Id, out msg);

                if (c == null)
                {
                    MessageBox.Show("数据库发生错误,请联系管理员!"); return;
                }

                c.RowCol          = "第" + prc.Row + "层,第" + prc.Col.ToString() + "列";
                c.Name            = prc.NamePrefix;
                c.WareHouseZoneId = (Guid)this.comboBox2.SelectedValue;
                c.Capacity        = prc.Capacity;

                var sub = new List <Models.WarehouseZonePosition>();
                sub.Add(c);
                var b = this.PharmacyDatabaseService.SaveWareHouseZonePosition(sub, out msg);

                if (b)
                {
                    MessageBox.Show("提交成功!");
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("提交失败,请联系管理员!");
                }
            };
            #endregion

            #region 关闭窗口
            this.button2.Click += (sender, e) =>
            {
                this.Close();
            };
            #endregion
        }