public bool Add(M_Project m_project) { string strSql = "PR_Project_Add"; SqlParameter[] parameter = GetParameters(m_project); return(SqlHelper.ExecuteProc(strSql, parameter)); }
public string CountRate(int projectid) { int result = 0; int FinishCount = this.bllwork.CountFinishWork(projectid); if (FinishCount == 0) { return("0%"); } else { result = FinishCount * 100 / CountWork(projectid); this.mproject = this.bll.GetProjectByid(projectid); if (result == 100) { this.mproject.Status = 1; } else { this.mproject.Status = 0; } this.bll.Update(this.mproject); return(result + "%"); } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { M_Project mproject = new M_Project(); mproject.ProjectName = TxtProjectName.Text.Trim(); mproject.ProjectIntro = TxtProjectIntro.Text.Trim(); mproject.StartDate = DataConverter.CDate(tbUBday.Value.Trim()); if (!string.IsNullOrEmpty(txtEndDay.Value.Trim())) { mproject.EndDate = DataConverter.CDate(txtEndDay.Value.Trim()); } else { mproject.EndDate = DateTime.MaxValue;//new DateTime(); } mproject.Uid = this.m_uid; mproject.Status = 0; if (Request.QueryString["rid"] != null) { mproject.RequireID = DataConverter.CLng(Request.QueryString["rid"].Trim()); } else { mproject.RequireID = 0;//无需求ID也可以由管理员自己添加项目 } B_Project bproject = new B_Project(); if (bproject.Add(mproject)) { Response.Write("<script language=javascript> alert('项目添加成功!');window.document.location.href='ProjectManage.aspx';</script>"); } }
public M_Project GetProject(string id) { SqlParameter[] parms = { new SqlParameter("@Id", SqlDbType.VarChar, 100) }; parms[0].Value = SqlTypeConverter.DBNullStringChecker(id); M_Project entity = null; using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Sc.Sql_M_Project_Repository_GetProject, parms)) { if (rdr.Read()) { entity = new M_Project(); entity.Id = SqlTypeConverter.DBNullStringHandler(rdr["Id"]); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.StartTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["StartTime"]); entity.EndTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["EndTime"]); entity.Responsible = SqlTypeConverter.DBNullStringHandler(rdr["Responsible"]); entity.ContactPhone = SqlTypeConverter.DBNullStringHandler(rdr["ContactPhone"]); entity.Company = SqlTypeConverter.DBNullStringHandler(rdr["Company"]); entity.Creator = SqlTypeConverter.DBNullStringHandler(rdr["Creator"]); entity.CreatedTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["CreatedTime"]); entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]); entity.Enabled = SqlTypeConverter.DBNullBooleanHandler(rdr["Enabled"]); } } return(entity); }
public List <M_Project> GetProjectsInSpan(DateTime start, DateTime end) { SqlParameter[] parms = { new SqlParameter("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime) }; parms[0].Value = SqlTypeConverter.DBNullDateTimeChecker(start); parms[1].Value = SqlTypeConverter.DBNullDateTimeChecker(end); var entities = new List <M_Project>(); using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Sc.Sql_M_Project_Repository_GetProjectsInSpan, parms)) { while (rdr.Read()) { var entity = new M_Project(); entity.Id = SqlTypeConverter.DBNullStringHandler(rdr["Id"]); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.StartTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["StartTime"]); entity.EndTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["EndTime"]); entity.Responsible = SqlTypeConverter.DBNullStringHandler(rdr["Responsible"]); entity.ContactPhone = SqlTypeConverter.DBNullStringHandler(rdr["ContactPhone"]); entity.Company = SqlTypeConverter.DBNullStringHandler(rdr["Company"]); entity.Creator = SqlTypeConverter.DBNullStringHandler(rdr["Creator"]); entity.CreatedTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["CreatedTime"]); entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]); entity.Enabled = SqlTypeConverter.DBNullBooleanHandler(rdr["Enabled"]); entities.Add(entity); } } return(entities); }
public void Update(M_Project project) { if (project == null) { throw new ArgumentNullException("project"); } _repository.Update(project); }
public void Add(M_Project project) { if (project == null) { throw new ArgumentNullException("project"); } _repository.Insert(project); }
public void InItModify(int pid) { LblTitle.Text = "修改项目"; B_Project bproject = new B_Project(); M_Project mproject = bproject.GetProjectByid(pid); TxtProjectName.Text = mproject.ProjectName; TxtProjectIntro.Text = mproject.ProjectIntro; tbUBday.Value = mproject.StartDate.ToShortDateString(); txtEndDay.Value = mproject.EndDate.ToShortDateString(); }
private M_Project GetProjectInfoFromReader(SqlDataReader reader) { M_Project info = new M_Project(); info.ProjectID = DataConverter.CLng(reader["ProjectID"].ToString()); info.ProjectName = reader["ProjectName"].ToString(); info.ProjectIntro = reader["ProjectIntro"].ToString(); info.RequireID = DataConverter.CLng(reader["RequireID"].ToString()); info.Uid = DataConverter.CLng(reader["UserID"].ToString()); info.StartDate = DataConverter.CDate(reader["StartDate"]); info.EndDate = DataConverter.CDate(reader["EndDate"]); info.Status = DataConverter.CLng(reader["Status"]); return(info); }
public void MyBind() { B_ProjectWork bprojectwork = new B_ProjectWork(); if (Request.QueryString["Pid"] != null) { int Pid = DataConverter.CLng(Request.QueryString["Pid"].Trim());//2; mproject = bproject.GetProjectByid(Pid); DataView dv = bprojectwork.SelectWorkByPID(Pid); this.m_projectname = mproject.ProjectName; this.Egv.DataSource = dv; this.Egv.DataKeyNames = new string[] { "WorkID" }; this.Egv.DataBind(); } else { DataTable dt = bprojectwork.GetProjectWorkAll(); this.Egv.DataSource = dt; this.Egv.DataBind(); } }
protected void EBtnModify_Click(object sender, EventArgs e) { B_Project bproject = new B_Project(); M_Project mproject = bproject.GetProjectByid(Convert.ToInt32(Request.QueryString["Pid"].Trim())); mproject.ProjectName = TxtProjectName.Text; mproject.ProjectIntro = TxtProjectIntro.Text; mproject.StartDate = DataConverter.CDate(tbUBday.Value.Trim()); if (!string.IsNullOrEmpty(txtEndDay.Value.Trim())) { mproject.EndDate = DataConverter.CDate(txtEndDay.Value.Trim()); } else { mproject.EndDate = DateTime.MaxValue;//new DateTime(); } if (bproject.Update(mproject)) { Response.Write("<script language=javascript> alert('项目修改成功!');window.document.location.href='ProjectManage.aspx';</script>"); } }
public void InitPage() { B_Project bpro = new B_Project(); B_ProjectWork bwork = new B_ProjectWork(); M_Project mpro = new M_Project(); StringBuilder strbul = new StringBuilder(); int rid = 0; if (Request.QueryString["pid"] != null) { rid = DataConverter.CLng(Request.QueryString["pid"].Trim()); mpro = bpro.GetProjectByid(rid); LblProName.Text = mpro.ProjectName; LblProIntro.Text = mpro.ProjectIntro; LblStartDate.Text = mpro.StartDate.ToShortDateString(); if (mpro.EndDate.ToShortDateString() == DateTime.MaxValue.ToShortDateString()) { LblEndDate.Text = ""; } else { LblEndDate.Text = mpro.EndDate.ToShortDateString(); } DataView dv = bwork.SelectWorkByPID(rid); if (dv.Table.Rows.Count > 0) { foreach (DataRow dr in dv.Table.Rows) { strbul.Append("<a href='DiscussList.aspx?wid=" + dr["WorkID"] + "&pid=" + Request.QueryString["pid"] + "'>" + dr["WorkName"] + "</a> <a href='DiscussList.aspx?wid=" + dr["WorkID"] + "&pid=" + Request.QueryString["pid"] + "'>查看讨论</a><br/>"); } } else { strbul.Append("暂无工作内容!"); } LblContent.Text = strbul.ToString(); } }
public void Insert(M_Project entity) { SqlParameter[] parms = { new SqlParameter("@Id", SqlDbType.VarChar, 100), new SqlParameter("@Name", SqlDbType.VarChar, 200), new SqlParameter("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime), new SqlParameter("@Responsible", SqlDbType.VarChar, 100), new SqlParameter("@ContactPhone", SqlDbType.VarChar, 100), new SqlParameter("@Company", SqlDbType.VarChar, 100), new SqlParameter("@Creator", SqlDbType.VarChar, 100), new SqlParameter("@CreatedTime", SqlDbType.DateTime), new SqlParameter("@Comment", SqlDbType.VarChar, 512), new SqlParameter("@Enabled", SqlDbType.Bit) }; using (var conn = new SqlConnection(this._databaseConnectionString)) { if (conn.State != ConnectionState.Open) { conn.Open(); } var trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { parms[0].Value = SqlTypeConverter.DBNullStringChecker(entity.Id); parms[1].Value = SqlTypeConverter.DBNullStringChecker(entity.Name); parms[2].Value = SqlTypeConverter.DBNullDateTimeChecker(entity.StartTime); parms[3].Value = SqlTypeConverter.DBNullDateTimeChecker(entity.EndTime); parms[4].Value = SqlTypeConverter.DBNullStringChecker(entity.Responsible); parms[5].Value = SqlTypeConverter.DBNullStringChecker(entity.ContactPhone); parms[6].Value = SqlTypeConverter.DBNullStringChecker(entity.Company); parms[7].Value = SqlTypeConverter.DBNullStringChecker(entity.Creator); parms[8].Value = SqlTypeConverter.DBNullDateTimeChecker(entity.CreatedTime); parms[9].Value = SqlTypeConverter.DBNullStringChecker(entity.Comment); parms[10].Value = entity.Enabled; SqlHelper.ExecuteNonQuery(trans, CommandType.Text, SqlCommands_Sc.Sql_M_Project_Repository_Insert, parms); trans.Commit(); } catch { trans.Rollback(); throw; } } }
private SqlParameter[] GetParameters(M_Project m_project) { SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@ProjectID", SqlDbType.Int), new SqlParameter("@ProjectName", SqlDbType.NVarChar, 255), new SqlParameter("@ProjectIntro", SqlDbType.NText, 16), new SqlParameter("@RequireID", SqlDbType.Int, 4), new SqlParameter("@StartDate", SqlDbType.DateTime, 8), new SqlParameter("@EndDate", SqlDbType.DateTime, 8), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.Int, 4) }; parameter[0].Value = m_project.ProjectID; parameter[1].Value = m_project.ProjectName; parameter[2].Value = m_project.ProjectIntro; parameter[3].Value = m_project.RequireID; parameter[4].Value = m_project.StartDate; parameter[5].Value = m_project.EndDate; parameter[6].Value = m_project.Status; parameter[7].Value = m_project.Uid; return(parameter); }
public List <M_Project> GetValidProjects() { var entities = new List <M_Project>(); using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Sc.Sql_M_Project_Repository_GetValidProjects, null)) { while (rdr.Read()) { var entity = new M_Project(); entity.Id = SqlTypeConverter.DBNullStringHandler(rdr["Id"]); entity.Name = SqlTypeConverter.DBNullStringHandler(rdr["Name"]); entity.StartTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["StartTime"]); entity.EndTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["EndTime"]); entity.Responsible = SqlTypeConverter.DBNullStringHandler(rdr["Responsible"]); entity.ContactPhone = SqlTypeConverter.DBNullStringHandler(rdr["ContactPhone"]); entity.Company = SqlTypeConverter.DBNullStringHandler(rdr["Company"]); entity.Creator = SqlTypeConverter.DBNullStringHandler(rdr["Creator"]); entity.CreatedTime = SqlTypeConverter.DBNullDateTimeHandler(rdr["CreatedTime"]); entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]); entity.Enabled = SqlTypeConverter.DBNullBooleanHandler(rdr["Enabled"]); entities.Add(entity); } } return(entities); }
public bool Update(M_Project m_Project) { return(dal.Update(m_Project)); }
public bool Add(M_Project projectInfo) { return(dal.Add(projectInfo)); }
public JsonResult SaveProject(ProjectModel project, int action) { try { if (project == null) { throw new ArgumentException("project"); } if (action == (int)EnmAction.Add) { var newOne = new M_Project { Id = project.id, Name = project.name, StartTime = Convert.ToDateTime(project.start), EndTime = Convert.ToDateTime(project.end).AddDays(1).AddSeconds(-1), Responsible = project.responsible, ContactPhone = project.contact, Company = project.company, Creator = _workContext.Employee() != null?_workContext.Employee().Name : _workContext.User().Uid, CreatedTime = DateTime.Now, Comment = project.comment, Enabled = project.enabled }; _projectService.Add(newOne); _webLogger.Information(EnmEventType.Other, string.Format("新增工程[{0}]", project.name), _workContext.User().Id, null); return(Json(new AjaxResultModel { success = true, code = 200, message = "保存成功" })); } else if (action == (int)EnmAction.Edit) { var existed = _projectService.GetProject(project.id); if (existed == null) { throw new iPemException("工程不存在,保存失败。"); } if (existed.Creator != (_workContext.Employee() != null ? _workContext.Employee().Name : _workContext.User().Uid)) { throw new iPemException("您没有操作权限。"); } //existed.Id = projectId; existed.Name = project.name; existed.StartTime = Convert.ToDateTime(project.start); existed.EndTime = Convert.ToDateTime(project.end).AddDays(1).AddSeconds(-1); existed.Responsible = project.responsible; existed.ContactPhone = project.contact; existed.Company = project.company; existed.Comment = project.comment; existed.Enabled = project.enabled; _projectService.Update(existed); _webLogger.Information(EnmEventType.Other, string.Format("更新工程[{0}]", existed.Name), _workContext.User().Id, null); return(Json(new AjaxResultModel { success = true, code = 200, message = "保存成功" })); } throw new ArgumentException("action"); } catch (Exception exc) { _webLogger.Error(EnmEventType.Other, exc.Message, _workContext.User().Id, exc); return(Json(new AjaxResultModel { success = false, code = 400, message = exc.Message })); } }
public bool Update(M_Project m_project) { SqlParameter[] cmdParams = GetParameters(m_project);; return(SqlHelper.ExecuteProc("PR_Project_Update", cmdParams)); }