public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();
            //create th item of the data
            clsSupplier TestItem = new clsSupplier();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Active            = true;
            TestItem.Supplier_Address  = "Some Supplier Address ";
            TestItem.CountyNo          = 1;
            TestItem.Supplier_Email    = "*****@*****.**";
            TestItem.Supplier_Id       = 001;
            TestItem.Supplier_Name     = "Game.net";
            TestItem.Supplier_Phone_No = "07331415589";
            //set ThisSupplier to the test data
            AllSuppliers.ThisSupplier = TestItem;
            //add record
            PrimaryKey = AllSuppliers.Add();
            //set the primary key of the test data
            TestItem.Supplier_Id = PrimaryKey;
            //find the record
            AllSuppliers.ThisSupplier.Find(PrimaryKey);
            //Test to see that the two values are the same
            Assert.AreEqual(AllSuppliers.ThisSupplier, TestItem);
        }
        public void AddMethodOK()
        {
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();
            clsSupplier           TestItem     = new clsSupplier();
            Int32 PrimaryKey = 0;

            TestItem.SupplierID        = 1;
            TestItem.Address           = "1b";
            TestItem.City              = "Birmingham";
            TestItem.County            = "eastmidlands";
            TestItem.DateAdded         = System.DateTime.Now.Date;
            TestItem.Mobile            = "078";
            TestItem.Name              = "Mark";
            TestItem.Postcode          = "CV6";
            TestItem.PositionInCompany = "1bbbbbbbbbbbbbbbbbbbbbb25";
            TestItem.SupplierName      = "Audi";
            TestItem.Title             = "Mr";
            TestItem.WorkExt           = "312";
            TestItem.WorkNumber        = "12134";
            TestItem.SupplierEmail     = "*****@*****.**";
            AllSuppliers.ThisSupplier  = TestItem;
            PrimaryKey          = AllSuppliers.Add();
            TestItem.SupplierID = PrimaryKey;
            AllSuppliers.ThisSupplier.Find(PrimaryKey);
            Assert.AreEqual(AllSuppliers.ThisSupplier, TestItem);
        }
        public void UpdateMethodOK()
        {
            clsSupplierCollection Suppliers = new clsSupplierCollection();

            clsSuppliers Supplier1 = new clsSuppliers();

            Int32 PrimaryKey = 1;

            Supplier1.Active       = true;
            Supplier1.Address      = "64 Zoo Lane";
            Supplier1.Email        = "*****@*****.**";
            Supplier1.LastDelivery = DateTime.Now.Date;
            Supplier1.Name         = "WotC";
            Supplier1.ID           = PrimaryKey;

            Suppliers.ThisSupplier = Supplier1;
            PrimaryKey             = Suppliers.Add();

            Supplier1.ID = PrimaryKey;
            Suppliers.ThisSupplier.Find(PrimaryKey);

            Supplier1.ID = PrimaryKey;

            Supplier1.Active       = true;
            Supplier1.Address      = "65 Zoo Lane";
            Supplier1.Email        = "*****@*****.**";
            Supplier1.LastDelivery = DateTime.Now.Date;
            Supplier1.Name         = "Konami";
            Supplier1.ID           = PrimaryKey;

            Suppliers.ThisSupplier = Supplier1;
            Suppliers.Update();
            Suppliers.ThisSupplier.Find(PrimaryKey);
            Assert.AreEqual(Suppliers.ThisSupplier, Supplier1);
        }
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();
            //create th item of the data
            clsSupplier TestItem = new clsSupplier();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Active            = true;
            TestItem.Supplier_Address  = "Some Supplier Address ";
            TestItem.CountyNo          = 1;
            TestItem.Supplier_Email    = "*****@*****.**";
            TestItem.Supplier_Id       = 001;
            TestItem.Supplier_Name     = "Game.net";
            TestItem.Supplier_Phone_No = "07331415589";
            //set ThisSupplier to the test data
            AllSuppliers.ThisSupplier = TestItem;
            //add record
            PrimaryKey = AllSuppliers.Add();
            //set the primary key of the test data
            TestItem.Supplier_Id = PrimaryKey;
            //find the record
            AllSuppliers.ThisSupplier.Find(PrimaryKey);
            //delete record
            AllSuppliers.Delete();
            //now find the record
            Boolean Found = AllSuppliers.ThisSupplier.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
        public void DeleteMethodOK()
        {
            clsSupplierCollection Suppliers = new clsSupplierCollection();

            clsSuppliers Supplier1 = new clsSuppliers();

            Int32 PrimaryKey = 0;

            Supplier1.Active       = true;
            Supplier1.Address      = "64 Zoo Lane";
            Supplier1.Email        = "*****@*****.**";
            Supplier1.LastDelivery = DateTime.Now.Date;
            Supplier1.Name         = "WotC";
            Supplier1.ID           = PrimaryKey;

            Suppliers.ThisSupplier = Supplier1;
            PrimaryKey             = Suppliers.Add();

            Supplier1.ID = PrimaryKey;
            Suppliers.ThisSupplier.Find(PrimaryKey);

            Suppliers.DeleteSupplier();
            Boolean Found = Suppliers.ThisSupplier.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
    void Add() //function for adding new records
    {
        //Create instance in Supplier collection class
        clsSupplierCollection Suppliers = new clsSupplierCollection();
        //validate the data on the web form
        Boolean OK = Suppliers.ThisSupplier.Valid(txtAddress.Text, txtCity.Text, txtCounty.Text, txtDateAdded.Text, txtMobile.Text, txtName.Text, txtPostcode.Text, txtPositionInCompany.Text, txtSupplierName.Text, txtTitle.Text, txtWorkExt.Text, txtWorkNumber.Text, txtSupplierEmail.Text);

        //if the data is ok then add it to the object
        if (OK == true)
        {
            Suppliers.ThisSupplier.Address           = txtAddress.Text;
            Suppliers.ThisSupplier.City              = txtCity.Text;
            Suppliers.ThisSupplier.County            = txtCounty.Text;
            Suppliers.ThisSupplier.DateAdded         = Convert.ToDateTime(txtDateAdded.Text);
            Suppliers.ThisSupplier.Mobile            = txtMobile.Text;
            Suppliers.ThisSupplier.Name              = txtName.Text;
            Suppliers.ThisSupplier.Postcode          = txtPostcode.Text;
            Suppliers.ThisSupplier.PositionInCompany = txtPositionInCompany.Text;
            Suppliers.ThisSupplier.SupplierName      = txtSupplierName.Text;
            Suppliers.ThisSupplier.Title             = txtTitle.Text;
            Suppliers.ThisSupplier.WorkExt           = txtWorkExt.Text;
            Suppliers.ThisSupplier.WorkNumber        = txtWorkNumber.Text;
            Suppliers.ThisSupplier.SupplierEmail     = txtSupplierEmail.Text;

            //add the record
            Suppliers.Add();
            Response.Redirect("SupplierHomepage.aspx");
        }
        else
        {
            //Report error
            lblErrorMessageAdd.Text = "there were problems with the data entered";
        }
    }
Example #7
0
        public void AddMethodOK()
        {
            clsSupplierCollection AllSupplier = new clsSupplierCollection();
            clsSupplier           TestItem    = new clsSupplier();
            Int32 PrimaryKey = 0;

            TestItem.SupplierID      = 1;
            TestItem.CompanyName     = "teesLTD";
            TestItem.Product         = "tShirts";
            TestItem.PhoneNumber     = "07456332127";
            TestItem.EmailAddress    = "*****@*****.**";
            TestItem.Address         = "101 Second Avenue";
            TestItem.PostCode        = "LE1 1ST";
            AllSupplier.ThisSupplier = TestItem;
            PrimaryKey          = AllSupplier.Add();
            TestItem.SupplierID = PrimaryKey;
            AllSupplier.ThisSupplier.Find(PrimaryKey);
            Assert.AreEqual(AllSupplier.ThisSupplier, TestItem);
        }
Example #8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        clsSuppliers ASupplier = new clsSuppliers();

        string Name         = txtName.Text;
        string Address      = txtAddress.Text;
        string Email        = txtEmail.Text;
        string LastDelivery = txtDelivery.Text;

        string Error = "";

        Error = ASupplier.Valid(Name, Email, Address, LastDelivery);


        if (Error == "")
        {
            ASupplier.Name         = Name;
            ASupplier.Address      = Address;
            ASupplier.Email        = Email;
            ASupplier.LastDelivery = Convert.ToDateTime(LastDelivery);
            ASupplier.Active       = cbxActive.Checked;

            clsSupplierCollection SupplierList = new clsSupplierCollection();

            if (ID == -1)
            {
                SupplierList.ThisSupplier = ASupplier;
                SupplierList.Add();
            }
            else
            {
                SupplierList.ThisSupplier.Find(ID);
                SupplierList.ThisSupplier = ASupplier;
                SupplierList.Update();
            }

            Response.Redirect("SupplierList.aspx");
        }
        else
        {
            lblResult.Text = Error;
        }
    }
Example #9
0
        public void DeleteMethodOK()
        {
            clsSupplierCollection AllSupplier = new clsSupplierCollection();
            clsSupplier           TestItem    = new clsSupplier();
            Int32 PrimaryKey = 0;

            //data to delete
            TestItem.CompanyName     = "teesLTD";
            TestItem.Product         = "tShirts";
            TestItem.PhoneNumber     = "07456332127";
            TestItem.EmailAddress    = "*****@*****.**";
            TestItem.Address         = "101 Second Avenue";
            TestItem.PostCode        = "LE1 1ST";
            AllSupplier.ThisSupplier = TestItem;
            PrimaryKey          = AllSupplier.Add();
            TestItem.SupplierID = PrimaryKey;
            AllSupplier.ThisSupplier.Find(PrimaryKey);
            AllSupplier.Delete();
            Boolean Found = AllSupplier.ThisSupplier.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }