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"]);
         UselessDeviceModel uselessDevice = UselessDeviceDAO.GetUselessDevice(id);
         this.TypeId.SelectedValue = uselessDevice.getTypeId().ToString();
         this.DeviceName.Text      = uselessDevice.getDeviceName();
         this.DeviceModel.Text     = uselessDevice.getDeviceModel();
         this.DeviceFrom.Text      = uselessDevice.getDeviceFrom();
         this.DeviceCount.Text     = uselessDevice.getDeviceCount().ToString();
     }
 }
Ejemplo n.º 2
0
        /*更新報廢設備資訊*/

        public static bool UpdateUselessDevice(UselessDeviceModel uselessDevice)
        {
            string updateString = "update [t_device_useless] set typeId=";

            updateString += uselessDevice.getTypeId() + ",deviceName=";
            updateString += SqlString.GetQuotedString(uselessDevice.getDeviceName()) + ",deviceModel=";
            updateString += SqlString.GetQuotedString(uselessDevice.getDeviceModel()) + ",deviceFrom=";
            updateString += SqlString.GetQuotedString(uselessDevice.getDeviceFrom()) + ",deviceCount=";
            updateString += uselessDevice.getDeviceCount() + " where id=" + uselessDevice.getId();

            DataBase db = new DataBase();

            if (db.InsertOrUpdate(updateString) > 0)
            {
                return(true);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /*登記報廢設備資訊*/

        public static bool AddUselessDevice(UselessDeviceModel uselessDevice)
        {
            string insertString = "insert into [t_device_useless] (typeId,deviceName,deviceModel,deviceFrom,deviceCount) values (";

            insertString += uselessDevice.getTypeId() + ",";
            insertString += SqlString.GetQuotedString(uselessDevice.getDeviceName()) + ",";
            insertString += SqlString.GetQuotedString(uselessDevice.getDeviceModel()) + ",";
            insertString += SqlString.GetQuotedString(uselessDevice.getDeviceFrom()) + ",";
            insertString += uselessDevice.getDeviceCount() + ")";

            DataBase db = new DataBase();

            if (db.InsertOrUpdate(insertString) > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        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>");
            }
        }