Esempio n. 1
0
        protected void Btn_Update_Click(object sender, EventArgs e)
        {
            BackupDeviceModel backupDevice = new BackupDeviceModel();
            int id = Int32.Parse(Request.QueryString["id"]);

            backupDevice.setId(id);
            backupDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            backupDevice.setDeviceName(this.DeviceName.Text);
            backupDevice.setDeviceModel(this.DeviceModel.Text);
            backupDevice.setPrice(Convert.ToSingle(this.Price.Text));
            backupDevice.setDeviceFrom(this.DeviceFrom.Text);
            backupDevice.setManufacturer(this.Manufacturer.Text);
            backupDevice.setInDate(this.InDate.Text);
            backupDevice.setOutDate(this.OutDate.Text);
            backupDevice.setStockCount(Int32.Parse(this.StockCount.Text));
            backupDevice.setInOperator(this.InOperator.Text);
            backupDevice.setOutOperator(this.OutOperator.Text);

            if (BackupDeviceDAO.UpdateDeviceModel(backupDevice))
            {
                Response.Write("<script>alert('更新成功!');location.href='BackupDeviceManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('更新失敗!');</script>");
            }
        }
Esempio n. 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();
     }
 }
Esempio n. 3
0
        protected void Btn_Add_Click(object sender, EventArgs e)
        {
            BackupDeviceModel backupDevice = new BackupDeviceModel();

            backupDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            backupDevice.setDeviceName(this.DeviceName.Text);
            backupDevice.setDeviceModel(this.DeviceModel.Text);
            backupDevice.setPrice(Convert.ToSingle(this.Price.Text));
            backupDevice.setDeviceFrom(this.DeviceFrom.Text);
            backupDevice.setManufacturer(this.Manufacturer.Text);
            backupDevice.setInDate(this.InDate.Text);
            backupDevice.setOutDate(this.OutDate.Text);
            backupDevice.setStockCount(Int32.Parse(this.StockCount.Text));
            backupDevice.setInOperator(this.InOperator.Text);
            backupDevice.setOutOperator(this.OutOperator.Text);

            if (BackupDeviceDAO.AddBackupDevice(backupDevice))
            {
                Response.Write("<script>alert('備用備件登記成功!');location.href='BackupDeviceAdd.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('備用備件登記失敗!');location.href='BackupDeviceAdd.aspx';</script>");
            }
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            string  deviceName = this.DeviceName.Text;
            int     typeId     = Int32.Parse(this.TypeId.SelectedValue);
            DataSet ds         = BackupDeviceDAO.QueryDeviceInfo(deviceName, typeId);

            this.GridView1.DataSourceID = null;
            this.GridView1.DataSource   = ds;
            this.GridView1.PageIndex    = e.NewPageIndex;
            this.GridView1.DataBind();
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //當滑鼠選擇某行時變顏色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00ffee';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");

                Literal TypeName = (Literal)e.Row.Cells[1].FindControl("TypeName");

                int id = Convert.ToInt32(this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString());
                TypeName.Text = BackupDeviceDAO.GetDeviceTypeName(id);
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null)
            {
                Response.Write("<script>alert('請先登入系統!');top.location.href='login.aspx';</script>");
                return;
            }

            int id = Int32.Parse(Request.QueryString["id"]);

            if (BackupDeviceDAO.DeleteDevice(id))
            {
                Response.Write("<script>alert('刪除成功!');location.href='BackupDeviceManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('刪除失敗!');location.href='BackupDeviceManage.aspx';</script>");
            }
        }