Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.CollFindWork model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CollFindWork set ");
            strSql.Append("WorkTime=@WorkTime");
            strSql.Append(" where CollectorID=@CollectorID and WorkID=@WorkID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WorkTime",    SqlDbType.Int, 4),
                new SqlParameter("@CollectorID", SqlDbType.Int, 4),
                new SqlParameter("@WorkID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.WorkTime;
            parameters[1].Value = model.CollectorID;
            parameters[2].Value = model.WorkID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.CollFindWork model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CollFindWork(");
            strSql.Append("CollectorID,WorkID,WorkTime)");
            strSql.Append(" values (");
            strSql.Append("@CollectorID,@WorkID,@WorkTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CollectorID", SqlDbType.Int, 4),
                new SqlParameter("@WorkID",      SqlDbType.Int, 4),
                new SqlParameter("@WorkTime",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CollectorID;
            parameters[1].Value = model.WorkID;
            parameters[2].Value = model.WorkTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.CollFindWork GetModel(int CollectorID, int WorkID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CollectorID,WorkID,WorkTime from CollFindWork ");
            strSql.Append(" where CollectorID=@CollectorID and WorkID=@WorkID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CollectorID", SqlDbType.Int, 4),
                new SqlParameter("@WorkID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = CollectorID;
            parameters[1].Value = WorkID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtCollectorID.Text))
            {
                strErr += "CollectorID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtWorkID.Text))
            {
                strErr += "WorkID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtWorkTime.Text))
            {
                strErr += "WorkTime格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int CollectorID = int.Parse(this.txtCollectorID.Text);
            int WorkID      = int.Parse(this.txtWorkID.Text);
            int WorkTime    = int.Parse(this.txtWorkTime.Text);

            WebDemo.Model.WebDemo.CollFindWork model = new WebDemo.Model.WebDemo.CollFindWork();
            model.CollectorID = CollectorID;
            model.WorkID      = WorkID;
            model.WorkTime    = WorkTime;

            WebDemo.BLL.WebDemo.CollFindWork bll = new WebDemo.BLL.WebDemo.CollFindWork();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Пример #5
0
 private void ShowInfo(int CollectorID, int WorkID)
 {
     WebDemo.BLL.WebDemo.CollFindWork   bll   = new WebDemo.BLL.WebDemo.CollFindWork();
     WebDemo.Model.WebDemo.CollFindWork model = bll.GetModel(CollectorID, WorkID);
     this.lblCollectorID.Text = model.CollectorID.ToString();
     this.lblWorkID.Text      = model.WorkID.ToString();
     this.lblWorkTime.Text    = model.WorkTime.ToString();
 }
Пример #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.CollFindWork DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.CollFindWork model = new WebDemo.Model.WebDemo.CollFindWork();
     if (row != null)
     {
         if (row["CollectorID"] != null && row["CollectorID"].ToString() != "")
         {
             model.CollectorID = int.Parse(row["CollectorID"].ToString());
         }
         if (row["WorkID"] != null && row["WorkID"].ToString() != "")
         {
             model.WorkID = int.Parse(row["WorkID"].ToString());
         }
         if (row["WorkTime"] != null && row["WorkTime"].ToString() != "")
         {
             model.WorkTime = int.Parse(row["WorkTime"].ToString());
         }
     }
     return(model);
 }