public static UserClassDto GetOneUserClassDto(string table,string strwhere) { UserClassDto userClassDto=new UserClassDto(); userClassDto = UserClassDal.GetOneUserClass(table, strwhere); return userClassDto; }
public ActionResult UserClassInsert(UserClassAddViewModel model) { UserClassDto userClassDto = new UserClassDto(); userClassDto.UserClassName = model.UserClassName; UserClassBll.AddUserClass(userClassDto); return RedirectTo("/UserClass/UserClassIndex", "归档类别添加成功了"); //return RedirectToAction("UserClassIndex"); }
public static void AddUserClass(UserClassDto userClassDto) { SqlParameter[] arParames = UserClassDal.getParameters(userClassDto); SqlConnection myconn = new SqlConnection(CommonDal.ConnectionString); try { SqlHelper.ExecuteNonQuery(myconn, CommandType.StoredProcedure, "CreateUserClass", arParames); } catch (SqlException ex) { throw ex; } finally { myconn.Close(); myconn.Dispose(); } }
public static UserClassDto GetOneUserClass(string table,string strwhere) { UserClassDto userClassDto = new UserClassDto(); SqlParameter[] arParames = new SqlParameter[2]; arParames[0] = new SqlParameter("@table ", SqlDbType.VarChar, 200); arParames[0].Value = table; arParames[1] = new SqlParameter("@Where ", SqlDbType.VarChar, 8000); arParames[1].Value = strwhere; DataTable dt = null; SqlConnection myconn = new SqlConnection(CommonDal.ConnectionString); try { DataSet ds = SqlHelper.ExecuteDataset(myconn, CommandType.StoredProcedure, "getModelByWhere", arParames); dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { userClassDto = UserClassDal.getDataRowToUserClassDto(dr); } return userClassDto; } catch (SqlException ex) { throw ex; } finally { myconn.Close(); myconn.Dispose(); } }
public static void UpdateUserClassDto(UserClassDto userClassDto) { UserClassDal.UpdateUserClass(userClassDto); }
public static void AddUserClass(UserClassDto userClassDto) { UserClassDal.AddUserClass(userClassDto); }
private static SqlParameter[] getParameters(UserClassDto userClassDto) { SqlParameter[] arParames = new SqlParameter[2]; arParames[0] = new SqlParameter("@UserClassId", SqlDbType.Int); arParames[0].Value = userClassDto.UserClassId; arParames[1] = new SqlParameter("@UserClassName", SqlDbType.VarChar, 50); arParames[1].Value = userClassDto.UserClassName; return arParames; }
private static UserClassDto getDataRowToUserClassDto(DataRow dr) { UserClassDto userClassDto = new UserClassDto(); userClassDto.UserClassId = int.Parse(dr["UserClassId"].ToString()); userClassDto.UserClassName = dr["UserClassName"].ToString(); return userClassDto; }