Beispiel #1
0
        private void LoadData()
        {
            switch (Mode)
            {
            case OperateMode.ADD:     // 新增
            {
                txtCode.Value = dictCode;
                break;
            }

            case OperateMode.UPDATE:     // 修改
            {
                DictItems itemModel = diBll.GetModel(itemID);

                if (itemModel == null)
                {
                    WebCommon.DialogAlertMsg(this, "不存在该字典!", "window.history.go(-1);");
                    return;
                }

                txtCode.Value      = itemModel.DictCode;
                txtItemCode.Value  = itemModel.ItemCode;
                UpdateItemCode     = itemModel.ItemCode;
                txtName.Value      = itemModel.ItemName;
                txtItemValue.Value = itemModel.ItemValue;
                txtRemark.Value    = itemModel.Remark;
                break;
            }
            }
        }
Beispiel #2
0
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            DictItems itemModel = new DictItems();
            string    dictCode  = txtCode.Value.Trim();
            string    itemCode  = txtItemCode.Value.Trim();
            string    name      = txtName.Value.Trim();
            string    itemValue = txtItemValue.Value.Trim();
            string    remark    = txtRemark.Value.Trim();

            // 修改
            if (Mode == OperateMode.UPDATE)
            {
                // 如果存在重名,返回
                if (diBll.IsExists(item => item.ItemCode != UpdateItemCode && item.ItemCode == itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号已经存在,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                itemModel                = diBll.GetModel(itemID);
                itemModel.ItemCode       = itemCode;
                itemModel.ItemName       = name;
                itemModel.ItemValue      = itemValue;
                itemModel.Remark         = remark;
                itemModel.LastUpdateDate = DateTime.Now;
                diBll.Update(itemModel);
            }
            else // 新增
            {
                if (string.IsNullOrEmpty(itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号不能为空,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                if (diBll.IsExists(item => item.DictCode == dictCode && item.ItemCode == itemCode))
                {
                    WebCommon.DialogAlertMsg(this, "项编号已经存在,请重新输入!", string.Format("$('#{0}').focus();", txtItemCode.ClientID));
                    return;
                }

                itemModel.DictCode       = dictCode;
                itemModel.CreateDate     = DateTime.Now;
                itemModel.ItemCode       = itemCode;
                itemModel.ItemName       = name;
                itemModel.ItemValue      = itemValue;
                itemModel.Remark         = remark;
                itemModel.LastUpdateDate = DateTime.Now;
                diBll.Add(itemModel);
                WebCommon.ResetControl(this.form1);
            }

            WebCommon.DialogSuccessMsg(this, "保存成功!");
        }
Beispiel #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Dict   dictModel = new Dict();
            string code      = txtCode.Value.Trim();
            string name      = txtName.Value.Trim();
            string remark    = txtRemark.Value.Trim();


            if (Mode == OperateMode.UPDATE)
            {
                dictModel                = dictBll.GetModel(dictID);
                dictModel.DictName       = name;
                dictModel.Remark         = remark;
                dictModel.LastUpdateDate = DateTime.Now;
                dictBll.Update(dictModel);
            }
            else // add
            {
                if (string.IsNullOrEmpty(code))
                {
                    WebCommon.DialogAlertMsg(this, "字典编号不能为空,请重新输入!", string.Format("$('#{0}').focus();", txtCode.ClientID));
                    return;
                }

                if (dictBll.IsExistsCode(code))
                {
                    WebCommon.DialogAlertMsg(this, "字典编号已经存在,请重新输入!", string.Format("$('#{0}').focus();", txtCode.ClientID));
                    return;
                }

                dictModel.Code           = code;
                dictModel.CreateDate     = DateTime.Now;
                dictModel.DictName       = name;
                dictModel.Remark         = remark;
                dictModel.LastUpdateDate = DateTime.Now;
                dictBll.Add(dictModel);
                WebCommon.ResetControl(this.form1);
            }

            WebCommon.DialogSuccessMsg(this, "保存成功!");
        }
Beispiel #4
0
        /// <summary>
        /// 初始化页面内容
        /// </summary>
        private void InitUI()
        {
            // 编辑时加载数据
            if (Mode == OperateMode.UPDATE)
            {
                Department deptModel = deptBll.GetModel(DeptID);

                if (deptModel == null)
                {
                    WebCommon.DialogAlertMsg(this, "不存在该部门!", "window.history.go(-1);");
                    return;
                }

                txtName.Disabled   = true;
                txtName.Value      = deptModel.DeptName;
                txtShortName.Value = deptModel.ShotDeptName;
                txtAddress.Value   = deptModel.Address;
                txtPhone.Value     = deptModel.Tel;
                txtFax.Value       = deptModel.Fax;
                txtRemark.Value    = deptModel.Remark;
            }
        }