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

            strSql.Append("update CCommunityAgency set ");
            strSql.Append("CommDescription=@CommDescription,");
            strSql.Append("CommAddDate=@CommAddDate,");
            strSql.Append("CommName=@CommName,");
            strSql.Append("UID=@UID");
            strSql.Append(" where CID=@CID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommDescription", SqlDbType.NVarChar, 200),
                new SqlParameter("@CommAddDate",     SqlDbType.NVarChar,  20),
                new SqlParameter("@CommName",        SqlDbType.NVarChar,  20),
                new SqlParameter("@UID",             SqlDbType.Int,        4),
                new SqlParameter("@CID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CommDescription;
            parameters[1].Value = model.CommAddDate;
            parameters[2].Value = model.CommName;
            parameters[3].Value = model.UID;
            parameters[4].Value = model.CID;

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

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

            strSql.Append("insert into CCommunityAgency(");
            strSql.Append("CommDescription,CommAddDate,CommName,UID)");
            strSql.Append(" values (");
            strSql.Append("@CommDescription,@CommAddDate,@CommName,@UID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommDescription", SqlDbType.NVarChar, 200),
                new SqlParameter("@CommAddDate",     SqlDbType.NVarChar,  20),
                new SqlParameter("@CommName",        SqlDbType.NVarChar,  20),
                new SqlParameter("@UID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CommDescription;
            parameters[1].Value = model.CommAddDate;
            parameters[2].Value = model.CommName;
            parameters[3].Value = model.UID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CHSS.Model.CCommunityAgency DataRowToModel(DataRow row)
 {
     CHSS.Model.CCommunityAgency model = new CHSS.Model.CCommunityAgency();
     if (row != null)
     {
         if (row["CID"] != null && row["CID"].ToString() != "")
         {
             model.CID = int.Parse(row["CID"].ToString());
         }
         if (row["CommDescription"] != null)
         {
             model.CommDescription = row["CommDescription"].ToString();
         }
         if (row["CommAddDate"] != null)
         {
             model.CommAddDate = row["CommAddDate"].ToString();
         }
         if (row["CommName"] != null)
         {
             model.CommName = row["CommName"].ToString();
         }
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
     }
     return(model);
 }
예제 #4
0
 private void ShowInfo(int CID)
 {
     CHSS.BLL.CCommunityAgency   bll   = new CHSS.BLL.CCommunityAgency();
     CHSS.Model.CCommunityAgency model = bll.GetModel(CID);
     this.txtCID.Text             = model.CID.ToString();
     this.txtCommDescription.Text = model.CommDescription;
     this.txtCommAddDate.Text     = model.CommAddDate;
     this.txtCommName.Text        = model.CommName;
 }
예제 #5
0
파일: Add.aspx.cs 프로젝트: GnohiSiaM/demos
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string CommDescription = this.txtCommDescription.Text;
            string CommAddDate     = this.txtCommAddDate.Text;
            string CommName        = this.txtCommName.Text;
            int    UID             = int.Parse(Session["UID"].ToString());

            CHSS.Model.CCommunityAgency model = new CHSS.Model.CCommunityAgency();
            model.CommDescription = CommDescription;
            model.CommAddDate     = CommAddDate;
            model.CommName        = CommName;
            model.UID             = UID;

            CHSS.BLL.CCommunityAgency bll = new CHSS.BLL.CCommunityAgency();
            bll.Add(model);
            Response.Redirect("Show.aspx?id=" + (bll.GetMaxId() - 1));
        }
예제 #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            int    CID             = int.Parse(this.txtCID.Text);
            string CommDescription = this.txtCommDescription.Text;
            string CommAddDate     = this.txtCommAddDate.Text;
            string CommName        = this.txtCommName.Text;
            int    UID             = int.Parse(Session["UID"].ToString());


            CHSS.Model.CCommunityAgency model = new CHSS.Model.CCommunityAgency();
            model.CID             = CID;
            model.CommDescription = CommDescription;
            model.CommAddDate     = CommAddDate;
            model.CommName        = CommName;
            model.UID             = UID;

            CHSS.BLL.CCommunityAgency bll = new CHSS.BLL.CCommunityAgency();
            bll.Update(model);
            Response.Redirect("Show.aspx?id=" + CID);
        }
예제 #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CHSS.Model.CCommunityAgency GetModel(int CID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CID,CommDescription,CommAddDate,CommName,UID from CCommunityAgency ");
            strSql.Append(" where CID=@CID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CID", SqlDbType.Int, 4)
            };
            parameters[0].Value = CID;

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

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