public clsCostumerCollection() { Int32 Index = 0; Int32 RecordCount = 0; clsDataConnection DB = new clsDataConnection(); DB.Execute("sproc_tblCostumer_SelectAll"); RecordCount = DB.Count; while (Index < RexordCount) { clsCostumerCollection ACostumer = new clsCostumerCollection(); ACostumer.Active = Convert.ToBoolean(DB.DataTable.Rows[Index]["Active"]); ACostumer.CostumerID = Convert.ToInt32(DB.DataTable.Rows[Index]["CostumerID"]); ACostumer.CostumerDOB = Convert.ToDateTime(DB.DataTable.Rows[Index]["CostumerDOB"]); ACostumer.CostumerAddress = Convert.ToString(DB.DataTable.Rows[Index]["CostumerAddress"]); ACostumer.Name = Convert.ToString(DB.DataTable.Rows[Index]["Name"]); ACostumer.Email = Convert.ToString(DB.DataTable.Rows[Index]["Email"]); mCostumerList.Add(ACostumer); Index++; } }
//function for adding new records void Add() { //create an instance of the address book clsCostumerCollection AddressBook = new clsCostumerCollection(); //validate the data on the web form String Error = AddressBook.ThisAddress.Valid(txtCostumerID Text, txtName Text, txtCostumerAddress Text, txtCostumerDOB Text, txtEmail Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user clsCostumerCollection AddressBook = new clsCostumerCollection(); txtCostumerID.Text = ACostumer.CostumerID.ToString(); txtName.Text = ACostumer.Name.ToString(); txtCostumerAddress.Text = ACostumer.CostumerAddress.ToString(); txtCostumerDOB.Text = ACostumer.CostumerDOB.ToString(); txtEmail.Text = ACostumer.Email.ToString(); //add the record AddressBook.Add(); //all done so redirect back to the main page Response.Redirect("CostumerList.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
protected void DeleteAddress() { clsCostumerCollection CostumerList = new clsCostumerCollection(); CostumerList.ThisCostumer.Find(CostumerID); ACostumer.Delete(); }
protected void btnYes_Click(object sender, EventArgs e) { clsCostumerCollection CostumerList = new clsCostumerCollection(); CostumerList.ThisCostumer.Find(CostumerID); CostumerList.Delete(); Response.Redirect("CostumerList.aspx"); }
public void ReportByNameMethodOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); clsCostumerCollection FilteredCostumer = new clsCostumerCollection(); FilteredCostumer.ReportByName(""); Assert.AreEqual(AllCostumer.Count, FilteredCostumer.Count); }
public void CountPropertyOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); Int32 SomeCount = 2; AllCostumers.Count = SomeCount; Assert.AreEqual(AllCostumers.Count, SomeCount); }
protected void btnApply_Click(object sender, EventArgs e) { clsCostumerCollection CostumerList = new clsCostumerCollection(); CostumerList.ReportByName(txtfilter.Text); lstCostumerList.DataSource = StaffList.StaffList; lstCostumerList.DataValueField = "CostumerID"; lstCostumerList.DataValueField = "Name"; lstCostumerList.DataBind(); }
protected void btnClear_Click(object sender, EventArgs e) { clsCostumerCollection CostumerList = new clsCostumerCollection(); CostumerList.ReportByName(""); txtfilter.Text = ""; lstCostumerList.DataSource = CostumerList.CostumerList; lstCostumerList.DataValueField = "CostumerID"; lstCostumerList.DataValueField = "Name"; lstCostumerList.DataBind(); }
void DisplayCostumer() { clsCostumerCollection ACostumer = new clsCostumerCollection(); lstCostumerList.DataSource = Costumer.CostumerList; lstCostumerList.DataValueField = "CostumerID"; lstCostumerList = "Name"; lstCostumerList.DataBind(); }
void DisplayCostumer() { //create an instance of the address book clsCostumerCollection AddressBook = new clsCostumerCollection(); //find the record to update AddressBook.ThisCostumer.Find(CostumerID); //display the data for this record clsCostumerCollection AddressBook = new clsCostumerCollection(); txtCostumerID.Text = ACostumer.CostumerID.ToString(); txtName.Text = ACostumer.Name.ToString(); txtCostumerAddress.Text = ACostumer.CostumerAddress.ToString(); txtCostumerDOB.Text = ACostumer.CostumerDOB.ToString(); txtEmail.Text = ACostumer.Email.ToString(); }
public void ThisCostumerPropertyOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); clsCostumer TestCostumer = new clsCostumer(); TestItem.Active = true; TestItem.CostumerID = 1; TestItem.CostumerDOB = DateTime.Now.Date; TestItem.CostumerAddress = "22 Grange Lane LE2 7NX"; TestItem.Name = "Natalia Stylianou"; TestItem.Email = "*****@*****.**"; AllCostumers.ThisCostumer = TestCostumer; Assert.AreEqual(AllCostumers.ThisCostumer, TestCostumer); }
public void ReportByNameTestDataFoundOK() { clsCostumerCollection FilteredCostumer = new clsCostumerCollection(); Boolean OK = true; FilteredCostumer.ReportByName("James Smith"); if (FilteredCostumer.Count == 1) { if (FilteredCostumer.CostumerList[0].ID != 1) { OK = false; } } else { OK = false; } Assert.IsTrue(OK); }
public void AddMethodOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); clsCostumer TestItem = new clsCostumer(); int PrimaryKey = 0; TestCostumer.CostumerID = 1; TestCostumer.Name = "James"; TestCostumer.CostumerAddress = "40 Glenfield Road"; TestCostumer.CostumerDOB = DateTime.Now.Date; TestCostumer.Email = "*****@*****.**"; TestCostumer.Active = true; AllCostumers.ThisCostumer = TestItem; PrimaryKey = AllCostumers.Add(); AllCostumers.ThisCostumer.Find(PrimaryKey); Assert.AreEqual(AllCostumers.ThisCostumer, TestItem); }
public void DeleteMethodOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); clsCostumer TestCostumer = new clsCostumer(); int PrimaryKey = 0; TestCostumer.CostumerID = 1; TestCostumer.Name = "James"; TestCostumer.CostumerAddress = "40 Glenfield Road"; TestCostumer.CostumerDOB = DateTime.Now.Date; TestCostumer.Email = "*****@*****.**"; TestCostumer.Active = true; PrimaryKey = AllCostumers.Add(); TestCostumer.CostumerID = PrimaryKey; AllCostumers.ThisCostumer.Find(PrimaryKey); AllCostumers.Delete(); Boolean Found = AllCostumers.ThisCostumer.Find(PrimaryKey); Assert.IsFalse(Found); }
public void CostumerListOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); List <clsCostumer> TestList = new List <clsCostumer>(); clcCostumer TestItem = new clsCostumer(); TestItem.Active = true; TestItem.CostumerID = 1; TestItem.CostumerDOB = DateTime.Now.Date; TestItem.CostumerAddress = "22 Grange Lane LE2 7NX"; TestItem.Name = "Natalia Stylianou"; TestItem.Email = "*****@*****.**"; TestList.add(TestItem); AllCostumers.CostumerList = TestList; Assert.AreEqual(AllCostumers.CostumerList, TestList); }
public void InstanceOK() { clsCostumerCollection AllCostumers = new clsCostumerCollection(); Assert.IsNotNull(AllCostumers); }