Пример #1
0
    /// <summary>
    /// 初始加载
    /// </summary>
    private void OnStart()
    {
        Owen.Model.Model_Dictionary model = new Owen.BLL.BLL_Dictionary().GetEntity(dicId);

        if (model == null) return;

        ddlDicType.SelectedValue = model.DicType.ToString();
        txtDkey.Text = model.Dkey;
        txtDicName.Text = model.DicName;
        txtMemo.Value = model.Memo;
    }
Пример #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Owen.BLL.BLL_Dictionary bllDic = new Owen.BLL.BLL_Dictionary();

        Owen.Model.Model_Dictionary entity = bllDic.GetEntity(dicId);

        if (entity == null)
            entity = new Owen.Model.Model_Dictionary();

        if (string.IsNullOrEmpty(ddlDicType.SelectedValue))
        {
            JSHelper.Alert(this, "请选择字典类型!");
            return;
        }
        entity.DicType = int.Parse(ddlDicType.SelectedValue);

        if (string.IsNullOrEmpty(txtDicName.Text))
        {
            JSHelper.Alert(this, "请选择字典名!");
            return;
        }

        if (action.Equals("add"))
        {
            if (bllDic.ExistsName(entity.DicType, txtDicName.Text))
            {
                JSHelper.Alert(this, "字典名已存在!");
                return;
            }

            if (!string.IsNullOrEmpty(txtDkey.Text))
            {
                if (bllDic.ExistsName(entity.DicType, txtDkey.Text))
                {
                    JSHelper.Alert(this, "字典Key已存在!");
                    return;
                }
            }
        }

        if (action.Equals("edit"))
        {
            if (bllDic.ExistsName(entity.DicType, txtDicName.Text, dicId))
            {
                JSHelper.Alert(this, "字典名已存在!");
                return;
            }

            if (!string.IsNullOrEmpty(txtDkey.Text))
            {
                if (bllDic.ExistsName(entity.DicType, txtDkey.Text, dicId))
                {
                    JSHelper.Alert(this, "字典Key已存在!");
                    return;
                }
            }
        }

        entity.Dkey = txtDkey.Text;
        entity.DicName = txtDicName.Text;
        entity.Memo = txtMemo.Value;

        switch (action)
        {
            case "add":
                new Owen.BLL.BLL_Dictionary().AddEntity(entity);
                JSHelper.Alert(this, "保存成功!", "DicList.aspx");
                break;
            case "edit":
                new Owen.BLL.BLL_Dictionary().UpdateEntity(entity);
                JSHelper.Alert(this, "保存成功!", "DicList.aspx");
                break;
        }

    }
 /// <summary>
 /// 绑定科室
 /// </summary>
 private void BindDepartment()
 {
     IList<Owen.Model.Model_Dictionary> list = new Owen.BLL.BLL_Dictionary().GetEntities(string.Format(" DicType = {0} ",(int)Owen.Common.DicType.Department));
     ddlDepartment.DataTextField = "DicName";
     ddlDepartment.DataValueField = "DictionaryID";
     ddlDepartment.DataSource = list;
     ddlDepartment.DataBind();
     ddlDepartment.Items.Insert(0, new ListItem("--请选择科室--", ""));
 }