示例#1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }
            if (this.txtprojectName.Text.Trim().Length == 0)
            {
                strErr += "projectName不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txttime.Text))
            {
                strErr += "time格式错误!\\n";
            }
            if (this.txttodayWork.Value.Trim().Length == 0)
            {
                strErr += "todayWork不能为空!\\n";
            }
            if (this.txtproblem.Value.Trim().Length == 0)
            {
                strErr += "problem不能为空!\\n";
            }
            if (this.txttomorrowWork.Value.Trim().Length == 0)
            {
                strErr += "tomorrowWork不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID           = int.Parse(this.lblID.Text);
            string   name         = this.txtname.Text;
            string   projectName  = this.txtprojectName.Text;
            DateTime time         = DateTime.Parse(this.txttime.Text);
            string   todayWork    = this.txttodayWork.Value;
            string   problem      = this.txtproblem.Value;
            string   tomorrowWork = this.txttomorrowWork.Value;


            Maticsoft.Model.Report model = new Maticsoft.Model.Report();
            model.ID           = ID;
            model.name         = name;
            model.projectName  = projectName;
            model.time         = time;
            model.todayWork    = todayWork;
            model.problem      = problem;
            model.tomorrowWork = tomorrowWork;

            Maticsoft.BLL.Report bll = new Maticsoft.BLL.Report();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
示例#2
0
 private void ShowInfo(int ID)
 {
     Maticsoft.BLL.Report   bll   = new Maticsoft.BLL.Report();
     Maticsoft.Model.Report model = bll.GetModel(ID);
     this.lblID.Text           = model.ID.ToString();
     this.lblname.Text         = model.name;
     this.lblprojectName.Text  = model.projectName;
     this.lbltime.Text         = model.time.ToString();
     this.lbltodayWork.Text    = model.todayWork;
     this.lblproblem.Text      = model.problem;
     this.lbltomorrowWork.Text = model.tomorrowWork;
 }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }
            if (this.txtprojectName.Text.Trim().Length == 0)
            {
                strErr += "projectName不能为空!\\n";
            }

            if (this.txttodayWork.Value.Trim().Length == 0)
            {
                strErr += "todayWork不能为空!\\n";
            }
            if (this.txtproblem.Value.Trim().Length == 0)
            {
                strErr += "problem不能为空!\\n";
            }
            if (this.txttomorrowWork.Value.Trim().Length == 0)
            {
                strErr += "tomorrowWork不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   name         = this.txtname.Text;
            string   projectName  = this.txtprojectName.Text;
            DateTime time         = DateTime.Parse(DateTime.Now.ToString());
            string   todayWork    = this.txttodayWork.Value;
            string   problem      = this.txtproblem.Value;
            string   tomorrowWork = this.txttomorrowWork.Value;

            Maticsoft.Model.Report model = new Maticsoft.Model.Report();
            model.name         = name;
            model.projectName  = projectName;
            model.time         = time;
            model.todayWork    = todayWork;
            model.problem      = problem;
            model.tomorrowWork = tomorrowWork;

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

            strSql.Append("update Report set ");
            strSql.Append("name=@name,");
            strSql.Append("projectName=@projectName,");
            strSql.Append("time=@time,");
            strSql.Append("todayWork=@todayWork,");
            strSql.Append("problem=@problem,");
            strSql.Append("tomorrowWork=@tomorrowWork");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",         SqlDbType.NVarChar,  10),
                new SqlParameter("@projectName",  SqlDbType.NVarChar,  50),
                new SqlParameter("@time",         SqlDbType.Date,       3),
                new SqlParameter("@todayWork",    SqlDbType.NVarChar, 300),
                new SqlParameter("@problem",      SqlDbType.NVarChar, 300),
                new SqlParameter("@tomorrowWork", SqlDbType.NVarChar, 300),
                new SqlParameter("@ID",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.projectName;
            parameters[2].Value = model.time;
            parameters[3].Value = model.todayWork;
            parameters[4].Value = model.problem;
            parameters[5].Value = model.tomorrowWork;
            parameters[6].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Report model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Report(");
            strSql.Append("name,projectName,time,todayWork,problem,tomorrowWork)");
            strSql.Append(" values (");
            strSql.Append("@name,@projectName,@time,@todayWork,@problem,@tomorrowWork)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",         SqlDbType.NVarChar,  10),
                new SqlParameter("@projectName",  SqlDbType.NVarChar,  50),
                new SqlParameter("@time",         SqlDbType.Date,       3),
                new SqlParameter("@todayWork",    SqlDbType.NVarChar, 300),
                new SqlParameter("@problem",      SqlDbType.NVarChar, 300),
                new SqlParameter("@tomorrowWork", SqlDbType.NVarChar, 300)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.projectName;
            parameters[2].Value = model.time;
            parameters[3].Value = model.todayWork;
            parameters[4].Value = model.problem;
            parameters[5].Value = model.tomorrowWork;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Report DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Report model = new Maticsoft.Model.Report();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["projectName"] != null)
         {
             model.projectName = row["projectName"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
         if (row["todayWork"] != null)
         {
             model.todayWork = row["todayWork"].ToString();
         }
         if (row["problem"] != null)
         {
             model.problem = row["problem"].ToString();
         }
         if (row["tomorrowWork"] != null)
         {
             model.tomorrowWork = row["tomorrowWork"].ToString();
         }
     }
     return(model);
 }
示例#7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Report GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,name,projectName,time,todayWork,problem,tomorrowWork from Report ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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