Esempio n. 1
0
        /*取得某個報廢設備資訊*/

        public static UselessDeviceModel GetUselessDevice(int id)
        {
            UselessDeviceModel uselessDevice = null;
            string             queryString   = "select * from [t_device_useless] where id=" + id;
            DataBase           db            = new DataBase();
            DataSet            deviceDs      = db.GetDataSet(queryString);

            if (deviceDs.Tables[0].Rows.Count > 0)
            {
                uselessDevice = new UselessDeviceModel();
                DataRow dr = deviceDs.Tables[0].Rows[0];
                uselessDevice.setTypeId(Convert.ToInt32(dr["typeId"]));
                uselessDevice.setDeviceName(dr["deviceName"].ToString());
                uselessDevice.setDeviceModel(dr["deviceModel"].ToString());
                uselessDevice.setDeviceFrom(dr["deviceFrom"].ToString());
                uselessDevice.setDeviceCount(Convert.ToInt32(dr["deviceCount"]));
            }
            return(uselessDevice);
        }
        protected void Btn_Add_Click(object sender, EventArgs e)
        {
            UselessDeviceModel uselessDevice = new UselessDeviceModel();

            uselessDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            uselessDevice.setDeviceName(this.DeviceName.Text);
            uselessDevice.setDeviceModel(this.DeviceModel.Text);
            uselessDevice.setDeviceFrom(this.DeviceFrom.Text);
            uselessDevice.setDeviceCount(Int32.Parse(this.DeviceCount.Text));

            if (UselessDeviceDAO.AddUselessDevice(uselessDevice))
            {
                Response.Write("<script>alert('報廢設備登記成功!');location.href='UselessDeviceAdd.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('報廢設備登記失敗!');location.href='UselessDeviceAdd.aspx';</script>");
            }
        }
        protected void Btn_Update_Click(object sender, EventArgs e)
        {
            UselessDeviceModel uselessDevice = new UselessDeviceModel();
            int id = Int32.Parse(Request.QueryString["id"]);

            uselessDevice.setId(id);
            uselessDevice.setTypeId(Int32.Parse(this.TypeId.SelectedValue));
            uselessDevice.setDeviceName(this.DeviceName.Text);
            uselessDevice.setDeviceModel(this.DeviceModel.Text);
            uselessDevice.setDeviceFrom(this.DeviceFrom.Text);
            uselessDevice.setDeviceCount(Int32.Parse(this.DeviceCount.Text));

            if (UselessDeviceDAO.UpdateUselessDevice(uselessDevice))
            {
                Response.Write("<script>alert('更新成功!');location.href='UselessDeviceManage.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('更新失败!');</script>");
            }
        }