示例#1
0
 public JsonResult Delete(int projectID, DateTime reportDate)
 {
     try
     {
         ProjectsStatusModel model = projectsStatusBll.GetModel(projectID, reportDate);
         if (model != null)
         {
             projectsStatusBll.Delete(projectID, reportDate);
         }
         else
         {
             return(Json(new { code = 500, msg = "parms is null" }));
         }
         return(Json(new { code = 200 }));
     }
     catch (Exception ex)
     {
         return(Json(new { code = 500, msg = ex.Message }));
     }
 }
示例#2
0
        public JsonResult Update(ProjectsStatusViewModel model)
        {
            try
            {
                ProjectsStatusModel projectsStatusModel = projectsStatusBll.GetModel(model.ProjectID, model.ReportDate);
                projectsStatusModel.ProjectID      = model.ProjectID;
                projectsStatusModel.ReportDate     = model.ReportDate;
                projectsStatusModel.Phase          = model.Phase;
                projectsStatusModel.DueDate        = model.DueDate;
                projectsStatusModel.DonePercent    = model.DonePercent;
                projectsStatusModel.SpendHour      = model.SpendHour;
                projectsStatusModel.SpendingRemark = model.SpendingRemark;

                projectsStatusBll.Update(projectsStatusModel);
                return(Json(new { code = 200 }));
            }
            catch (Exception ex)
            {
                return(Json(new { code = 500, msg = ex.Message }));
            }
        }
        public ProjectsStatusModel DataRowToModel(DataRow row)
        {
            ProjectsStatusModel model = new ProjectsStatusModel();

            if (row == null)
            {
                return(model);
            }

            if (row["ProjectID"] != null && row["ProjectID"].ToString() != "")
            {
                model.ProjectID = int.Parse(row["ProjectID"].ToString());
            }
            if (row["ReportDate"] != null && row["ReportDate"].ToString() != "")
            {
                model.ReportDate = DateTime.Parse(row["ReportDate"].ToString());
            }
            if (row["Phase"] != null && row["Phase"].ToString() != "")
            {
                model.Phase = row["Phase"].ToString();
            }
            if (row["DueDate"] != null && row["DueDate"].ToString() != "")
            {
                model.DueDate = DateTime.Parse(row["DueDate"].ToString());
            }
            if (row["DonePercent"] != null && row["DonePercent"].ToString() != "")
            {
                model.DonePercent = int.Parse(row["DonePercent"].ToString());
            }
            if (row["SpendHour"] != null && row["SpendHour"].ToString() != "")
            {
                model.SpendHour = int.Parse(row["SpendHour"].ToString());
            }
            if (row["SpendingRemark"] != null && row["SpendingRemark"].ToString() != "")
            {
                model.SpendingRemark = row["SpendingRemark"].ToString();
            }

            return(model);
        }
        public int Update(ProjectsStatusModel model)
        {
            string sql = "UPDATE [ProjectsStatus] SET [ProjectID]=@ProjectID,[ReportDate]=@ReportDate,[Phase]=@Phase,[DueDate]=@DueDate,[DonePercent]=@DonePercent,[SpendHour]=@SpendHour,[SpendingRemark]=@SpendingRemark WHERE ProjectID=@ProjectID and ReportDate=@ReportDate";

            SqlParameter[] parameters =
            {
                new SqlParameter("@ProjectID",      SqlDbType.Int),
                new SqlParameter("@ReportDate",     SqlDbType.DateTime),
                new SqlParameter("@Phase",          SqlDbType.NVarChar),
                new SqlParameter("@DueDate",        SqlDbType.DateTime),
                new SqlParameter("@DonePercent",    SqlDbType.Int),
                new SqlParameter("@SpendHour",      SqlDbType.Int),
                new SqlParameter("@SpendingRemark", SqlDbType.NVarChar),
            };
            parameters[0].Value = model.ProjectID;
            parameters[1].Value = model.ReportDate;
            parameters[2].Value = model.Phase == null ? (object)DBNull.Value : model.Phase;
            parameters[3].Value = model.DueDate == null ? (object)DBNull.Value : model.DueDate;
            parameters[4].Value = model.DonePercent == null ? (object)DBNull.Value : model.DonePercent;
            parameters[5].Value = model.SpendHour == null ? (object)DBNull.Value : model.SpendHour;
            parameters[6].Value = model.SpendingRemark == null ? (object)DBNull.Value : model.SpendingRemark;

            return(DbHelperSQL.ExecuteSql(sql, parameters));
        }
        public int Insert(ProjectsStatusModel model)
        {
            string sql = "INSERT INTO [ProjectsStatus]([ProjectID],[ReportDate],[Phase],[DueDate],[DonePercent],[SpendHour],[SpendingRemark]) VALUES(@ProjectID,@ReportDate,@Phase,@DueDate,@DonePercent,@SpendHour,@SpendingRemark)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@ProjectID",      SqlDbType.Int),
                new SqlParameter("@ReportDate",     SqlDbType.DateTime),
                new SqlParameter("@Phase",          SqlDbType.NVarChar),
                new SqlParameter("@DueDate",        SqlDbType.DateTime),
                new SqlParameter("@DonePercent",    SqlDbType.Int),
                new SqlParameter("@SpendHour",      SqlDbType.Int),
                new SqlParameter("@SpendingRemark", SqlDbType.NVarChar),
            };
            parameters[0].Value = model.ProjectID;
            parameters[1].Value = model.ReportDate;
            parameters[2].Value = model.Phase == null ? (object)DBNull.Value : model.Phase;
            parameters[3].Value = model.DueDate == null ? (object)DBNull.Value : model.DueDate;
            parameters[4].Value = model.DonePercent == null ? (object)DBNull.Value : model.DonePercent;
            parameters[5].Value = model.SpendHour == null ? (object)DBNull.Value : model.SpendHour;
            parameters[6].Value = model.SpendingRemark == null ? (object)DBNull.Value : model.SpendingRemark;

            return(DbHelperSQL.ExecuteSql(sql, parameters));
        }
示例#6
0
 public int Update(ProjectsStatusModel model)
 {
     return(dal.Update(model));
 }
示例#7
0
 public int Insert(ProjectsStatusModel model)
 {
     return(dal.Insert(model));
 }