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

            strSql.Append("update typeInfo set ");
            strSql.Append("typeName=@typeName,");
            strSql.Append("ext1=@ext1,");
            strSql.Append("ext2=@ext2,");
            strSql.Append("ext3=@ext3");
            strSql.Append(" where typeId=@typeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeName", SqlDbType.VarChar,  50),
                new SqlParameter("@ext1",     SqlDbType.VarChar, 200),
                new SqlParameter("@ext2",     SqlDbType.VarChar, 200),
                new SqlParameter("@ext3",     SqlDbType.VarChar, 200),
                new SqlParameter("@typeId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.typeName;
            parameters[1].Value = model.ext1;
            parameters[2].Value = model.ext2;
            parameters[3].Value = model.ext3;
            parameters[4].Value = model.typeId;

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

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

            strSql.Append("insert into typeInfo(");
            strSql.Append("typeName,ext1,ext2,ext3)");
            strSql.Append(" values (");
            strSql.Append("@typeName,@ext1,@ext2,@ext3)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeName", SqlDbType.VarChar,  50),
                new SqlParameter("@ext1",     SqlDbType.VarChar, 200),
                new SqlParameter("@ext2",     SqlDbType.VarChar, 200),
                new SqlParameter("@ext3",     SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.typeName;
            parameters[1].Value = model.ext1;
            parameters[2].Value = model.ext2;
            parameters[3].Value = model.ext3;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public rr2.Model.typeInfo DataRowToModel(DataRow row)
 {
     rr2.Model.typeInfo model = new rr2.Model.typeInfo();
     if (row != null)
     {
         if (row["typeId"] != null && row["typeId"].ToString() != "")
         {
             model.typeId = int.Parse(row["typeId"].ToString());
         }
         if (row["typeName"] != null)
         {
             model.typeName = row["typeName"].ToString();
         }
         if (row["ext1"] != null)
         {
             model.ext1 = row["ext1"].ToString();
         }
         if (row["ext2"] != null)
         {
             model.ext2 = row["ext2"].ToString();
         }
         if (row["ext3"] != null)
         {
             model.ext3 = row["ext3"].ToString();
         }
     }
     return(model);
 }
Example #4
0
 private void ShowInfo(int typeId)
 {
     rr2.BLL.typeInfo   bll   = new rr2.BLL.typeInfo();
     rr2.Model.typeInfo model = bll.GetModel(typeId);
     this.lbltypeId.Text   = model.typeId.ToString();
     this.lbltypeName.Text = model.typeName;
     this.lblext1.Text     = model.ext1;
     this.lblext2.Text     = model.ext2;
     this.lblext3.Text     = model.ext3;
 }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string typeid = Request.QueryString["typeId"];

            if (!IsPostBack)
            {
                mdltype     = blltype.GetModel(int.Parse(typeid));
                TBtype.Text = mdltype.typeName;
            }
        }
Example #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txttypeName.Text.Trim().Length == 0)
            {
                strErr += "typeName不能为空!\\n";
            }
            if (this.txtext1.Text.Trim().Length == 0)
            {
                strErr += "ext1不能为空!\\n";
            }
            if (this.txtext2.Text.Trim().Length == 0)
            {
                strErr += "ext2不能为空!\\n";
            }
            if (this.txtext3.Text.Trim().Length == 0)
            {
                strErr += "ext3不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    typeId   = int.Parse(this.lbltypeId.Text);
            string typeName = this.txttypeName.Text;
            string ext1     = this.txtext1.Text;
            string ext2     = this.txtext2.Text;
            string ext3     = this.txtext3.Text;


            rr2.Model.typeInfo model = new rr2.Model.typeInfo();
            model.typeId   = typeId;
            model.typeName = typeName;
            model.ext1     = ext1;
            model.ext2     = ext2;
            model.ext3     = ext3;

            rr2.BLL.typeInfo bll = new rr2.BLL.typeInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public rr2.Model.typeInfo GetModel(int typeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 typeId,typeName,ext1,ext2,ext3 from typeInfo ");
            strSql.Append(" where typeId=@typeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = typeId;

            rr2.Model.typeInfo model = new rr2.Model.typeInfo();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

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