示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(tbCode.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "此项不能为空!");
                tbCode.Focus();
            }
            else if (string.IsNullOrEmpty(tbName.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "此项不能为空!");
                tbName.Focus();
            }
            #endregion
            LabMS.Model.Dictionary MD = new LabMS.Model.Dictionary();

            MD.ID = ID;
            MD.DClass = ED.GetListByID(ID)[0].DClass;
            MD.Code = tbCode.Text.Trim();
            MD.Name = tbName.Text.Trim();

            try
            {
                ED.Update(MD);
            }
            catch(Exception ex)
            {
                throw ex;
            }
            Common.JShelper.JSAlertAndRedirect(this.Page, "", "更新成功!", "DictionaryMaintenance.aspx?Name="+Server.HtmlEncode(MD.Name)+"&Code="+Server.HtmlEncode(MD.DClass));
        }
示例#2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(tbCode.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "此项不能为空!");
                tbCode.Focus();
            }
            else if (string.IsNullOrEmpty(tbName.Text.Trim()))
            {
                Common.JShelper.JSAlert(this.Page, "", "此项不能为空!");
                tbName.Focus();
            }
            #endregion
            else
            {
                ExtendBLL.Dictionary EB = new ExtendBLL.Dictionary();
                LabMS.Model.Dictionary MD = new LabMS.Model.Dictionary();
                if (EB.IsCodeExist(DClass, tbCode.Text.Trim()) == 0)
                {
                    Common.JShelper.JSAlert(this.Page, "", "该值已经存在!");
                    tbCode.Text = "";
                    tbCode.Focus();
                }
                else
                {
                    MD.DClass = DClass;
                    MD.Name = tbName.Text.Trim();
                    MD.Code = tbCode.Text.Trim();

                    int count = EB.Add(MD);
                    if (count > 0)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('新增成功!');window.opener.location.href=window.opener.location.href;self.close();</script>");
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Dictionary GetModel(long ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,DClass,Code,Name from Dictionary ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.BigInt)};
            parameters[0].Value = ID;

            LabMS.Model.Dictionary model=new LabMS.Model.Dictionary();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.DClass=ds.Tables[0].Rows[0]["DClass"].ToString();
                model.Code=ds.Tables[0].Rows[0]["Code"].ToString();
                model.Name=ds.Tables[0].Rows[0]["Name"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }