/// <summary> /// 更新一条数据 /// </summary> public void Update(JumbotOA.Entity.WorklogEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [OA_Worklog] set "); strSql.Append("Uid=" + model.Uid + ","); strSql.Append("Manager='" + model.Manager + "',"); strSql.Append("Title='" + model.Title + "',"); strSql.Append("Content='" + model.Content + "',"); strSql.Append("Begintime='" + model.Begintime + "',"); strSql.Append("Endtime='" + model.Endtime + "',"); strSql.Append("Problem='" + model.Problem + "',"); strSql.Append("Remark='" + model.Remark + "'"); strSql.Append(" where Id=" + model.Id + " "); DbHelperSQL.ExecuteSql(strSql.ToString()); }
/// <summary> /// 得到一个对象实体 /// </summary> public JumbotOA.Entity.WorklogEntity GetEntity(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" * "); strSql.Append(" from [OA_Worklog] "); strSql.Append(" where Id=" + Id + " "); JumbotOA.Entity.WorklogEntity model = new JumbotOA.Entity.WorklogEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["Uid"].ToString() != "") { model.Uid = int.Parse(ds.Tables[0].Rows[0]["Uid"].ToString()); } if (ds.Tables[0].Rows[0]["Manager"].ToString() != "") { model.Manager = ds.Tables[0].Rows[0]["Manager"].ToString(); } model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); model.Content = ds.Tables[0].Rows[0]["Content"].ToString(); if (ds.Tables[0].Rows[0]["Begintime"].ToString() != "") { model.Begintime = DateTime.Parse(ds.Tables[0].Rows[0]["Begintime"].ToString()); } if (ds.Tables[0].Rows[0]["Endtime"].ToString() != "") { model.Endtime = DateTime.Parse(ds.Tables[0].Rows[0]["Endtime"].ToString()); } model.Problem = ds.Tables[0].Rows[0]["Problem"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JumbotOA.Entity.WorklogEntity GetEntity(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" * "); strSql.Append(" from [OA_Worklog] "); strSql.Append(" where Id=" + Id + " "); JumbotOA.Entity.WorklogEntity model = new JumbotOA.Entity.WorklogEntity(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["Uid"].ToString() != "") { model.Uid = int.Parse(ds.Tables[0].Rows[0]["Uid"].ToString()); } if (ds.Tables[0].Rows[0]["Manager"].ToString() != "") { model.Manager = ds.Tables[0].Rows[0]["Manager"].ToString(); } model.Title = ds.Tables[0].Rows[0]["Title"].ToString(); model.Content = ds.Tables[0].Rows[0]["Content"].ToString(); if (ds.Tables[0].Rows[0]["Begintime"].ToString() != "") { model.Begintime = DateTime.Parse(ds.Tables[0].Rows[0]["Begintime"].ToString()); } if (ds.Tables[0].Rows[0]["Endtime"].ToString() != "") { model.Endtime = DateTime.Parse(ds.Tables[0].Rows[0]["Endtime"].ToString()); } model.Problem = ds.Tables[0].Rows[0]["Problem"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return model; } else { return null; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JumbotOA.Entity.WorklogEntity model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); strSql1.Append("Uid,"); strSql2.Append("" + model.Uid + ","); if (model.Manager != null) { strSql1.Append("Manager,"); strSql2.Append("'" + model.Manager + "',"); } if (model.Title != null) { strSql1.Append("Title,"); strSql2.Append("'" + model.Title + "',"); } if (model.Content != null) { strSql1.Append("Content,"); strSql2.Append("'" + model.Content + "',"); } if (model.Begintime != null) { strSql1.Append("Begintime,"); strSql2.Append("'" + model.Begintime + "',"); } if (model.Endtime != null) { strSql1.Append("Endtime,"); strSql2.Append("'" + model.Endtime + "',"); } if (model.Problem != null) { strSql1.Append("Problem,"); strSql2.Append("'" + model.Problem + "',"); } if (model.Remark != null) { strSql1.Append("Remark,"); strSql2.Append("'" + model.Remark + "',"); } strSql.Append("insert into [OA_Worklog]("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql.Append(";select @@IDENTITY"); object obj = DbHelperSQL.GetSingle(strSql.ToString()); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }