- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Vehicles_OperatorManager : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- Model.Controlloer MM = new Model.Controlloer();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.Controlloer BM = new BLL.Controlloer();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Vehicles_OperatorManager");
- if (!IsPostBack)
- {
- MyDataBind();
- }
- }
- /// <summary>
- /// 清空
- /// </summary>
- public void Clear()
- {
- KeyValue_DDY.Text = "";
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (String.IsNullOrEmpty(KeyValue_DDY.Text.Trim()))
- {
- throw new Exception("调度员不能为空!");
- }
- if (BM.GetCount("DDY = '" + KeyValue_DDY.Text + "'") > 0)
- {
- throw new Exception("该调度员已经存在!");
- }
- MM.DDY = KeyValue_DDY.Text;
- BM.Add(MM);
- MessageBox.Show("添加成功!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- Clear();
- MyDataBind();
- }
- protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
- {
- for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
- {
- CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
- if (CheckBox1.Checked)
- {
- cbox.Checked = true;
- }
- else
- {
- cbox.Checked = false;
- }
- }
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- /// <summary>
- /// 获取信息
- /// </summary>
- /// <param name="pidx">页号</param>
- public void MyDataBind()
- {
- List<Model.Controlloer> LRData = BM.GetList();
- if (LRData.Count == 0)
- {
- Model.Controlloer MM = new Model.Controlloer();
- LRData.Add(MM);
- }
- GridView1.DataSource = LRData;
- GridView1.DataBind();
- }
- protected void DelButton1_Click(object sender, EventArgs e)
- {
- try
- {
- for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
- {
- CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
- if (cbox.Checked)
- {
- int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
- if (Id == 0)
- {
- throw new Exception("该记录不能被删除!");
- }
- BM.Delete(Id);
- }
- else
- {
- }
- }
- MessageBox.Show("删除完成!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- MyDataBind();
- Clear();
- }
- }