/*登記備用備件資訊*/ 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); }
/*更新備用備件資訊*/ 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); }
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(); } }