void Add() { //create an instance of the Inventory Collenction clsInventoryCollection AllInventories = new clsInventoryCollection(); //validate the data on the web form string Error = AllInventories.ThisInventory.Valid(txtName.Text, txtPrice.Text, txtQuantity.Text, Convert.ToString(comboBoxCategory.SelectedItem), txtDateAdded.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user AllInventories.ThisInventory.Name = txtName.Text; AllInventories.ThisInventory.Price = Convert.ToDecimal(txtPrice.Text); AllInventories.ThisInventory.Quantity = Convert.ToInt32(txtQuantity.Text); AllInventories.ThisInventory.DateAdded = Convert.ToDateTime(txtDateAdded.Text); AllInventories.ThisInventory.Active = chkActive.Checked; AllInventories.ThisInventory.Category = Convert.ToString(comboBoxCategory.SelectedItem); AllInventories.ThisInventory.Description = Convert.ToString(txtDescription.Text); AllInventories.ThisInventory.ImagePath = Convert.ToString(txtImagePath.Text); //add the record AllInventories.Add(); //all done so redirect back to the main page InventoryManageForm IM = new InventoryManageForm(); this.Hide(); IM.ShowDialog(); this.Close(); } else { //report an error lblError.Text = "There were problems with the data entered : " + Error; } }
private void btnCancel_Click(object sender, EventArgs e) { InventoryManageForm IF = new InventoryManageForm(); this.Hide(); IF.ShowDialog(); this.Close(); }
private void btnNo_Click(object sender, EventArgs e) { //redirect to the main form InventoryManageForm InvManageForm = new InventoryManageForm(); this.Hide(); InvManageForm.ShowDialog(); this.Close(); }
private void btnYes_Click_1(object sender, EventArgs e) { string message = "The Inventory has been deleted successfully."; string caption = "Deletion Confirmation"; DialogResult result; MessageBoxButtons button = MessageBoxButtons.OK; result = MessageBox.Show(message, caption, button); if (result == DialogResult.OK) { //delete the record DeleteInventory(); //redirect to the main form InventoryManageForm InvManageForm = new InventoryManageForm(); this.Hide(); InvManageForm.ShowDialog(); this.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { clsInventoryCollection AllInventories = new clsInventoryCollection(); string Error = AllInventories.ThisInventory.Valid(txtName.Text, txtPrice.Text, txtQuantity.Text, Convert.ToString(comboBoxCategory.SelectedItem), txtDateAdded.Text); string message = "Are you sure to Update the existing Inventory?"; string caption = "User Confirmation!"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; //Displays the MessageBox //if there are no Errors returned if (Error == "") { //show the Message box result = MessageBox.Show(message, caption, buttons); //if "Yes" is pressed if (result == DialogResult.Yes) { //execute the Update method Update(); //create an instance of ManageInventoryForm InventoryManageForm mdiMF = new InventoryManageForm(); //hide the current form this.Hide(); //show the Manaage Inventory Form mdiMF.ShowDialog(); //close the current form this.Close(); } } else { //report an error lblError.Text = "There were problems with the data entered : " + Error; } }
public void Update() { //create an instance of the Inventory Collection clsInventoryCollection AllInventories = new clsInventoryCollection(); //validate the data on the Windows Form String Error = AllInventories.ThisInventory.Valid(txtName.Text, txtPrice.Text, txtQuantity.Text, Convert.ToString(comboBoxCategory.SelectedItem), txtDateAdded.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to UPDATE AllInventories.ThisInventory.Find(mInventoryId); //get the data entered by the user AllInventories.ThisInventory.Name = txtName.Text; AllInventories.ThisInventory.Price = Convert.ToDecimal(txtPrice.Text); AllInventories.ThisInventory.Quantity = Convert.ToInt32(txtQuantity.Text); AllInventories.ThisInventory.Category = Convert.ToString(comboBoxCategory.SelectedItem); AllInventories.ThisInventory.DateAdded = Convert.ToDateTime(txtDateAdded.Text); AllInventories.ThisInventory.Active = chkActive.Checked; AllInventories.ThisInventory.Description = txtDescription.Text; AllInventories.ThisInventory.ImagePath = txtImagePath.Text; //UPDATE the record AllInventories.Update(); //All Done so Redirect to the previous Form InventoryManageForm IF = new InventoryManageForm(); this.Hide(); IF.ShowDialog(); this.Close(); } else { lblError.Text = "There were problems with the data entered: " + Error; } }