Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.ManageUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ManageUser(");
            strSql.Append("UsersID,ManageFareID,ChargeDate,LastDate,ReMark,Status)");
            strSql.Append(" values (");
            strSql.Append("@UsersID,@ManageFareID,@ChargeDate,@LastDate,@ReMark,@Status)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UsersID",      SqlDbType.Int,         4),
                new SqlParameter("@ManageFareID", SqlDbType.VarChar,   200),
                new SqlParameter("@ChargeDate",   SqlDbType.DateTime),
                new SqlParameter("@LastDate",     SqlDbType.DateTime),
                new SqlParameter("@ReMark",       SqlDbType.VarChar,   200),
                new SqlParameter("@Status",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UsersID;
            parameters[1].Value = model.ManageFareID;
            parameters[2].Value = model.ChargeDate;
            parameters[3].Value = model.LastDate;
            parameters[4].Value = model.ReMark;
            parameters[5].Value = model.Status;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.ManageUser DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.ManageUser model = new WebDemo.Model.WebDemo.ManageUser();
     if (row != null)
     {
         if (row["UsersID"] != null && row["UsersID"].ToString() != "")
         {
             model.UsersID = int.Parse(row["UsersID"].ToString());
         }
         if (row["ManageFareID"] != null)
         {
             model.ManageFareID = row["ManageFareID"].ToString();
         }
         if (row["ChargeDate"] != null && row["ChargeDate"].ToString() != "")
         {
             model.ChargeDate = DateTime.Parse(row["ChargeDate"].ToString());
         }
         if (row["LastDate"] != null && row["LastDate"].ToString() != "")
         {
             model.LastDate = DateTime.Parse(row["LastDate"].ToString());
         }
         if (row["ReMark"] != null)
         {
             model.ReMark = row["ReMark"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.ManageUser GetModel(int UsersID, string ManageFareID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UsersID,ManageFareID,ChargeDate,LastDate,ReMark,Status from ManageUser ");
            strSql.Append(" where UsersID=@UsersID and ManageFareID=@ManageFareID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UsersID",      SqlDbType.Int,     4),
                new SqlParameter("@ManageFareID", SqlDbType.VarChar, 200)
            };
            parameters[0].Value = UsersID;
            parameters[1].Value = ManageFareID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
 private void ShowInfo(int UsersID, string ManageFareID)
 {
     WebDemo.BLL.WebDemo.ManageUser   bll   = new WebDemo.BLL.WebDemo.ManageUser();
     WebDemo.Model.WebDemo.ManageUser model = bll.GetModel(UsersID, ManageFareID);
     this.lblUsersID.Text      = model.UsersID.ToString();
     this.lblManageFareID.Text = model.ManageFareID;
     this.lblChargeDate.Text   = model.ChargeDate.ToString();
     this.lblLastDate.Text     = model.LastDate.ToString();
     this.lblReMark.Text       = model.ReMark;
     this.lblStatus.Text       = model.Status.ToString();
 }
Esempio n. 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUsersID.Text))
            {
                strErr += "用户ID格式错误!\\n";
            }
            if (this.txtManageFareID.Text.Trim().Length == 0)
            {
                strErr += "物业费ID不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtChargeDate.Text))
            {
                strErr += "启用时间格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtLastDate.Text))
            {
                strErr += "最后一次收费格式错误!\\n";
            }
            if (this.txtReMark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      UsersID      = int.Parse(this.txtUsersID.Text);
            string   ManageFareID = this.txtManageFareID.Text;
            DateTime ChargeDate   = DateTime.Parse(this.txtChargeDate.Text);
            DateTime LastDate     = DateTime.Parse(this.txtLastDate.Text);
            string   ReMark       = this.txtReMark.Text;
            int      Status       = int.Parse(this.txtStatus.Text);

            WebDemo.Model.WebDemo.ManageUser model = new WebDemo.Model.WebDemo.ManageUser();
            model.UsersID      = UsersID;
            model.ManageFareID = ManageFareID;
            model.ChargeDate   = ChargeDate;
            model.LastDate     = LastDate;
            model.ReMark       = ReMark;
            model.Status       = Status;

            WebDemo.BLL.WebDemo.ManageUser bll = new WebDemo.BLL.WebDemo.ManageUser();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.ManageUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ManageUser set ");
            strSql.Append("ChargeDate=@ChargeDate,");
            strSql.Append("LastDate=@LastDate,");
            strSql.Append("ReMark=@ReMark,");
            strSql.Append("Status=@Status");
            strSql.Append(" where UsersID=@UsersID and ManageFareID=@ManageFareID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ChargeDate",   SqlDbType.DateTime),
                new SqlParameter("@LastDate",     SqlDbType.DateTime),
                new SqlParameter("@ReMark",       SqlDbType.VarChar, 200),
                new SqlParameter("@Status",       SqlDbType.Int,       4),
                new SqlParameter("@UsersID",      SqlDbType.Int,       4),
                new SqlParameter("@ManageFareID", SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.ChargeDate;
            parameters[1].Value = model.LastDate;
            parameters[2].Value = model.ReMark;
            parameters[3].Value = model.Status;
            parameters[4].Value = model.UsersID;
            parameters[5].Value = model.ManageFareID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }