예제 #1
0
 public ResponseStatus GetDetail(int id,Work work)
 {
     //dalBase.sql = "SELECT db_work.id,userid,stuNum,stuName,content,cutOffDate,statuss,improveContent,improveCutOffDate,activityid " +
     //    "from db_work,db_users WHERE db_work.userid=db_users.id and db_work.id=1";
     dalBase.sql = "SELECT db_work.id,userid,stuNum,stuName,content,startDate,cutOffDate,statuss,activityid " +
         "from db_work,db_users WHERE db_work.userid=db_users.id and db_work.id=@id";
     dalBase.Param = new MySqlParameter("@id", id);
     bool isSuccess = dalBase.Run(Behavious.SELECT_WITH_SINGLEPARAM, false);
     return this.JudgeDBResult(isSuccess,
         () =>
         {
             dalBase.DataRead.Read();
             work.ID = Convert.ToInt32(dalBase.DataRead["id"]);
             work.UserAutoID = Convert.ToInt32(dalBase.DataRead["userid"]);
             work.UserID = dalBase.DataRead["stuNum"].ToString();
             work.UserName = dalBase.DataRead["stuName"].ToString();
             work.Content = dalBase.DataRead["content"].ToString();
             work.StartDate = Convert.ToDateTime(dalBase.DataRead["startDate"]);
             work.CutOffDate = Convert.ToDateTime(dalBase.DataRead["cutOffDate"]);
             work.Status = (WorkStatus)Convert.ToByte(dalBase.DataRead["statuss"]);
             //work.ImproveContent = dalBase.Dread["improveContent"].ToString();
             //work.ImproveCutOffDate = dalBase.Dread["improveCutOffDate"] == null ?
             //                Convert.ToDateTime(dalBase.Dread["improveCutOffDate"]) : GLB.initTime;
         },
         () =>
         {
             work = null;
         });
 }
예제 #2
0
        public ResponseStatus AddWork(HttpRequestBase req)
        {
            ResponseStatus resp = ResponseStatus.NONE;
            string userId = req.Form["userId"].ToString();
            UserDAL userDal = new UserDAL();
            int id = userDal.GetUserAutoId(userId);
            userDal.ReturnUnitToPool();

            if (id != 0)
            {
                workDal = new WorkDAL();
                Work work = new Work()
                {
                    ID = Convert.ToInt32(req.Form["id"]),
                    UserAutoID = id,
                    Content = req.Form["content"].ToString(),
                    StartDate = Convert.ToDateTime(req.Form["startdate"]),
                    CutOffDate = Convert.ToDateTime(req.Form["cutoffdate"]),
                    Status = (WorkStatus)Convert.ToByte(req.Form["status"]),
                    //ImproveContent = req.Form["improveContent"].ToString(),
                    //ImproveCutOffDate = string.IsNullOrEmpty(req.Form["improveCutOffDate"]) ? GLB.initTime :
                    //    Convert.ToDateTime(req.Form["improveCutOffDate"]),
                    activityId = Convert.ToInt32(req.Form["activityId"])
                };
                if (workDal.Add(work))
                {
                    resp = ResponseStatus.SUCCESS;
                }
                else
                {
                    resp = ResponseStatus.FAILED;
                }
                workDal.ReturnUnitToPool();
            }
            else
            {
                resp = ResponseStatus.FAILED;
            }

            return resp;
        }
예제 #3
0
 public bool Add(Work w)
 {
     StringBuilder sbuilder = new StringBuilder();
     //sbuilder.Append("INSERT INTO db_work(userid,content,startDate,cutOffDate,statuss,improveContent,improveDate,improveCutOffDate,activityid) VALUES ");
     //sbuilder.Append("(@userid,@content,@startDate,@cutOffDate,@statuss,@improveContent,@improveDate,@improveCutOffDate,@activityid)"); //@userid,
     sbuilder.Append("INSERT INTO db_work(userid,content,startDate,cutOffDate,statuss,activityid) VALUES ");
     sbuilder.Append("(@userid,@content,@startDate,@cutOffDate,@statuss,@activityid)"); //@userid,
     dalBase.sql = sbuilder.ToString();
     dalBase.List_param = new List<MySqlParameter>()
     {
         new MySqlParameter("@userId",w.UserAutoID),
         new MySqlParameter("@content", w.Content),
         //new MySqlParameter("@startDate", w.StartDate),
         new MySqlParameter("@cutOffDate", w.CutOffDate),
         new MySqlParameter("@statuss", w.Status),
         //new MySqlParameter("@improveContent", w.ImproveContent),
         //new MySqlParameter("@improveCutOffDate", w.ImproveCutOffDate),
         new MySqlParameter("@activityid", w.activityId)
     };
     if (!string.IsNullOrEmpty(w.Content)) dalBase.List_param.Add(new MySqlParameter("@startDate", DateTime.Now.Date));
     //if (!string.IsNullOrEmpty(w.ImproveContent)) dalBase.List_param.Add(new MySqlParameter("@improveDate", DateTime.Now.Date));
     return dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE, true);
 }
예제 #4
0
 private bool CreateInstance(HttpRequestBase req,ref Work work)
 {
     bool flag = true;
     try
     {
         work = new Work()
         {
             ID = Convert.ToInt32(req.Form["id"]),
             UserID = req.Form["userId"].ToString(),
             UserName = req.Form["userName"].ToString(),
             Content = req.Form["content"].ToString(),
             StartDate = Convert.ToDateTime(req.Form["startdate"]),
             CutOffDate = Convert.ToDateTime(req.Form["cutoffdate"]),
             Status = (WorkStatus)Convert.ToByte(req.Form["status"])
             //ImproveContent = req.Form["improveContent"].ToString(),
             //ImproveCutOffDate = string.IsNullOrEmpty(req.Form["improveCutOffDate"])? GLB.initTime:
             //    Convert.ToDateTime(req.Form["improveCutOffDate"])
         };
     }
     catch (System.Exception ex)
     {
         flag = false;
         work = null;
     }
     return flag;
 }
예제 #5
0
 public bool Update(Work w)
 {
     StringBuilder sbuilder = new StringBuilder();
     //sbuilder.Append("UPDATE db_work SET content=@content,cutOffDate=@cutOffDate,"); //userid=@userid,
     //sbuilder.Append("statuss=@statuss,improveContent=@improveContent,improveCutOffDate=@improveCutOffDate ");
     sbuilder.Append("UPDATE db_work SET content=@content,startDate=@startDate,cutOffDate=@cutOffDate,statuss=@statuss "); //userid=@userid,
     sbuilder.Append("WHERE id=@id");
     dalBase.sql = sbuilder.ToString();
     dalBase.List_param = new List<MySqlParameter>()
     {
         new MySqlParameter("@id",w.ID),
         //new MySqlParameter("@userId",w.UserID),
         new MySqlParameter("@content", w.Content),
         new MySqlParameter("@startDate", w.StartDate),
         new MySqlParameter("@cutOffDate", w.CutOffDate),
         new MySqlParameter("@statuss", w.Status)
         //new MySqlParameter("@improveContent", w.ImproveContent),
         //new MySqlParameter("@improveCutOffDate", w.ImproveCutOffDate)
     };
     return dalBase.Run(Behavious.INSERT_OR_UPDATE_OR_DELETE, true);
 }