Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CHSS.Model.CFunction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CFunction set ");
            strSql.Append("FuncName=@FuncName,");
            strSql.Append("FuncAbbr=@FuncAbbr,");
            strSql.Append("MID=@MID");
            strSql.Append(" where FID=@FID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FuncName", SqlDbType.NVarChar, 50),
                new SqlParameter("@FuncAbbr", SqlDbType.NChar,    50),
                new SqlParameter("@MID",      SqlDbType.Int,       4),
                new SqlParameter("@FID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FuncName;
            parameters[1].Value = model.FuncAbbr;
            parameters[2].Value = model.MID;
            parameters[3].Value = model.FID;

            int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CHSS.Model.CFunction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CFunction(");
            strSql.Append("FuncName,FuncAbbr,MID)");
            strSql.Append(" values (");
            strSql.Append("@FuncName,@FuncAbbr,@MID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FuncName", SqlDbType.NVarChar, 50),
                new SqlParameter("@FuncAbbr", SqlDbType.NChar,    50),
                new SqlParameter("@MID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FuncName;
            parameters[1].Value = model.FuncAbbr;
            parameters[2].Value = model.MID;

            object obj = DBHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtFuncName.Text.Trim().Length == 0)
            {
                strErr += "FuncName不能为空!\\n";
            }
            if (this.txtFuncAbbr.Text.Trim().Length == 0)
            {
                strErr += "FuncAbbr不能为空!\\n";
            }
            //if(!PageValidate.IsNumber(txtMID.Text))
            //{
            //    strErr+="MID格式错误!\\n";
            //}

            //if(strErr!="")
            //{
            //    MessageBox.Show(this,strErr);
            //    return;
            //}
            string FuncName = this.txtFuncName.Text;
            string FuncAbbr = this.txtFuncAbbr.Text;
            int    MID      = int.Parse(this.txtMID.Text);

            CHSS.Model.CFunction model = new CHSS.Model.CFunction();
            model.FuncName = FuncName;
            model.FuncAbbr = FuncAbbr;
            model.MID      = MID;

            CHSS.BLL.CFunction bll = new CHSS.BLL.CFunction();
            bll.Add(model);
            //Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
Beispiel #4
0
 private void ShowInfo(int FID)
 {
     CHSS.BLL.CFunction   bll   = new CHSS.BLL.CFunction();
     CHSS.Model.CFunction model = bll.GetModel(FID);
     this.lblFID.Text      = model.FID.ToString();
     this.txtFuncName.Text = model.FuncName;
     this.txtFuncAbbr.Text = model.FuncAbbr;
     this.txtMID.Text      = model.MID.ToString();
 }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CHSS.Model.CFunction DataRowToModel(DataRow row)
 {
     CHSS.Model.CFunction model = new CHSS.Model.CFunction();
     if (row != null)
     {
         if (row["FID"] != null && row["FID"].ToString() != "")
         {
             model.FID = int.Parse(row["FID"].ToString());
         }
         if (row["FuncName"] != null)
         {
             model.FuncName = row["FuncName"].ToString();
         }
         if (row["FuncAbbr"] != null)
         {
             model.FuncAbbr = row["FuncAbbr"].ToString();
         }
         if (row["MID"] != null && row["MID"].ToString() != "")
         {
             model.MID = int.Parse(row["MID"].ToString());
         }
     }
     return(model);
 }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CHSS.Model.CFunction GetModel(int FID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 FID,FuncName,FuncAbbr,MID from CFunction ");
            strSql.Append(" where FID=@FID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FID", SqlDbType.Int, 4)
            };
            parameters[0].Value = FID;

            CHSS.Model.CFunction model = new CHSS.Model.CFunction();
            DataSet ds = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }