public static bool Insert(EvaluationHistory eh, ref string e) { string sql = "insert into tb_EvaluationHistory values(@ehStatus,@ehStartDate,@ehEndDate)"; SqlParameter[] parameters = { new SqlParameter("@ehStatus", SqlDbType.Bit), new SqlParameter("@ehStartDate", SqlDbType.DateTime), new SqlParameter("@ehEndDate", SqlDbType.DateTime) }; parameters[0].Value = eh.EhStatus; parameters[1].Value = eh.EhStartDate; parameters[2].Value = eh.EhEndDate; string exception = db.InsertExec(sql, parameters); if (exception != "" && exception != null) { e = exception; return false; } return true; }
public static bool Select(ref List<EvaluationHistory> ehs, ref string e, string sql) { DataTable table = new DataTable(); table = db.QueryDataTable(sql, ref e); if (table != null && table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { EvaluationHistory eh = new EvaluationHistory(); eh.EhID = (Int32)table.Rows[i]["ehID"]; eh.EhStatus=(bool)table.Rows[i]["ehStatus"]; eh.EhStartDate = (DateTime)table.Rows[i]["ehStartDate"]; eh.EhEndDate = (DateTime)table.Rows[i]["ehEndDate"]; ehs.Add(eh); } return true; } else { if (e != "" && e != null) return false; e = "查询不存在"; return false; } }
//开始新考评 //成功返回true,失败返回false; public static bool StartNewEvaluation() { EvaluationHistory eh = new EvaluationHistory(); eh.EhStatus = true; eh.EhStartDate = DateTime.Now.Date; //获取当前日期 eh.EhEndDate = DateTime.Now.Date; //获取当前日期 string e=""; return Insert(eh,ref e); }