public void Wc_VehicleController(string Action, FormCollection fc) { switch (Action) { case "ok_One": { un.model.ObjectID = Convert.ToInt16(fc["O_id"]); un.model.Pversion = fc["O_name"]; un.model.Pversion = fc["O_Ilm"]; //少一个droplist un.model.Pversion = fc["O_Channel"]; un.model.Pversion = fc["O_Model"]; un.model.Pversion = fc["O_id"]; un.model.Pversion = fc["O_Brand"]; un.model.Pversion = fc["O_Company"]; un.model.Pversion = fc["O_Color"]; un.model.Pversion = fc["O_Mobile2"]; un.model.Pversion = fc["O_name2"]; un.model.Pversion = fc["0_Phone"]; un.model.Pversion = fc["0_Time"]; //少一个droplist un.model.Pversion = fc["O_Ratio"]; break; } case "ok_two": { un.model.Pversion = fc["sp_offices"]; un.model.Pversion = fc["sp_No"]; un.model.Pversion = fc["sp_type"]; un.model.Pversion = fc["sp_chargers"]; un.model.Pversion = fc["sp_Ino"]; un.model.Pversion = fc["sp_Time"]; break; } case "ok_Third": { un.model.ObjectID = Convert.ToInt16(fc["T_id"]); un.model.Pversion = fc["un.categories"]; un.model.EqManufacturers = fc["T_types"]; un.model.Eqtypes = fc["T_version"]; bool flg = base.CustomerInfo.InsertModel(un.model); if (flg) { Response.Redirect("/WC_Index/Index"); } break; } case "ok_Four": { un.model.Pversion = fc["F_No"]; un.model.Pversion = fc["F_contacts"]; un.model.Pversion = fc["F_name"]; un.model.Pversion = fc["E_phone"]; un.model.Pversion = fc["F_Pone"]; un.model.Pversion = fc["F_model"]; un.model.Pversion = fc["D_modle"]; un.model.Pversion = fc["F_contacts2"]; un.model.Pversion = fc["F_sex"]; un.model.Pversion = fc["F_phone2"]; un.model.Pversion = fc["F_model2"]; un.model.Pversion = fc["F_no"]; break; } } }
这样的代码估计还多人都用过 怎么样利用反射来优化呢?
调用:
public ActionResult InsertVehicle(string Action, FormCollection fc)
{
Wc_VehicleController( Action, fc);
return View();
}
先定义个类 把所有要操作的方法定义 然后利用type ?好像打错了那个属性就可以了 大话设计里面有