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

            strSql.Append("update CAmbulance set ");
            strSql.Append("AmbuDescription=@AmbuDescription,");
            strSql.Append("AmbuAddDate=@AmbuAddDate,");
            strSql.Append("AmbuNumber=@AmbuNumber,");
            strSql.Append("UID=@UID");
            strSql.Append(" where AID=@AID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AmbuDescription", SqlDbType.NVarChar, 200),
                new SqlParameter("@AmbuAddDate",     SqlDbType.NVarChar,  20),
                new SqlParameter("@AmbuNumber",      SqlDbType.NChar,     10),
                new SqlParameter("@UID",             SqlDbType.Int,        4),
                new SqlParameter("@AID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AmbuDescription;
            parameters[1].Value = model.AmbuAddDate;
            parameters[2].Value = model.AmbuNumber;
            parameters[3].Value = model.UID;
            parameters[4].Value = model.AID;

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

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

            strSql.Append("insert into CAmbulance(");
            strSql.Append("AmbuDescription,AmbuAddDate,AmbuNumber,UID)");
            strSql.Append(" values (");
            strSql.Append("@AmbuDescription,@AmbuAddDate,@AmbuNumber,@UID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AmbuDescription", SqlDbType.NVarChar, 200),
                new SqlParameter("@AmbuAddDate",     SqlDbType.NVarChar,  20),
                new SqlParameter("@AmbuNumber",      SqlDbType.NChar,     10),
                new SqlParameter("@UID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AmbuDescription;
            parameters[1].Value = model.AmbuAddDate;
            parameters[2].Value = model.AmbuNumber;
            parameters[3].Value = model.UID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CHSS.Model.CAmbulance DataRowToModel(DataRow row)
 {
     CHSS.Model.CAmbulance model = new CHSS.Model.CAmbulance();
     if (row != null)
     {
         if (row["AID"] != null && row["AID"].ToString() != "")
         {
             model.AID = int.Parse(row["AID"].ToString());
         }
         if (row["AmbuDescription"] != null)
         {
             model.AmbuDescription = row["AmbuDescription"].ToString();
         }
         if (row["AmbuAddDate"] != null)
         {
             model.AmbuAddDate = row["AmbuAddDate"].ToString();
         }
         if (row["AmbuNumber"] != null)
         {
             model.AmbuNumber = row["AmbuNumber"].ToString();
         }
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
     }
     return(model);
 }
Example #4
0
 private void ShowInfo(int AID)
 {
     CHSS.BLL.CAmbulance   bll   = new CHSS.BLL.CAmbulance();
     CHSS.Model.CAmbulance model = bll.GetModel(AID);
     this.txtAID.Text             = model.AID.ToString();
     this.txtAmbuDescription.Text = model.AmbuDescription;
     this.txtAmbuAddDate.Text     = model.AmbuAddDate;
     this.txtAmbuNumber.Text      = model.AmbuNumber;
 }
Example #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string AmbuDescription = this.txtAmbuDescription.Text;
            string AmbuAddDate     = this.txtAmbuAddDate.Text;
            string AmbuNumber      = this.txtAmbuNumber.Text;
            int    UID             = int.Parse(Session["UID"].ToString());

            CHSS.Model.CAmbulance model = new CHSS.Model.CAmbulance();
            model.AmbuDescription = AmbuDescription;
            model.AmbuAddDate     = AmbuAddDate;
            model.AmbuNumber      = AmbuNumber;
            model.UID             = UID;

            CHSS.BLL.CAmbulance bll = new CHSS.BLL.CAmbulance();
            bll.Add(model);
            Response.Redirect("Show.aspx?id=" + (bll.GetMaxId() - 1));
        }
Example #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            int    AID             = int.Parse(this.txtAID.Text);
            string AmbuDescription = this.txtAmbuDescription.Text;
            string AmbuAddDate     = this.txtAmbuAddDate.Text;
            string AmbuNumber      = this.txtAmbuNumber.Text;
            int    UID             = int.Parse(Session["UID"].ToString());


            CHSS.Model.CAmbulance model = new CHSS.Model.CAmbulance();
            model.AID             = AID;
            model.AmbuDescription = AmbuDescription;
            model.AmbuAddDate     = AmbuAddDate;
            model.AmbuNumber      = AmbuNumber;
            model.UID             = UID;

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

            strSql.Append("select  top 1 AID,AmbuDescription,AmbuAddDate,AmbuNumber,UID from CAmbulance ");
            strSql.Append(" where AID=@AID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AID", SqlDbType.Int, 4)
            };
            parameters[0].Value = AID;

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

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