Exemplo n.º 1
0
        /*取得某個備用設備資訊*/

        public static BackupDeviceModel GetBackupDevice(int id)
        {
            BackupDeviceModel backupDevice = null;
            string            queryString  = "select * from [t_device_backup] where id=" + id;
            DataBase          db           = new DataBase();
            DataSet           deviceDs     = db.GetDataSet(queryString);

            if (deviceDs.Tables[0].Rows.Count > 0)
            {
                backupDevice = new BackupDeviceModel();
                DataRow dr = deviceDs.Tables[0].Rows[0];
                backupDevice.setTypeId(Convert.ToInt32(dr["typeId"]));
                backupDevice.setDeviceName(dr["deviceName"].ToString());
                backupDevice.setDeviceModel(dr["deviceModel"].ToString());
                backupDevice.setPrice(Convert.ToSingle(dr["price"]));
                backupDevice.setDeviceFrom(dr["deviceFrom"].ToString());
                backupDevice.setManufacturer(dr["manufacturer"].ToString());
                backupDevice.setInDate(dr["inDate"].ToString());
                backupDevice.setOutDate(dr["outDate"].ToString());
                backupDevice.setStockCount(Convert.ToInt32(dr["stockCount"]));
                backupDevice.setInOperator(dr["inOperator"].ToString());
                backupDevice.setOutOperator(dr["outOperator"].ToString());
            }
            return(backupDevice);
        }
Exemplo n.º 2
0
        /*更新備用備件資訊*/

        public static bool UpdateDeviceModel(BackupDeviceModel backupDevice)
        {
            string updateSql = "update [t_device_backup] set ";

            updateSql += "typeId=" + backupDevice.getTypeId() + ",";
            updateSql += "deviceName=" + SqlString.GetQuotedString(backupDevice.getDeviceName()) + ",";
            updateSql += "deviceModel=" + SqlString.GetQuotedString(backupDevice.getDeviceModel()) + ",";
            updateSql += "price=" + backupDevice.getPrice() + ",";
            updateSql += "deviceFrom=" + SqlString.GetQuotedString(backupDevice.getDeviceFrom()) + ",";
            updateSql += "manufacturer=" + SqlString.GetQuotedString(backupDevice.getManufacturer()) + ",";
            updateSql += "inDate=" + SqlString.GetQuotedString(backupDevice.getInDate()) + ",";
            updateSql += "outDate=" + SqlString.GetQuotedString(backupDevice.getOutDate()) + ",";
            updateSql += "stockCount=" + backupDevice.getStockCount() + ",";
            updateSql += "inOperator=" + SqlString.GetQuotedString(backupDevice.getInOperator()) + ",";
            updateSql += "outOperator=" + SqlString.GetQuotedString(backupDevice.getOutOperator());
            updateSql += " where id=" + backupDevice.getId();

            DataBase db = new DataBase();

            if (db.InsertOrUpdate(updateSql) < 0)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        /*登記備用備件資訊*/

        public static bool AddBackupDevice(BackupDeviceModel backupDevice)
        {
            //string sqlString = string.Format("insert into [t_device_backup] (typeId,deviceName,deviceModel,price,deviceFrom,manufacturer,inDate,outDate,stockCount,inOperator,outOperator) values '{0}', '{1}', N'{2}', N'{3}', '{4}', N'{5}', N'{6}', '{7}', '{8}', N'{9}', N'{10}'",
            string sqlString = "insert into [t_device_backup] (typeId,deviceName,deviceModel,price,deviceFrom,manufacturer,inDate,outDate,stockCount,inOperator,outOperator) values (";

            sqlString += backupDevice.getTypeId() + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getDeviceName()) + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getDeviceModel()) + ",";
            sqlString += backupDevice.getPrice() + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getDeviceFrom()) + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getManufacturer()) + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getInDate()) + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getOutDate()) + ",";
            sqlString += backupDevice.getStockCount() + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getInOperator()) + ",";
            sqlString += SqlString.GetQuotedString(backupDevice.getOutOperator()) + ")";

            DataBase db = new DataBase();

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