Exemple #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();
            }
        }
Exemple #2
0
        protected void Btn_Update_Click(object sender, EventArgs e)
        {
            UsingDeviceModel usingDevice = new UsingDeviceModel();
            int id = Int32.Parse(Request.QueryString["id"]);

            usingDevice.setId(id);
            usingDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            usingDevice.setDeviceName(this.DeviceName.Text);
            usingDevice.setDeviceModel(this.DeviceModel.Text);
            usingDevice.setDeviceFrom(this.DeviceFrom.Text);
            usingDevice.setManufacturer(this.Manufacturer.Text);
            usingDevice.setUseDate(Convert.ToDateTime(this.UseDate.Text));
            usingDevice.setDeviceLife(Int32.Parse(this.DeviceLife.Text));
            usingDevice.setUsePlace(this.UsePlace.SelectedValue);
            usingDevice.setDeviceCount(Int32.Parse(this.DeviceCount.Text));
            usingDevice.setDeviceState(this.DeviceState.Text);
            if (UsingDeviceDAO.UpdateUsingDevice(usingDevice))
            {
                Response.Write("<script>alert('更新成功!');location.href='UsingDeviceManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('更新失敗!');</script>");
            }
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            string  deviceName = this.DeviceName.Text;
            int     typeId     = Int32.Parse(this.TypeId.SelectedValue);
            string  usePlace   = this.UsePlace.SelectedValue;
            DataSet ds         = UsingDeviceDAO.QueryDeviceInfo(deviceName, typeId, usePlace);

            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 = UsingDeviceDAO.GetDeviceTypeName(id);

                e.Row.Cells[5].Text = Convert.ToDateTime(e.Row.Cells[5].Text).ToShortDateString();
            }
        }
        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 (UsingDeviceDAO.DeleteUsingDevice(id))
            {
                Response.Write("<script>alert('刪除成功!');location.href='UsingDeviceManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('刪除失敗!');location.href='UsingDeviceManage.aspx';</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null)
            {
                Response.Write("<script>alert('請先登入系統!');top.location.href='login.aspx';</script>");
                return;
            }

            ArrayList devices = UsingDeviceDAO.GetStockWarningDevices();

            if (devices.Count == 0)
            {
                this.Devices.Text = "<font color=blue>暫時還沒有設備需要購買!</font>";
            }
            else
            {
                this.Devices.Text += "<font color=blue>";
                for (int i = 0; i < devices.Count; i++)
                {
                    this.Devices.Text += devices[i].ToString() + "<br>";
                }
                this.Devices.Text += "</font>";
            }
        }
        protected void Btn_Add_Click(object sender, EventArgs e)
        {
            UsingDeviceModel usingDevice = new UsingDeviceModel();

            usingDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            usingDevice.setDeviceName(this.DeviceName.Text);
            usingDevice.setDeviceModel(this.DeviceModel.Text);
            usingDevice.setDeviceFrom(this.DeviceFrom.Text);
            usingDevice.setManufacturer(this.Manufacturer.Text);
            usingDevice.setUseDate(Convert.ToDateTime(this.UseDate.Text));
            usingDevice.setDeviceLife(Int32.Parse(this.deviceLife.Text));
            usingDevice.setUsePlace(this.UsePlace.SelectedValue);
            usingDevice.setDeviceCount(Int32.Parse(this.DeviceCount.Text));
            usingDevice.setDeviceState(this.DeviceState.Text);

            if (UsingDeviceDAO.AddUsingDevice(usingDevice))
            {
                Response.Write("<script>alert('在用設備登記成功!');location.href='UsingDeviceAdd.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('在用設備登記失敗!');location.href='UsingDeviceAdd.aspx';</script>");
            }
        }