/// <summary> /// 获得数据列表 /// </summary> public List<Maticsoft.Model.Agent> DataTableToList(DataTable dt) { List<Maticsoft.Model.Agent> modelList = new List<Maticsoft.Model.Agent>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Maticsoft.Model.Agent model; for (int n = 0; n < rowsCount; n++) { model = new Maticsoft.Model.Agent(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.category = dt.Rows[n]["category"].ToString(); model.agentname = dt.Rows[n]["agentname"].ToString(); model.tel = dt.Rows[n]["tel"].ToString(); model.addr = dt.Rows[n]["addr"].ToString(); model.point = dt.Rows[n]["point"].ToString(); model.cuscount = dt.Rows[n]["cuscount"].ToString(); model.flag = dt.Rows[n]["flag"].ToString(); if (dt.Rows[n]["createdate"].ToString() != "") { model.createdate = DateTime.Parse(dt.Rows[n]["createdate"].ToString()); } modelList.Add(model); } } return modelList; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Rid.Value = string.IsNullOrEmpty(Request["id"]) ? "" : Request["id"]; if (!string.IsNullOrEmpty(Rid.Value)) { Maticsoft.BLL.Agent bll = new Maticsoft.BLL.Agent(); Maticsoft.Model.Agent model = bll.GetModel(Convert.ToInt32(Rid.Value)); addr.Text = model.addr; agentname.Text = model.agentname; category.Text = model.category; createdate.Text = (model.createdate).ToString(); cuscount.Text = model.cuscount; flag.Text = model.flag; point.Text = model.point; tel.Text = model.tel; } } }
protected void save_Click(object sender, EventArgs e) { Maticsoft.BLL.Agent bll = new Maticsoft.BLL.Agent(); Maticsoft.Model.Agent model = new Maticsoft.Model.Agent(); model.addr = addr.Text; model.agentname = agentname.Text; model.category = category.Text; model.createdate = Convert.ToDateTime(createdate.Text); model.cuscount = cuscount.Text; model.flag = flag.Text; model.point = point.Text; model.tel = tel.Text; if (string.IsNullOrEmpty(Rid.Value)) { if (bll.Add(model) > 0) { Maticsoft.Common.MessageBox.ShowAndRedirect(Page, "添加成功", "get_Agent.aspx"); } else { Maticsoft.Common.MessageBox.Show(Page, "添加失败"); } } else { model.id = Convert.ToInt32(Rid.Value); if (bll.Update(model)) { Maticsoft.Common.MessageBox.ShowAndRedirect(Page, "更新成功", "get_Agent.aspx"); } else { Maticsoft.Common.MessageBox.Show(Page, "更新失败"); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Agent model) { return dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.Agent model) { return dal.Add(model); }