Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null)
            {
                Response.Write("<script>alert('請先登入系統!');top.location.href='login.aspx';</script>");
                return;
            }
            if (!IsPostBack)
            {
                DataSet deviceTypeDs = DeviceTypeDAO.QueryAllDeviceType();
                for (int i = 0; i < deviceTypeDs.Tables[0].Rows.Count; i++)
                {
                    DataRow  dr = deviceTypeDs.Tables[0].Rows[i];
                    ListItem li = new ListItem(dr["typeName"].ToString(), dr["typeId"].ToString());
                    this.TypeId.Items.Add(li);
                }

                DataSet placeDs = PlaceDAO.QueryAllPlace();
                this.UsePlace.DataSource = placeDs;
                this.UsePlace.DataBind();

                int id = Int32.Parse(Request.QueryString["id"]);
                UsingDeviceModel usingDevice = UsingDeviceDAO.GetUsingDevice(id);
                this.TypeId.SelectedValue   = usingDevice.getTypeId().ToString();
                this.DeviceName.Text        = usingDevice.getDeviceName().ToString();
                this.DeviceModel.Text       = usingDevice.getDeviceModel().ToString();
                this.DeviceFrom.Text        = usingDevice.getDeviceFrom().ToString();
                this.Manufacturer.Text      = usingDevice.getManufacturer().ToString();
                this.UseDate.Text           = usingDevice.getUseDate().ToShortDateString();
                this.DeviceLife.Text        = usingDevice.getDeviceLife().ToString();
                this.UsePlace.SelectedValue = usingDevice.getUsePlace().ToString();
                this.DeviceCount.Text       = usingDevice.getDeviceCount().ToString();
                this.DeviceState.Text       = usingDevice.getDeviceState().ToString();
            }
        }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["username"] == null)
     {
         Response.Write("<script>alert('請先登入系統!');top.location.href='login.aspx';</script>");
         return;
     }
     if (!IsPostBack)
     {
         DataSet deviceTypeDs = DeviceTypeDAO.QueryAllDeviceType();
         for (int i = 0; i < deviceTypeDs.Tables[0].Rows.Count; i++)
         {
             DataRow  dr = deviceTypeDs.Tables[0].Rows[i];
             ListItem li = new ListItem(dr["typeName"].ToString(), dr["typeId"].ToString());
             this.TypeId.Items.Add(li);
         }
         int id = Int32.Parse(Request.QueryString["id"]);
         BackupDeviceModel backupDevice = BackupDeviceDAO.GetBackupDevice(id);
         this.TypeId.SelectedValue = backupDevice.getTypeId().ToString();
         this.DeviceName.Text      = backupDevice.getDeviceName();
         this.DeviceModel.Text     = backupDevice.getDeviceModel();
         this.Price.Text           = backupDevice.getPrice().ToString();
         this.DeviceFrom.Text      = backupDevice.getDeviceFrom();
         this.Manufacturer.Text    = backupDevice.getManufacturer();
         this.InDate.Text          = backupDevice.getInDate();
         this.OutDate.Text         = backupDevice.getOutDate();
         this.StockCount.Text      = backupDevice.getStockCount().ToString();
         this.InOperator.Text      = backupDevice.getInOperator();
         this.OutOperator.Text     = backupDevice.getOutOperator();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            {
                if (Session["username"] == null)
                {
                    Response.Write("<script>alert('請先登入系統!');top.location.href='login.aspx';</script>");
                    return;
                }
                if (!IsPostBack)
                {
                    /*初始化設備類別下拉清單*/
                    ListItem li = new ListItem("請選擇", "0");
                    this.TypeId.Items.Add(li);
                    DataSet deviceTypeDs = DeviceTypeDAO.QueryAllDeviceType();
                    for (int i = 0; i < deviceTypeDs.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = deviceTypeDs.Tables[0].Rows[i];
                        li = new ListItem(dr["typeName"].ToString(), dr["typeId"].ToString());
                        this.TypeId.Items.Add(li);
                    }

                    /*初始化使用地點*/
                    li = new ListItem("請選擇", "");
                    this.UsePlace.Items.Add(li);
                    DataSet placeDs = PlaceDAO.QueryAllPlace();
                    for (int i = 0; i < placeDs.Tables[0].Rows.Count; i++)
                    {
                        DataRow dr = placeDs.Tables[0].Rows[i];
                        li = new ListItem(dr["placeName"].ToString(), dr["placeName"].ToString());
                        this.UsePlace.Items.Add(li);
                    }
                }
            }
        }
Beispiel #4
0
        private void InitDeviceTypeInfo()
        {
            DataSet deviceTypeDs = DeviceTypeDAO.QueryAllDeviceType();

            this.GridView1.DataSourceID = null;
            GridView1.DataSource        = deviceTypeDs;
            GridView1.DataBind();
        }
        /*根據記錄號碼查詢本條設備記錄的設備類型*/

        public static string GetDeviceTypeName(int id)
        {
            string   queryString = "select typeId from [t_device_useless] where id=" + id;
            DataBase db          = new DataBase();
            DataSet  deviceDs    = db.GetDataSet(queryString);
            int      typeId      = 0;

            if (deviceDs.Tables[0].Rows.Count > 0)
            {
                DataRow dr = deviceDs.Tables[0].Rows[0];
                typeId = Convert.ToInt32(dr["typeId"]);
            }

            return(DeviceTypeDAO.GetTypeNameById(typeId));
        }
Beispiel #6
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 #7
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 #8
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>");
            }
        }