コード例 #1
0
        /// <summary>
        /// 添加仓位
        /// </summary>
        private void AddWarehouseBin()
        {
            FrmWarehouseBinManager warehouseBinManager = new FrmWarehouseBinManager();

            DialogResult dialogResult = warehouseBinManager.ShowDialog();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_WH_ID = txtWH_ID.Text.Trim();
            if (dialogResult != DialogResult.OK)
            {
                return;
            }
            if (string.IsNullOrEmpty(warehouseBinManager.warehouseBinManagerUIModel.WHB_Name))
            {
                //仓位名称不能为空
                MessageBoxs.Show(Trans.PIS, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0001, new object[] { SystemTableColumnEnums.PIS_WarehouseBin.Name.WHB_Name }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //接受仓位窗体传来的值
            WarehouseBinManagerUIModel warehouseBin = new WarehouseBinManagerUIModel()
            {
                WHB_Name = warehouseBinManager.warehouseBinManagerUIModel.WHB_Name,
                WHB_Description = warehouseBinManager.warehouseBinManagerUIModel.WHB_Description,
                WHB_IsValid = warehouseBinManager.warehouseBinManagerUIModel.WHB_IsValid,
                WHB_VersionNo = warehouseBinManager.warehouseBinManagerUIModel.WHB_VersionNo,
                WHB_CreatedBy = warehouseBinManager.warehouseBinManagerUIModel.WHB_CreatedBy,
                WHB_CreatedTime = warehouseBinManager.warehouseBinManagerUIModel.WHB_CreatedTime,
                WHB_UpdatedBy = LoginInfoDAX.UserName,
                WHB_UpdatedTime = DateTime.Now,
                Tmp_SID_ID = warehouseBinManager.warehouseBinManagerUIModel.Tmp_SID_ID
            };
            //判断传来仓位名称是否重复
            foreach (var loopwarehouseBin in _warehouseBinList)
            {
                if (loopwarehouseBin.WHB_Name == warehouseBin.WHB_Name)
                {
                    //仓位名称已存在
                    MessageBoxs.Show(Trans.PIS, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0006, new object[] { SystemTableColumnEnums.PIS_WarehouseBin.Name.WHB_Name }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            _warehouseBinList.Insert(0, warehouseBin);

            if (dialogResult == DialogResult.OK)
            {
                warehouseBinManager.Close();
                gdGridWarehouseBin.DataSource = _warehouseBinList;
                gdGridWarehouseBin.DataBind();
                //设置Grid自适应列宽(根据单元格内容)
                gdGridWarehouseBin.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.VisibleRows);
                //设置单元格样式
                SetWarehouseStyle();
            }
        }
コード例 #2
0
        /// <summary>
        /// 将Grid中值赋值给属性,留页面传参用
        /// </summary>
        private void UpdateWarehouseBin()
        {
            //初始化窗体对象
            FrmWarehouseBinManager warehouseBinManager = new FrmWarehouseBinManager();
            //获取双击的行
            int activeRowIndex = gdGridWarehouseBin.ActiveRow.Index;
            //取得双击行的值
            warehouseBinManager.warehouseBinManagerUIModel.WHB_ID = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_ID].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_WH_ID = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_WH_ID].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_Name = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_Name].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_Description = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_Description].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_CreatedBy = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_CreatedBy].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_UpdatedBy = gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_UpdatedBy].Text.Trim();
            warehouseBinManager.warehouseBinManagerUIModel.WHB_VersionNo = Convert.ToInt64(gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_VersionNo].Text.Trim());
            warehouseBinManager.warehouseBinManagerUIModel.WHB_IsValid = Convert.ToBoolean(gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_IsValid].Text.Trim());
            warehouseBinManager.warehouseBinManagerUIModel.WHB_CreatedTime = Convert.ToDateTime(gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_CreatedTime].Text.Trim());
            warehouseBinManager.warehouseBinManagerUIModel.WHB_UpdatedTime = Convert.ToDateTime(gdGridWarehouseBin.Rows[activeRowIndex].Cells[SystemTableColumnEnums.PIS_WarehouseBin.Code.WHB_UpdatedTime].Text.Trim());
            warehouseBinManager.warehouseBinManagerUIModel.Tmp_SID_ID = gdGridWarehouseBin.Rows[activeRowIndex].Cells["Tmp_SID_ID"].Text.Trim();
            //显示窗体
            warehouseBinManager.ShowDialog();
            //判断修改的仓位名称是否重复
            foreach (var loopWarehouseBin in _warehouseBinList)
            {
                if (loopWarehouseBin.WHB_Name == warehouseBinManager.warehouseBinManagerUIModel.WHB_Name && loopWarehouseBin.Tmp_SID_ID != warehouseBinManager.warehouseBinManagerUIModel.Tmp_SID_ID)
                {
                    //仓位名称已存在
                    MessageBoxs.Show(Trans.PIS, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0006, new object[] { SystemTableColumnEnums.PIS_WarehouseBin.Name.WHB_Name }), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            //将修改过的信息赋值给对应的_warehouseBinList
            foreach (var loopWarehouseBin in _warehouseBinList)
            {
                if (loopWarehouseBin.Tmp_SID_ID == warehouseBinManager.warehouseBinManagerUIModel.Tmp_SID_ID)
                {
                    loopWarehouseBin.WHB_ID = warehouseBinManager.warehouseBinManagerUIModel.WHB_ID;
                    loopWarehouseBin.WHB_WH_ID = warehouseBinManager.warehouseBinManagerUIModel.WHB_WH_ID;
                    loopWarehouseBin.WHB_Name = warehouseBinManager.warehouseBinManagerUIModel.WHB_Name;
                    loopWarehouseBin.WHB_Description = warehouseBinManager.warehouseBinManagerUIModel.WHB_Description;
                    loopWarehouseBin.WHB_VersionNo = warehouseBinManager.warehouseBinManagerUIModel.WHB_VersionNo;
                    loopWarehouseBin.WHB_IsValid = warehouseBinManager.warehouseBinManagerUIModel.WHB_IsValid;
                    loopWarehouseBin.WHB_UpdatedBy = LoginInfoDAX.UserName;
                    loopWarehouseBin.WHB_UpdatedTime = DateTime.Now;
                }
            }
            gdGridWarehouseBin.DataSource = _warehouseBinList;
            gdGridWarehouseBin.DataBind();

            gdGridWarehouseBin.UpdateData();
        }