public void InstanceOk() { //creates a instance of the class we want to create clsParts aPart = new clsParts(); //test to see if it exists Assert.IsNotNull(aPart); }
protected void Page_Load(object sender, EventArgs e) { //create a new instance of clsParts clsParts aPart = new clsParts(); //get data from session object aPart = (clsParts)Session["aPart"]; //display part description for this entry Response.Write(aPart.PartDescription); }
public void PriceOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property double testData = 155.99; //assign data to property aPart.Price = testData; //test the two values are the same Assert.AreEqual(aPart.Price, testData); }
public void PartTypeOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property String testData = "Motherboard"; //assign data to property aPart.PartType = testData; //test the two values are the same Assert.AreEqual(aPart.PartType, testData); }
public void PartDescriptionOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property String testData = "asus b450-m mini itx motherboard"; //assign data to property aPart.PartDescription = testData; //test the two values are the same Assert.AreEqual(aPart.PartDescription, testData); }
public void PartIdOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property Int32 testData = 123456; //assign data to property aPart.PartId = testData; //test the two values are the same Assert.AreEqual(aPart.PartId, testData); }
public void DateAddedPropertyOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property DateTime testData = DateTime.Now.Date; //assign data to property aPart.DateAdded = testData; //test the two values are the same Assert.AreEqual(aPart.DateAdded, testData); }
public void AvailablePropertyOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property Boolean testData = true; //assign data to property aPart.Available = testData; //test the two values are the same Assert.AreEqual(aPart.Available, testData); }
public void WattageOk() { //create instance of class clsParts aPart = new clsParts(); //create test data to assign to the property Int32 testData = 85; //assign data to property aPart.Wattage = testData; //test the two values are the same Assert.AreEqual(aPart.Wattage, testData); }
public void FindMethodOk() { //new instance clsParts aPart = new clsParts(); //boolean variable soring validation results Boolean found = false; //create test data Int32 partId = 123456; //invoke method found = aPart.Find(partId); //test if true Assert.IsTrue(found); }
public void TestAvailableFound() { //new instance clsParts aPart = new clsParts(); //boolean variable soring validation results Boolean found = false; //boolean recording if data is ok Boolean ok = true; //create test data Int32 partId = 21; //invoke method found = aPart.Find(partId); //check PartId if (aPart.Available != true) { ok = false; } //test if true Assert.IsTrue(ok); }
public void TestDateAddedFound() { //new instance clsParts aPart = new clsParts(); //boolean variable soring validation results Boolean found = false; //boolean recording if data is ok Boolean ok = true; //create test data Int32 partId = 21; //invoke method found = aPart.Find(partId); //check PartId if (aPart.DateAdded != Convert.ToDateTime("01/01/2001")) { ok = false; } //test if true Assert.IsTrue(ok); }
protected void btnOk_Click(object sender, EventArgs e) { //create new instance of parts clsParts aPart = new clsParts(); //capture PartId aPart.PartId = Convert.ToInt32(txtPartId.Text); //capture PartDescription aPart.PartDescription = txtPartDescription.Text; //capture PartType aPart.PartType = txtPartType.Text; //capture Price aPart.Price = Convert.ToDouble(txtPrice.Text); //capture DateAdded aPart.DateAdded = Convert.ToDateTime(txtDateAdded); //capture wattage aPart.Wattage = Convert.ToInt32(txtWattage); //capture availability aPart.Available = Convert.ToBoolean(chkAvailable.Checked); //store the description in the session object Session["aPart"] = aPart; //Navigate to viewer page Response.Redirect("PartsViewer.aspx"); }
protected void cmdDelete_Click(object sender, EventArgs e) { clsParts DB = new clsParts(); try { // txtCode, txtDesc, txtUnitPrice, cboSupplierID, txtManuDate, txtExpireDate if (txtCode.Text == null) { lblResults.Text = "Please enter the part code"; return; } if (txtDesc.Text == null) { lblResults.Text = "Enter the part name"; return; } if (txtUnitPrice.Text == null) { lblResults.Text = "Enter the unit price"; return; } if (txtUnitPrice.GetType() != typeof(Decimal)) { lblResults.Text = "Enter the monetary unit price"; return; } if (cboSupplierID.Text == null) { lblResults.Text = "Select the supplier"; return; } if (txtManuDate.GetType() != typeof(DateTime)) { lblResults.Text = "Enter a valid license manufacture date"; return; } if (txtExpireDate.GetType() != typeof(DateTime)) { lblResults.Text = "Enter a valid license expiry date"; return; } DB.Delete_rec(txtCode.Text, txtDesc.Text, Decimal.Parse(txtUnitPrice.Text), cboSupplierID.Text, DateTime.Parse(txtManuDate.SelectedDate.ToString()), DateTime.Parse(txtExpireDate.SelectedDate.ToString())); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; txtCode.Text = ""; txtDesc.Text = ""; txtUnitPrice.Text = "0"; cboSupplierID.Text = ""; return; } catch (FormatException err) { EventLog log = new EventLog(); log.Source = "Milorry Transport Frontend"; log.WriteEntry(err.Message, EventLogEntryType.Error); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtPN.Text.Trim())) { MetroFramework.MetroMessageBox.Show(this, "One or more Field(s) Empty.....", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!string.IsNullOrEmpty(txtID.Text)) { //update if (Exist() == true) { clsParts x = new clsParts(); x.ID = Convert.ToInt32(txtID.Text.Trim()); x.PartName = Convert.ToString(txtPN.Text.Trim()); x.PartType = Convert.ToInt32(ddlPT.SelectedValue); x.SUID = Convert.ToInt32(ddlSN.SelectedValue); x.StockLevel = Convert.ToInt32(txtSL.Text.Trim()); x.MinStockLevel = Convert.ToInt32(txtMSL.Text.Trim()); x.CostPrice = Convert.ToDouble(txtCP.Text.Trim()); x.SellingPrice = Convert.ToDouble(txtSP.Text.Trim()); x.Discount = Convert.ToDouble(txtD.Text.Trim()); x.Location = Convert.ToString(txtL.Text.Trim()); x.Remarks = Convert.ToString(txtR.Text.Trim()); int r = clsParts.update(x); if (r > 0) { ResetTextFields(); loadData(); MetroFramework.MetroMessageBox.Show(this, "Hurray Record Successfully Updated.....", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "An Error Occured While Updating Record.....", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MetroFramework.MetroMessageBox.Show(this, "This record does not Exist in the Database......", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //insert clsParts x = new clsParts(); x.PartName = Convert.ToString(txtPN.Text.Trim()); x.PartType = Convert.ToInt32(ddlPT.SelectedValue); x.SUID = Convert.ToInt32(ddlSN.SelectedValue); x.StockLevel = Convert.ToInt32(txtSL.Text.Trim()); x.MinStockLevel = Convert.ToInt32(txtMSL.Text.Trim()); x.CostPrice = Convert.ToDouble(txtCP.Text.Trim()); x.SellingPrice = Convert.ToDouble(txtSP.Text.Trim()); x.Discount = Convert.ToDouble(txtD.Text.Trim()); x.Location = Convert.ToString(txtL.Text.Trim()); x.Remarks = Convert.ToString(txtR.Text.Trim()); int r = clsParts.insert(x); if (r > 0) { ResetTextFields(); loadData(); MetroFramework.MetroMessageBox.Show(this, "Hurray Record Successfully Inserted.....", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "An Error Occured While Inserting Record.....", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }