修改某个数据可属性值根据三层 BLL
/// <summary>
/// 提交
/// </summary>
private void Submit()
{
string msg = "-1";
int id = Convert.ToInt32(Request.Form["ipt_citygameid"]);
if (msg == "-1")
{
if (!string.IsNullOrEmpty(Request.Form["ipt_citygameid"]))
{
Model.CityGame CityGameModel = GetData();
if (id == 0)
{
if (cityGameBLL.Add(CityGameModel) > 0)
{
msg = "0";
if (Request.Form["ipt_isselect"].ToString() == "True")
{
}
}
}
else if (id > 0)
{
if (cityGameBLL.Update(CityGameModel))
{
msg = "0";
if (Request.Form["ipt_isselect"].ToString() == "True")
{
}
}
}
}
}
WebCommon.WriteMsg(msg);
}
/// <summary>
/// 获取数据
/// </summary>
/// <returns></returns>
private Model.CityGame GetData()
{
int id = Convert.ToInt32(Request.Form["ipt_citygameid"]);
Model.CityGame cityGameModel = new Model.CityGame();
if (id == 0)
{
cityGameModel.Year = Request.Form["ipt_year"];
cityGameModel.BeginDateTime = Convert.ToDateTime(Request.Form["ipt_begindatetime"]);
cityGameModel.EndDateTime = Convert.ToDateTime(Request.Form["ipt_enddatetime"]);
cityGameModel.GameName = Request.Form["ipt_gamename"];
cityGameModel.RegBeginDateTime = Convert.ToDateTime(Request.Form["ipt_regbegindatetime"]);
cityGameModel.RegEndDateTime = Convert.ToDateTime(Request.Form["ipt_regenddatetime"]);
cityGameModel.Remark = Request.Form["ipt_remark"];
cityGameModel.Attachment = Request.Form["ipt_attachment"];
cityGameModel.IsDelete = false;
cityGameModel.IsSelect = Convert.ToBoolean(Request.Form["ipt_isselect"]);
if (Request.Form["ipt_isselect"].ToString() == "True")
{
DataSet ds = cityGameBLL.GetAllList();
foreach (DataRow item in ds.Tables[0].Rows)
{
Model.CityGame cgModel = new Model.CityGame();
cgModel = cityGameBLL.GetModel(Convert.ToInt32(item["CityGameID"]));
cgModel.IsSelect =Convert.ToBoolean("False");
cityGameBLL.Update(cgModel);
}
}
}
if (id > 0)
{
cityGameModel= cityGameBLL.GetModel(id);
cityGameModel.Year = Request.Form["ipt_year"];
cityGameModel.BeginDateTime = Convert.ToDateTime(Request.Form["ipt_begindatetime"]);
cityGameModel.EndDateTime = Convert.ToDateTime(Request.Form["ipt_enddatetime"]);
cityGameModel.GameName = Request.Form["ipt_gamename"];
cityGameModel.RegBeginDateTime = Convert.ToDateTime(Request.Form["ipt_regbegindatetime"]);
cityGameModel.RegEndDateTime = Convert.ToDateTime(Request.Form["ipt_regenddatetime"]);
cityGameModel.Remark = Request.Form["ipt_remark"];
cityGameModel.Attachment = Request.Form["ipt_attachment"];
cityGameModel.IsDelete = false;
cityGameModel.IsSelect = Convert.ToBoolean(Request.Form["ipt_isselect"]);
if (Request.Form["ipt_isselect"].ToString() == "True")
{
DataSet ds = cityGameBLL.GetAllList();
foreach (DataRow item in ds.Tables[0].Rows)
{
Model.CityGame cgModel = new Model.CityGame();
cgModel = cityGameBLL.GetModel(Convert.ToInt32(item["CityGameID"]));
cgModel.IsSelect = Convert.ToBoolean("False");
cityGameBLL.Update(cgModel);
}
}
}
return cityGameModel;
}