Example #1
0
        protected void btnAddSub_Click(object sender, EventArgs e)
        {
            Dictronary subupdating = new Dictronary();
            subupdating.DictCode = txtDictCode.Text;
            subupdating.DictType = Request.QueryString["val"];
            subupdating.DictName = txtDictName.Text;
            subupdating.DictDesc = txtDictDesc.Text;
            ObservableCollection<Dictronary> List = new DictronaryDAL().QueryByType(Request["val"]);
            foreach (Dictronary obj in List)
            {
                if (obj.DictCode == subupdating.DictCode)
                {
                    Alert("您已提交过该编号了!");
                    return;
                }
            }

            new DictronaryDAL().Add(subupdating);
            txtDictCode.Text = "";
            txtDictName.Text = "";
            txtDictDesc.Text = "";
            InitPage();
        }
Example #2
0
        protected void gridSubName_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string strCode=((TextBox)gridSubName.Rows[e.RowIndex].FindControl("txtDictCode")).Text.Trim();
            if (strCode.Length > 0)
            {
                try
                {
                    if (!CheckString(strCode))
                    {
                        Alert("请勿输入特殊字符!");
                        return;
                    }
                    string oldSub = ((TextBox)gridSubName.Rows[e.RowIndex].FindControl("txtOldSubName")).Text;
                    if (Request["val"].ToString() != "")
                    {
                        ObservableCollection<Dictronary> List = new DictronaryDAL().SelectSubWithoutSelf(Request["val"], oldSub);
                        foreach (Dictronary obj in List)
                        {
                            if (obj.DictCode == strCode)
                            {
                                Alert("您已提交过该名称了!");
                                return;
                            }
                        }
                    }
                    Dictronary subupdating = new Dictronary();

                    subupdating.DictCode = strCode;
                    subupdating.DictType = Request.QueryString["val"];
                    subupdating.DictName = ((TextBox)gridSubName.Rows[e.RowIndex].FindControl("txtDictName")).Text;
                    subupdating.DictDesc = ((TextBox)gridSubName.Rows[e.RowIndex].FindControl("txtDictDesc")).Text;

                    new DictronaryDAL().Update(subupdating,oldSub);

                    gridSubName.EditIndex = -1;
                    InitPage();
                }
                catch (Exception ex)
                {
                    Alert(ex);
                }
            }
            else
            {
                Alert("子类名称不能为空!"); return;
            }
        }