public void UpdateConsignor() { // SETUP ConsignorClasses.Consignor c = new Consignor(); ConsignorClasses.ConsignorUtilities u = new ConsignorUtilities(); c.Address1City = testAddressCity; c.Address1State = testAddressState; c.Address1Street = testStreet; c.Address1Zip = testZip; c.CellPhone = testCell; c.Comments = testComments; c.ConsignorID = GetMaxConsignorID(); c.Donate = true; c.EmailAddress = testEmail; c.FirstName = testUpdatedFirstName; c.HomePhone = testHomePhone; c.LastName = testUpdatedLastName; c.WorkPhone = testWorkPhone; // TRIGGER bool updateResult = u.Consignor_Update(c); ConsignorClasses.Consignor updated = new Consignor(); updated = u.GetExistingConsignor(GetMaxConsignorID()); // VALIDATE Assert.AreEqual(true, updateResult, "expected different result"); Assert.AreEqual(c.LastName, updated.LastName, "expected same updated last name"); Assert.AreEqual(c.FirstName, updated.FirstName, "expected same updated first name"); }
public void AddConsignor() { // SETUP int nextConsignor = GetMaxConsignorID() + 1; ConsignorClasses.Consignor c = new Consignor(); ConsignorClasses.ConsignorUtilities u = new ConsignorUtilities(); c.Address1City = testAddressCity; c.Address1State = testAddressState; c.Address1Street = testStreet; c.Address1Zip = testZip; c.CellPhone = testCell; c.Comments = testComments; c.ConsignorID = 0; c.Donate = true; c.EmailAddress = testEmail; c.FirstName = testFirstName; c.HomePhone = testHomePhone; c.LastName = testLastName; c.WorkPhone = testWorkPhone; // TRIGGER int newConsignorID = u.AddNewConsignor(c); // VALIDATE Assert.AreEqual(nextConsignor, newConsignorID, "expected different number"); }
private bool ConsignorUpdate() { ConsignorClasses.Consignor c = new ConsignorClasses.Consignor(); ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); // set the updated consignor c.Address1City = txtCity.Text; c.Address1State = txtState.Text; c.Address1Street = txtAddress.Text; c.Address1Zip = txtZipCode.Text; c.CellPhone = txtCellPhone.Text; c.Comments = txtComments.Text; c.ConsignorID = int.Parse(txtConsignorID.Text); c.Donate = ckDonate.Checked; c.EmailAddress = txtemail.Text; c.FirstName = txtFirstName.Text; c.HomePhone = txtHomePhone.Text; c.LastName = txtLastName.Text; c.WorkPhone = txtWorkPhone.Text; // update the consignor bool result = cu.Consignor_Update(c); ClearConsignor(); return result; }
/// <summary> /// Navigate to the report when list box items have been selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdGo_Click(object sender, EventArgs e) { if (listBox1.SelectedItems.Count != 0) { List<string> collection = ParseSelectedItems(listBox1.SelectedItems); string sqlParams = ConvertToSqlParam(collection); ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); ConsignorClasses.Consignor c = new ConsignorClasses.Consignor(); c = cu.GetExistingConsignor(GlobalClass.ConsignerID); ConsignorID = c.ConsignorID; LoadReport(c.ConsignorID, sqlParams); } }
/// <summary> /// validations /// </summary> /// <returns></returns> private bool DoValidations() { if (txtConsignerID.Text == "") { return false; } if (txtConsignerID.Text != "") { try { int itest = int.Parse(txtConsignerID.Text.ToString()); } catch { return false; } } // valid consignor? ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); if (!cu.ValidConsignor(txtConsignerID.Text)) { return false; } // NOW test the data grid if (dgInventory.Rows.Count == 1) { return false; } for (int iRow = 0; iRow < dgInventory.Rows.Count -1; iRow++) { if (dgInventory[0, iRow].Value == null) { return false; } try { decimal dTest = decimal.Parse(dgInventory[1, iRow].Value.ToString()); } catch { return false; } } return true; }
/// <summary> /// load the active only to start /// </summary> private void LoadActiveOnly() { string sqlParams = ConvertToSqlParam(ActiveOnlyStatus); ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); ConsignorClasses.Consignor c = new ConsignorClasses.Consignor(); c = cu.GetExistingConsignor(GlobalClass.ConsignerID); ConsignorID = c.ConsignorID; LoadReport(c.ConsignorID, sqlParams); }
/// <summary> /// load up the report /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Report_ConsignorDetailReport_Load(object sender, EventArgs e) { this.soldStatus_Select1TableAdapter.Fill(this.doubletakeDataSet.SoldStatus_Select1); ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); ConsignorClasses.Consignor c = new ConsignorClasses.Consignor(); c = cu.GetExistingConsignor(GlobalClass.ConsignerID); ConsignorID = c.ConsignorID; lblConsignorName.Text = string.Format("{0} {1}", c.FirstName, c.LastName); // check if this is coming from the right click on the search if (string.IsNullOrEmpty(GlobalClass.WhateverString)) { listBox1.SelectedItems.Clear(); } else { LoadReport(c.ConsignorID, GlobalClass.WhateverString); } }
private void NewConsignorInsert() { int count; ConsignorClasses.ConsignorUtilities cu = new ConsignorClasses.ConsignorUtilities(); ConsignorClasses.Consignor c = new ConsignorClasses.Consignor(); c.LastName = txtLastName.Text; c.FirstName = txtFirstName.Text; c.Address1Street = txtAddress.Text; c.Address1City = txtCity.Text; c.Address1State = txtState.Text; c.Address1Zip = txtZipCode.Text; c.HomePhone = txtHomePhone.Text; c.WorkPhone = txtWorkPhone.Text; c.CellPhone = txtCellPhone.Text; c.EmailAddress = txtemail.Text; c.Comments = txtComments.Text; c.Donate = ckDonate.Checked; c.CreateBy = "NewConsignor"; count = cu.AddNewConsignor(c); switch (count) { case -1: MessageBox.Show("There was a SQL Data Error", Properties.Settings.Default.MessageBoxTitle, MessageBoxButtons.OK); break; case -2: MessageBox.Show("C# Error", Properties.Settings.Default.MessageBoxTitle, MessageBoxButtons.OK); break; default: txtConsignorID.Visible = true; txtConsignorID.Text = count.ToString(); txtConsignorID.Enabled = false; ClearConsignor(); break; } }
private void GetConsignor(int ConsignorID) { ConsignorClasses.ConsignorUtilities u = new ConsignorClasses.ConsignorUtilities(); var returnedConsignor = new ConsignorClasses.Consignor(); returnedConsignor = u.GetExistingConsignor(ConsignorID); // check for C# exceptions if (returnedConsignor.LastName.Contains("SQL Exception")) { MessageBox.Show(returnedConsignor.Comments, "SQL Data Error", MessageBoxButtons.OK); ClearConsignor(); } else if (returnedConsignor.LastName.Contains("C# Exception")) { MessageBox.Show(returnedConsignor.Comments, "C# Error", MessageBoxButtons.OK); ClearConsignor(); } else { txtConsignorID.Text = ConsignorID.ToString(); txtLastName.Text = returnedConsignor.LastName; txtFirstName.Text = returnedConsignor.FirstName; txtAddress.Text = returnedConsignor.Address1Street; txtCity.Text = returnedConsignor.Address1City; txtState.Text = returnedConsignor.Address1State; txtZipCode.Text = returnedConsignor.Address1Zip; txtHomePhone.Text = returnedConsignor.HomePhone; txtWorkPhone.Text = returnedConsignor.WorkPhone; txtCellPhone.Text = returnedConsignor.CellPhone; txtemail.Text = returnedConsignor.EmailAddress; txtComments.Text = returnedConsignor.Comments; ckDonate.Checked = returnedConsignor.Donate; } ClearConsignor(); }