public static MokuaiDto GetOneMokuaiDto(string table,string strwhere) { MokuaiDto mokuaiDto=new MokuaiDto(); mokuaiDto = MokuaiDal.GetOneMokuai(table, strwhere); return mokuaiDto; }
public ActionResult MokuaiInsert(MokuaiAddViewModel model) { MokuaiDto mokuaiDto = new MokuaiDto(); mokuaiDto.MokuaiTitle = model.MokuaiTitle; mokuaiDto.MokuaiImg = model.MokuaiImg; mokuaiDto.MokuaiContent = model.MokuaiContent; mokuaiDto.MokuaiInfo = model.MokuaiInfo; mokuaiDto.MokuaiDateTime = System.DateTime.Now; MokuaiBll.AddMokuai(mokuaiDto); return RedirectToAction("MokuaiIndex"); }
public static void AddMokuai(MokuaiDto mokuaiDto) { SqlParameter[] arParames = MokuaiDal.getParameters(mokuaiDto); SqlConnection myconn = new SqlConnection(CommonDal.ConnectionString); try { SqlHelper.ExecuteNonQuery(CommonDal.ConnectionString, CommandType.StoredProcedure, "CreateMokuai", arParames); } catch (SqlException ex) { throw ex; } finally { myconn.Close(); myconn.Dispose(); } }
public static List<MokuaiDto> GetMokuaiList(string strwhere) { List<MokuaiDto> mokuailist = new List<MokuaiDto>(); SqlParameter[] arParames = new SqlParameter[2]; arParames[0] = new SqlParameter("@table ", SqlDbType.VarChar, 200); arParames[0].Value = "QxsqMokuai"; arParames[1] = new SqlParameter("@Where ", SqlDbType.VarChar, 8000); arParames[1].Value = strwhere; SqlConnection myconn = new SqlConnection(CommonDal.ConnectionString); try { DataTable dt = null; DataSet ds = SqlHelper.ExecuteDataset(CommonDal.ConnectionString, CommandType.StoredProcedure, "getModelByWhere", arParames); dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { MokuaiDto MokuaiDto = new MokuaiDto(); MokuaiDto = MokuaiDal.getDataRowToMokuaiDto(dr); mokuailist.Add(MokuaiDto); } return mokuailist; } catch (SqlException ex) { throw ex; } finally { myconn.Close(); myconn.Dispose(); } }
private static SqlParameter[] getParameters(MokuaiDto mokuaiDto) { SqlParameter[] arParames = new SqlParameter[6]; arParames[0] = new SqlParameter("@MokuaiId", SqlDbType.Int); arParames[0].Value = mokuaiDto.MokuaiId; arParames[1] = new SqlParameter("@MokuaiTitle", SqlDbType.VarChar, 500); arParames[1].Value = mokuaiDto.MokuaiTitle; arParames[2] = new SqlParameter("@MokuaiImg", SqlDbType.VarChar, 500); arParames[2].Value = mokuaiDto.MokuaiImg; arParames[3] = new SqlParameter("@MokuaiContent", SqlDbType.Text); arParames[3].Value = mokuaiDto.MokuaiContent; arParames[4] = new SqlParameter("@MokuaiInfo", SqlDbType.Text); arParames[4].Value = mokuaiDto.MokuaiInfo; arParames[5] = new SqlParameter("@MokuaiDateTime", SqlDbType.DateTime); arParames[5].Value = mokuaiDto.MokuaiDateTime; return arParames; }
private static MokuaiDto getDataRowToMokuaiDto(DataRow dr) { MokuaiDto mokuaiDto = new MokuaiDto(); mokuaiDto.MokuaiId = int.Parse(dr["MokuaiId"].ToString()); mokuaiDto.MokuaiTitle = dr["MokuaiTitle"].ToString(); mokuaiDto.MokuaiImg = dr["MokuaiImg"].ToString(); mokuaiDto.MokuaiContent = dr["MokuaiContent"].ToString(); mokuaiDto.MokuaiInfo = dr["MokuaiInfo"].ToString(); mokuaiDto.MokuaiDateTime = DateTime.Parse(dr["MokuaiDateTime"].ToString()); return mokuaiDto; }
public static void UpdateMokuaiDto(MokuaiDto mokuaiDto) { MokuaiDal.UpdateMokuai(mokuaiDto); }
public static void AddMokuai(MokuaiDto mokuaiDto) { MokuaiDal.AddMokuai(mokuaiDto); }