public PavilionModel GetPavilionByID(string paID) { SqlParameter param = new SqlParameter("@PaID", SqlDbType.VarChar, 3); param.Value = paID; SqlDataReader dr = SqlHelp.ExecuteReader("prc_GetPavilionByID", CommandType.StoredProcedure, param); dr.Read(); PavilionModel pavilion = new PavilionModel(); if (dr.HasRows) { pavilion.PaID = dr[0].ToString(); pavilion.Name = dr[1].ToString(); pavilion.Layer = Convert.ToInt32(dr[2]); pavilion.Height = Convert.ToDouble(dr[3]); pavilion.Area = Convert.ToDouble(dr[4]); pavilion.BuildDate = Convert.ToDateTime(dr[5]); pavilion.Memo = dr[6].ToString(); pavilion.TypeName = dr[7].ToString(); pavilion.TypeID = Convert.ToInt32(dr[8]); } dr.Close(); return(pavilion); }
protected void Page_Load(object sender, EventArgs e) { user = (UserModel)Session["User"]; if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1) { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { DDLPavilionType.DataSource = bll.GetType("Pavilion"); DDLPavilionType.DataBind(); string paID = Request.QueryString["ID"].ToString(); PavilionModel pavilion = pabll.GetPavilionByID(paID); txtPavilionName.Text = pavilion.Name; txtPavilionLayer.Text = pavilion.Layer.ToString(); txtPavilionHeight.Text = pavilion.Height.ToString(); txtPavilionArea.Text = pavilion.Area.ToString(); txtBuildDate.Value = pavilion.BuildDate.ToString("yyyy-MM-dd"); DDLPavilionType.SelectedValue = pavilion.TypeID.ToString(); txtMemo.Text = pavilion.Memo; } } }
protected void Add_Click(object sender, EventArgs e) { PavilionModel pavilion = new PavilionModel(); int i = pabll.GetMaxID(); if (i == -1) { pavilion.PaID = "100"; } else { pavilion.PaID = (i + 1).ToString(); } pavilion.Name = txtPavilionName.Text.Trim(); pavilion.Layer = Convert.ToInt32(txtPavilionLayer.Text.Trim()); pavilion.Height = Convert.ToDouble(txtPavilionHeight.Text.Trim()); pavilion.Area = Convert.ToDouble(txtPavilionArea.Text.Trim()); pavilion.BuildDate = Convert.ToDateTime(txtBuildDate.Value.Trim()); pavilion.TypeID = Convert.ToInt32(DDLPavilionType.SelectedValue); pavilion.Memo = txtMemo.Text.Trim(); bool flag = pabll.InsertPavilion(pavilion); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加成功');location.href='PavilionInfo.aspx';</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加失败');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { user = (UserModel)Session["User"]; if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1) { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { DDLPa.DataSource = pabll.GetAllPavilion(); DDLPa.DataBind(); DDLCell.DataSource = bll.GetType("Cell"); DDLCell.DataBind(); DDLLayerBegin.Items.Clear(); DDLLayerEnd.Items.Clear(); PavilionModel pavilion = pabll.GetPavilionByID(DDLPa.SelectedValue); for (int i = 1; i <= pavilion.Layer; i++) { ListItem items = new ListItem(); items.Text = i.ToString(); if (i < 10) { items.Value = "0" + i.ToString(); } else { items.Value = i.ToString(); } DDLLayerBegin.Items.Add(items); DDLLayerEnd.Items.Add(items); } DDLLayerBegin.DataBind(); DDLLayerEnd.DataBind(); if (dttable.Columns.Count == 0) { dttable.Columns.Add("ID", typeof(int)); dttable.Columns.Add("SunnyID", typeof(int)); dttable.Columns.Add("SunnyName", typeof(string)); dttable.Columns.Add("IndoorID", typeof(int)); dttable.Columns.Add("IndoorName", typeof(string)); dttable.Columns.Add("RoomUseID", typeof(int)); dttable.Columns.Add("RoomUseName", typeof(string)); dttable.Columns.Add("RoomFormatID", typeof(int)); dttable.Columns.Add("RoomFormatName", typeof(string)); dttable.Columns.Add("BuildArea", typeof(double)); dttable.Columns.Add("UseArea", typeof(double)); DataColumn[] key = { dttable.Columns["ID"] }; dttable.PrimaryKey = key; } } } }
public int InsertPavilion(PavilionModel pavilion) { SqlParameter[] param = { new SqlParameter("@PaID", SqlDbType.VarChar, 3), new SqlParameter("@Name", SqlDbType.VarChar, 20), new SqlParameter("@Layer", SqlDbType.SmallInt), new SqlParameter("@Height", SqlDbType.Float), new SqlParameter("@Area", SqlDbType.Float), new SqlParameter("@BuildDate", SqlDbType.DateTime, 10), new SqlParameter("@Memo", SqlDbType.Text), new SqlParameter("@TypeID", SqlDbType.Int) }; param[0].Value = pavilion.PaID; param[1].Value = pavilion.Name; param[2].Value = pavilion.Layer; param[3].Value = pavilion.Height; param[4].Value = pavilion.Area; param[5].Value = pavilion.BuildDate; param[6].Value = pavilion.Memo; param[7].Value = pavilion.TypeID; int result = SqlHelp.ExecuteNonQuery("prc_InsertPavilion", CommandType.StoredProcedure, param); return(result); }
public List <PavilionModel> GetAllPavilion() { SqlDataReader dr = SqlHelp.ExecuteReader("prc_GetAllPavilion", CommandType.StoredProcedure); List <PavilionModel> list = new List <PavilionModel>(); while (dr.Read()) { PavilionModel pavilion = new PavilionModel(); pavilion.PaID = dr[0].ToString(); pavilion.Name = dr[1].ToString(); pavilion.Layer = Convert.ToInt32(dr[2]); pavilion.Height = Convert.ToDouble(dr[3]); pavilion.Area = Convert.ToDouble(dr[4]); pavilion.BuildDate = Convert.ToDateTime(dr[5]); pavilion.Memo = dr[6].ToString(); pavilion.TypeName = dr[7].ToString(); list.Add(pavilion); } dr.Close(); return(list); }
protected void Edit_Click(object sender, EventArgs e) { PavilionModel pavilion = new PavilionModel(); pavilion.PaID = Request.QueryString["ID"].ToString(); pavilion.Name = txtPavilionName.Text.Trim(); pavilion.Layer = Convert.ToInt32(txtPavilionLayer.Text.Trim()); pavilion.Height = Convert.ToDouble(txtPavilionHeight.Text.Trim()); pavilion.Area = Convert.ToDouble(txtPavilionArea.Text.Trim()); pavilion.BuildDate = Convert.ToDateTime(txtBuildDate.Value.Trim()); pavilion.TypeID = Convert.ToInt32(DDLPavilionType.SelectedValue); pavilion.Memo = txtMemo.Text.Trim(); bool flag = pabll.UpdatePavilion(pavilion); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('修改成功');location.href='PavilionInfo.aspx';</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('修改失败');</script>"); } }
public List <PavilionModel> GetPavilionByCondition(string condition) { SqlParameter param = new SqlParameter("@Condition", SqlDbType.VarChar, 255); param.Value = condition; SqlDataReader dr = SqlHelp.ExecuteReader("prc_GetPavilionByCondition", CommandType.StoredProcedure, param); List <PavilionModel> list = new List <PavilionModel>(); while (dr.Read()) { PavilionModel pavilion = new PavilionModel(); pavilion.PaID = dr[0].ToString(); pavilion.Name = dr[1].ToString(); pavilion.Layer = Convert.ToInt32(dr[2]); pavilion.Height = Convert.ToDouble(dr[3]); pavilion.Area = Convert.ToDouble(dr[4]); pavilion.BuildDate = Convert.ToDateTime(dr[5]); pavilion.Memo = dr[6].ToString(); pavilion.TypeName = dr[7].ToString(); list.Add(pavilion); } dr.Close(); return(list); }
protected void DDLPa_SelectedIndexChanged(object sender, EventArgs e) { DDLLayerBegin.Items.Clear(); DDLLayerEnd.Items.Clear(); PavilionModel pavilion = pabll.GetPavilionByID(DDLPa.SelectedValue); for (int i = 1; i <= pavilion.Layer; i++) { ListItem items = new ListItem(); items.Text = i.ToString(); if (i < 10) { items.Value = "0" + i.ToString(); } else { items.Value = i.ToString(); } DDLLayerBegin.Items.Add(items); DDLLayerEnd.Items.Add(items); } DDLLayerBegin.DataBind(); DDLLayerEnd.DataBind(); }
public bool InsertPavilion(PavilionModel pavilion) { int result = dal.InsertPavilion(pavilion); return(result == 0 ? false : true); }
public bool UpdatePavilion(PavilionModel pavilion) { int result = dal.UpdatePavilion(pavilion); return(result == 0 ? false : true); }