//Returns one row from Database public dbRecord GetItemRecord(int id) { int weight; string category, brand, model, condition, location, notes; double purchasePric, sellingPrice; DateTime receivedDate, lastUpdated; dbRecord record = new dbRecord(); this.dataBase.GetItemRecord(id, out category, out brand, out model, out receivedDate, out weight , out condition, out location, out purchasePric, out sellingPrice, out notes , out lastUpdated); record.Brand = brand; record.Category = category; record.Condition = condition; record.LastUpdated = lastUpdated; record.Location = location; record.Model = model; record.Notes = notes; record.PurchasePrice = purchasePric; record.ReceivedDate = receivedDate; record.SellingPrice = sellingPrice; record.Weight = weight; record.ItemID = id; return(record); }
//Returns one row from Database public dbRecord GetItemRecord(int id) { int weight; string category, brand, model, condition, location, notes; double purchasePric,sellingPrice; DateTime receivedDate, lastUpdated; dbRecord record = new dbRecord(); this.dataBase.GetItemRecord(id, out category, out brand, out model, out receivedDate, out weight , out condition, out location, out purchasePric, out sellingPrice, out notes , out lastUpdated); record.Brand = brand; record.Category = category; record.Condition = condition; record.LastUpdated = lastUpdated; record.Location = location; record.Model = model; record.Notes = notes; record.PurchasePrice = purchasePric; record.ReceivedDate = receivedDate; record.SellingPrice = sellingPrice; record.Weight = weight; record.ItemID = id; return record; }
UpdateResponse m_updateFunction; //Delegate that Calls the update function from main form #endregion Fields #region Constructors /*Initialise the components and loads the data in textboxes, when it is the case*/ public DialogWindow(int option, dbRecord record, UpdateResponse updateFunction, IDataController data) { InitializeComponent(); m_updateFunction = updateFunction; m_option = option; m_record = record; m_data = data; LoadInformation(); }
public bool UpdateItemRecord(dbRecord itemRecord) { dbRecord previousRecord; previousRecord = GetItemRecord(itemRecord.ItemID); if (previousRecord.LastUpdated == itemRecord.LastUpdated) { this.dataBase.UpdateItemRecord(itemRecord.ItemID, itemRecord.Category, itemRecord.Brand, itemRecord.Model, itemRecord.ReceivedDate, itemRecord.Weight, itemRecord.Condition, itemRecord.Location, itemRecord.PurchasePrice, itemRecord.SellingPrice, itemRecord.Notes); return(true); } return(false); }
//Copy Constructor public dbRecord(dbRecord record) { this.Category = record.Category; this.Brand = record.Brand; this.Model = record.Model; this.ReceivedDate = record.ReceivedDate; this.Weight = record.Weight; this.Condition = record.Condition; this.Location = record.Location; this.PurchasePrice = record.PurchasePrice; this.SellingPrice = record.SellingPrice; this.Notes = record.Notes; this.LastUpdated = record.LastUpdated; this.ItemID = record.ItemID; }
/*Loads data from the record to textboxes*/ private void LoadInfo() { m_record = m_data.GetItemRecord(m_record.ItemID); txtBrand.Text = m_record.Brand; txtCategory.Text = m_record.Category; txtCondition.Text = m_record.Condition; txtId.Text = m_record.ItemID.ToString(); txtLocation.Text = m_record.Location; txtModel.Text = m_record.Model; rtbNotes.AppendText(m_record.Notes); txtPurshasePrice.Text = m_record.PurchasePrice.ToString(); txtReceivedDate.Text = m_record.ReceivedDate.ToString(); txtSellingPrice.Text = m_record.SellingPrice.ToString(); txtWeight.Text = m_record.Weight.ToString(); }
public int AddItemRecord(dbRecord itemRecord) { return(this.dataBase.AddItemRecord(itemRecord.Category, itemRecord.Brand, itemRecord.Model, itemRecord.ReceivedDate, itemRecord.Weight, itemRecord.Condition, itemRecord.Location, itemRecord.PurchasePrice, itemRecord.SellingPrice, itemRecord.Notes)); }
public int AddItemRecord(dbRecord itemRecord) { return this.dataBase.AddItemRecord(itemRecord.Category, itemRecord.Brand, itemRecord.Model, itemRecord.ReceivedDate, itemRecord.Weight, itemRecord.Condition, itemRecord.Location, itemRecord.PurchasePrice, itemRecord.SellingPrice, itemRecord.Notes); }
public bool UpdateItemRecord(dbRecord itemRecord) { dbRecord previousRecord; previousRecord = GetItemRecord(itemRecord.ItemID); if (previousRecord.LastUpdated == itemRecord.LastUpdated) { this.dataBase.UpdateItemRecord(itemRecord.ItemID, itemRecord.Category, itemRecord.Brand, itemRecord.Model, itemRecord.ReceivedDate, itemRecord.Weight, itemRecord.Condition, itemRecord.Location, itemRecord.PurchasePrice, itemRecord.SellingPrice, itemRecord.Notes); return true; } return false; }
/*Loads the data from textboxes to the record*/ private void SetRecord() { m_record = new dbRecord(); m_record.Brand = txtBrand.Text; m_record.Category = txtCategory.Text; m_record.Condition = txtCondition.Text; if (PageMode.Value == "Edit") { m_record.ItemID = Convert.ToInt32(ItemId.Value); m_record.LastUpdated = new DateTime(Convert.ToInt64(LastModified.Value)); } m_record.Location = txtLocation.Text; m_record.Model = txtModel.Text; m_record.Notes = txtNotes.Text; m_record.PurchasePrice = Convert.ToDouble(txtPurshasePrice.Text); m_record.ReceivedDate = Convert.ToDateTime(txtReceivedDate.Text); m_record.SellingPrice = Convert.ToDouble(txtSellingPrice.Text); m_record.Weight = Convert.ToInt32(txtWeight.Text); }
/*Loads data from the record to textboxes*/ private void LoadInfo() { m_record = new dbRecord(m_service.GetItemRecord(Convert.ToInt32(ItemId.Value))); txtID.Text = m_record.ItemID.ToString(); txtBrand.Text = m_record.Brand; txtCategory.Text = m_record.Category; txtCondition.Text = m_record.Condition; txtLocation.Text = m_record.Location; txtModel.Text = m_record.Model; txtPurshasePrice.Text = m_record.PurchasePrice.ToString(); txtReceivedDate.Text = m_record.ReceivedDate.ToString(); txtSellingPrice.Text = m_record.SellingPrice.ToString(); txtWeight.Text = m_record.Weight.ToString(); txtNotes.Text = m_record.Notes; /*Converts the date to ticks and then store it. When date is converted to string the ticks differ from the original date, although date, hour, minutes and seconds are equal*/ LastModified.Value = m_record.LastUpdated.Ticks.ToString(); }
//Updates a row in database. Returns true in success or false in fail. public bool UpdateItemRecord(dbRecord itemRecord) { return m_data.UpdateItemRecord(itemRecord); }
//Adds a new row in database and returns its ID public int AddItemRecord(dbRecord itemRecord) { return m_data.AddItemRecord(itemRecord); }