Beispiel #1
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            /*取得该记录编号*/
            int           typeId        = Int32.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
            DeviceTypeDAO deviceTypeDAO = new DeviceTypeDAO();

            if (deviceTypeDAO.DeleteDeviceType(typeId))
            {
                Response.Write("<script language=javascript>alert('成功删除类别!');</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('" + deviceTypeDAO.getErrMessage() + "');</script>");
            }
            GridView1.EditIndex = -1;
            InitDeviceTypeInfo();
        }
Beispiel #2
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            /*取得该类别编号和类别名称*/
            int    typeId   = Int32.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
            string typeName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TypeName")).Text;
            /*调用业务层执行更新操作*/
            DeviceTypeDAO deviceTypeDAO = new DeviceTypeDAO();

            if (deviceTypeDAO.UpdateDeviceType(typeId, typeName))
            {
                Response.Write("<script language=javascript>alert('修改成功!');</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('" + deviceTypeDAO.getErrMessage() + "');</script>");
            }
            GridView1.EditIndex = -1;
            InitDeviceTypeInfo();
        }
Beispiel #3
0
        protected void Btn_Add_Click(object sender, EventArgs e)
        {
            string typeName = this.TypeName.Text;

            if (typeName == "")
            {
                Response.Write("<script>alert('請填寫類別名稱!');</script>");
                return;
            }

            DeviceTypeDAO deviceTypeDAO = new DeviceTypeDAO();

            if (deviceTypeDAO.AddDeviceType(typeName))
            {
                Response.Write("<script>alert('設備類別添加成功!');location.href='DeviceTypeManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('" + deviceTypeDAO.getErrMessage() + "');location.href='DeviceTypeManage.aspx';</script>");
            }
        }