/// <summary> /// 得到一个对象实体 /// </summary> public DataTable GetTableModel(int ID) { SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; var model = new Sys.Model.Expression(); var ds = DbHelperSQL.RunProcedure("Expression_GetModel", parameters, "ds"); return(ds.Tables[0]); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Sys.Model.Expression model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@SId", SqlDbType.Int, 4), new SqlParameter("@StuId", SqlDbType.Int, 4), new SqlParameter("@GId", SqlDbType.Int, 4), new SqlParameter("@CId", SqlDbType.NChar, 10), new SqlParameter("@Content", SqlDbType.NVarChar, 1000), new SqlParameter("@F_UserId", SqlDbType.NChar, 10), new SqlParameter("@F_RealName", SqlDbType.NVarChar, 50), new SqlParameter("@CreateIp", SqlDbType.VarChar, 50), new SqlParameter("@SendName", SqlDbType.Int, 4), new SqlParameter("@SendStates", SqlDbType.Int, 4), new SqlParameter("@SendSuccess", SqlDbType.Int, 4), new SqlParameter("@TypeID", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.CreateTime; parameters[2].Value = model.SId; parameters[3].Value = model.StuId; parameters[4].Value = model.GId; parameters[5].Value = model.CId; parameters[6].Value = model.Content; parameters[7].Value = model.F_UserId; parameters[8].Value = model.F_RealName; parameters[9].Value = model.CreateIp; parameters[10].Value = model.SendName; parameters[11].Value = model.SendStates; parameters[12].Value = model.SendSuccess; parameters[13].Value = model.TypeID; DbHelperSQL.RunProcedure("Expression_Update", parameters, out rowsAffected); return(rowsAffected > 0); }
/// <summary> /// 得到一个对象实体 /// </summary> public Sys.Model.Expression GetModel(int ID) { SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; var model = new Sys.Model.Expression(); var ds = DbHelperSQL.RunProcedure("Expression_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } if (ds.Tables[0].Rows[0]["SId"] != null && ds.Tables[0].Rows[0]["SId"].ToString() != "") { model.SId = int.Parse(ds.Tables[0].Rows[0]["SId"].ToString()); } if (ds.Tables[0].Rows[0]["StuId"] != null && ds.Tables[0].Rows[0]["StuId"].ToString() != "") { model.StuId = int.Parse(ds.Tables[0].Rows[0]["StuId"].ToString()); } if (ds.Tables[0].Rows[0]["GId"] != null && ds.Tables[0].Rows[0]["GId"].ToString() != "") { model.GId = int.Parse(ds.Tables[0].Rows[0]["GId"].ToString()); } if (ds.Tables[0].Rows[0]["CId"] != null && ds.Tables[0].Rows[0]["CId"].ToString() != "") { model.CId = ds.Tables[0].Rows[0]["CId"].ToString(); } if (ds.Tables[0].Rows[0]["Content"] != null && ds.Tables[0].Rows[0]["Content"].ToString() != "") { model.Content = ds.Tables[0].Rows[0]["Content"].ToString(); } if (ds.Tables[0].Rows[0]["F_UserId"] != null && ds.Tables[0].Rows[0]["F_UserId"].ToString() != "") { model.F_UserId = ds.Tables[0].Rows[0]["F_UserId"].ToString(); } if (ds.Tables[0].Rows[0]["F_RealName"] != null && ds.Tables[0].Rows[0]["F_RealName"].ToString() != "") { model.F_RealName = ds.Tables[0].Rows[0]["F_RealName"].ToString(); } if (ds.Tables[0].Rows[0]["CreateIp"] != null && ds.Tables[0].Rows[0]["CreateIp"].ToString() != "") { model.CreateIp = ds.Tables[0].Rows[0]["CreateIp"].ToString(); } if (ds.Tables[0].Rows[0]["SendName"] != null && ds.Tables[0].Rows[0]["SendName"].ToString() != "") { model.SendName = int.Parse(ds.Tables[0].Rows[0]["SendName"].ToString()); } if (ds.Tables[0].Rows[0]["SendStates"] != null && ds.Tables[0].Rows[0]["SendStates"].ToString() != "") { model.SendStates = int.Parse(ds.Tables[0].Rows[0]["SendStates"].ToString()); } if (ds.Tables[0].Rows[0]["SendSuccess"] != null && ds.Tables[0].Rows[0]["SendSuccess"].ToString() != "") { model.SendSuccess = int.Parse(ds.Tables[0].Rows[0]["SendSuccess"].ToString()); } if (ds.Tables[0].Rows[0]["TypeID"] != null && ds.Tables[0].Rows[0]["TypeID"].ToString() != "") { model.TypeID = int.Parse(ds.Tables[0].Rows[0]["TypeID"].ToString()); } return(model); } return(null); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Sys.Model.Expression model) { return(_dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Sys.Model.Expression model) { return(_dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <Sys.Model.Expression> DataTableToList(DataTable dt) { var modelList = new List <Sys.Model.Expression>(); var rowsCount = dt.Rows.Count; if (rowsCount > 0) { Sys.Model.Expression model; for (var n = 0; n < rowsCount; n++) { model = new Sys.Model.Expression(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["CreateTime"] != null && dt.Rows[n]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString()); } if (dt.Rows[n]["SId"] != null && dt.Rows[n]["SId"].ToString() != "") { model.SId = int.Parse(dt.Rows[n]["SId"].ToString()); } if (dt.Rows[n]["StuId"] != null && dt.Rows[n]["StuId"].ToString() != "") { model.StuId = int.Parse(dt.Rows[n]["StuId"].ToString()); } if (dt.Rows[n]["GId"] != null && dt.Rows[n]["GId"].ToString() != "") { model.GId = int.Parse(dt.Rows[n]["GId"].ToString()); } if (dt.Rows[n]["CId"] != null && dt.Rows[n]["CId"].ToString() != "") { model.CId = dt.Rows[n]["CId"].ToString(); } if (dt.Rows[n]["Content"] != null && dt.Rows[n]["Content"].ToString() != "") { model.Content = dt.Rows[n]["Content"].ToString(); } if (dt.Rows[n]["F_UserId"] != null && dt.Rows[n]["F_UserId"].ToString() != "") { model.F_UserId = dt.Rows[n]["F_UserId"].ToString(); } if (dt.Rows[n]["F_RealName"] != null && dt.Rows[n]["F_RealName"].ToString() != "") { model.F_RealName = dt.Rows[n]["F_RealName"].ToString(); } if (dt.Rows[n]["CreateIp"] != null && dt.Rows[n]["CreateIp"].ToString() != "") { model.CreateIp = dt.Rows[n]["CreateIp"].ToString(); } if (dt.Rows[n]["SendName"] != null && dt.Rows[n]["SendName"].ToString() != "") { model.SendName = int.Parse(dt.Rows[n]["SendName"].ToString()); } if (dt.Rows[n]["SendStates"] != null && dt.Rows[n]["SendStates"].ToString() != "") { model.SendStates = int.Parse(dt.Rows[n]["SendStates"].ToString()); } if (dt.Rows[n]["SendSuccess"] != null && dt.Rows[n]["SendSuccess"].ToString() != "") { model.SendSuccess = int.Parse(dt.Rows[n]["SendSuccess"].ToString()); } if (dt.Rows[n]["TypeID"] != null && dt.Rows[n]["TypeID"].ToString() != "") { model.TypeID = int.Parse(dt.Rows[n]["TypeID"].ToString()); } modelList.Add(model); } } return(modelList); }