示例#1
0
        public void DateAddedInvalidData()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //String variable to store any error message
            String Error = "";
            //Set the DateAdded to a non date value
            string DateAdded = "this is not a date!";

            //Invoke the method
            Error = AnManufacturer.Valid(ManufacturerNo, ManufacturerName, Address, PostCode, Town, TelephoneNo, Email, DateAdded);
            //Test to see that the results is correct
            Assert.AreNotEqual(Error, "");
        }
示例#2
0
        public void FindMethodOk()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //Boolean variable to store the result of the validation
            Boolean Found = false;
            //Create some test data to use with the method
            Int32 ManufacturerNo = 1;

            //Invoke the method
            Found = AnManufacturer.Find(ManufacturerNo);
            //Test to see that the result is correct
            Assert.IsTrue(Found);
        }
示例#3
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            //create an instance of the address page class
            clsManufacturer ThisManufacturer = new clsManufacturer();
            //var to store any error message
            string ErrorMessage;

            //test the data on teh web form
            ErrorMessage = ThisManufacturer.Valid(
                txtManufacturerName.Text,
                txtManufacturerTelephone.Text,
                txtManufacturerEmail.Text);


            //if there is no error message
            if (ErrorMessage == "")
            {
                //create a new instance of the address book class
                clsManufacturerCollection Manufacturer = new clsManufacturerCollection();
                //do something with the data - insert or update
                //
                //if the Laptop Number is -1
                if (ManufacturerNo == -1)
                {
                    //copy the data from the interface to the object;
                    Manufacturer.ThisManufacturer.ManufacturerName      = txtManufacturerName.Text;
                    Manufacturer.ThisManufacturer.ManufacturerTelephone = txtManufacturerTelephone.Text;
                    Manufacturer.ThisManufacturer.ManufacturerEmail     = txtManufacturerEmail.Text;
                    //add the new record
                    Manufacturer.Add();
                }
                else
                {
                    //this is an existing record
                    //copy the data from the interface to the object
                    Manufacturer.ThisManufacturer.ManufacturerName      = txtManufacturerName.Text;
                    Manufacturer.ThisManufacturer.ManufacturerTelephone = txtManufacturerTelephone.Text;
                    Manufacturer.ThisManufacturer.ManufacturerEmail     = txtManufacturerEmail.Text;
                    //update the existing record
                    Manufacturer.Update();
                }
                //redircet bact to the main page
                Response.Redirect("ManufacturerManagement.aspx");
            }
            else
            {
                //display the error message
                lblError.Text = ErrorMessage;
            }
        }
示例#4
0
        public void YearMadeInvalidData()
        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //string variable to store any error message
            String Error = "";
            //set the yearmade to a non date value
            string YearMade = "This is not a date";

            //invoke the methods
            Error = AnManufacturer.Valid(CarModel, ChairMan, Email, YearMade);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
示例#5
0
        public void EmailPlusOne()
        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //string variable to store any error message
            string Error = "";
            //this should pass
            string Email = "aa"; // this should be ok

            //invoke the method
            Error = AnManufacturer.Valid(CarModel, ChairMan, Email, YearMade);
            // test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#6
0
        public void ManufacturerNameMaxPlusOne()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //String variable to store any error message
            String Error = "";
            //This should fail
            string ManufacturerName = "";

            //Invoke the method
            Error = AnManufacturer.Valid(ManufacturerNo, ManufacturerName, Address, PostCode, Town, TelephoneNo, Email, DateAdded);
            //Test to see that the results is correct
            Assert.AreNotEqual(Error, "");
        }
示例#7
0
        public void FindMethodOK()
        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            // create some test data to use with the method
            Int32 ManufacturerID = 123;

            // invoke the method
            Found = AnManufacturer.Find(ManufacturerID);
            // test to see that the result is correct
            Assert.IsTrue(Found);
        }
示例#8
0
        //this function displays the data for a staff member on the web form
        void DisplayManufacturer(Int32 ManufacturerNo)
        {
            //create an instance of the laptops class
            clsManufacturer Manufacturer = new clsManufacturer();

            //find the record we want to display
            Manufacturer.Find(ManufacturerNo);
            //display title
            txtManufacturerName.Text = Manufacturer.ManufacturerName;
            //display fname
            txtManufacturerTelephone.Text = Manufacturer.ManufacturerTelephone;
            //display lname
            txtManufacturerEmail.Text = Manufacturer.ManufacturerEmail;
        }
示例#9
0
        public void ChairManMid()
        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //string variable to store any error message
            string Error = "";
            //this should fail
            string ChairMan = "";

            ChairMan = ChairMan.PadRight(18, 'a');
            //invoke the method
            Error = AnManufacturer.Valid(CarModel, ChairMan, Email, YearMade);
            // test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#10
0
        public void TownMid()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //String variable to store any error message
            String Error = "";
            //This should pass
            string Town = " ";

            Town = Town.PadRight(25, 'c');
            //Invoke the method
            Error = AnManufacturer.Valid(ManufacturerNo, ManufacturerName, Address, PostCode, Town, TelephoneNo, Email, DateAdded);
            //Test to see that the results is correct
            Assert.AreEqual(Error, "");
        }
    void LoadManufacturers()
    {
        clsManufacturer obj = new clsManufacturer();

        obj.Op = 4;
        DataTable dt = obj.ManufacturerMaster(obj).Tables[0];

        ddlManufacturer.DataSource      = dt;
        ddlEManufacturer.DataSource     = dt;
        ddlManufacturer.DataValueField  = "ID";
        ddlManufacturer.DataTextField   = "Name";
        ddlEManufacturer.DataValueField = "ID";
        ddlEManufacturer.DataTextField  = "Name";
        ddlManufacturer.DataBind();
        ddlEManufacturer.DataBind();
    }
        protected void cmdDelete2_Click(object sender, EventArgs e)
        {
            clsManufacturer DB = new clsManufacturer();

            try
            {
                if (txtManufacturerId1 == null)  //cboitem, lblUnitcost,txtquantity,txtregno,dtdate,txtAmount
                {
                    lblResults1.Text = "Enter the manufacturer";
                }
                if (txtManufacturerId1.GetType() != typeof(String))
                {
                    lblResults1.Text = "Enter the manufacturer";
                }


                if (txtManufacturerName0 == null)
                {
                    lblResults1.Text = "The Manufacturer cannot be empty";
                }
                if (txtManufacturerName0.GetType() != typeof(string))
                {
                    lblResults1.Text = "Enter the Manufacturer";
                }



                string varResponse = DB.Delete_rec(txtManufacturerId1.Text, txtManufacturerName0.Text);
                // Fill the DataSet.
                DataSet ds = new DataSet();
                ds = DB.FindTable();
                //adapter.Fill(ds, "tb_Customer");
                // Perform the binding.
                GridView11.DataSource = ds;
                GridView11.DataBind();

                lblResults1.Text = "Operation successful";
                return;
            }
            catch (FormatException err)
            {
                EventLog log = new EventLog();
                log.Source = "Milorry Frontend";
                log.WriteEntry(err.Message, EventLogEntryType.Error);
            }
        }
示例#13
0
        public void UpdateManufacturerMethodOk()
        {
            // Create instance of the class
            clsManufacturerCollection AllManufacturers = new clsManufacturerCollection();
            //Create the item of test data
            clsManufacturer TestItem = new clsManufacturer();

            //Variable to store the primary key
            //Int32 Primarykey = 0;
            //Set item properties
            TestItem.Check            = true;
            TestItem.DateAdded        = DateTime.Now.Date;
            TestItem.ManufacturerName = "Apple";
            TestItem.ManufacturerNo   = 1;
            TestItem.Address          = "40 Paynell Road";
            TestItem.PostCode         = "PE1 5ST";
            TestItem.Town             = "Peterborough";
            TestItem.TelephoneNo      = "01733389454";
            TestItem.Email            = "*****@*****.**";
            //St ThisManufacturer to the test data
            AllManufacturers.ThisManufacturer = TestItem;
            //Add the record
            PrimaryKey = AllManufacturers.Add();
            //Set the primary key to the test data
            TestItem.ManufacturerNo = PrimaryKey;
            //Modify the test data
            TestItem.Check            = false;
            TestItem.DateAdded        = DateTime.Now.Date;
            TestItem.ManufacturerName = "Apple";
            TestItem.ManufacturerNo   = 1;
            TestItem.Address          = "40 Paynell Road";
            TestItem.PostCode         = "PE1 5ST";
            TestItem.Town             = "Peterborough";
            TestItem.TelephoneNo      = "01733389454";
            TestItem.Email            = "*****@*****.**";
            //Set the record based on the new test data
            AllManufacturers.ThisManufacturer = TestItem;
            //Update the record
            AllManufacturers.Update();
            //Now find the record
            AllManufacturers.ThisManufacturer.Find(PrimaryKey);
            //Test to see ThisManufacturer matches the test data
            Assert.AreEqual(AllManufacturers.ThisManufacturer, TestItem);
        }
示例#14
0
        public void DateAddedMin()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //String variable to store any error message
            String Error = "";
            //Create a variable to store the test date data
            DateTime TestDate;

            //Set the date todays date
            TestDate = DateTime.Now.Date;
            //Convert the date variable to a string variable
            string DateAdded = TestDate.ToString();

            //Invoke the method
            Error = AnManufacturer.Valid(ManufacturerNo, ManufacturerName, Address, PostCode, Town, TelephoneNo, Email, DateAdded);
            //Test to see that the results is correct
            Assert.AreEqual(Error, "");
        }
示例#15
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        clsManufacturer obj = new clsManufacturer();

        obj.Name    = txtName.Text;
        obj.Address = txtAddress.Text;
        obj.PhoneNo = txtPhone.Text;
        obj.Email   = txtEmail.Text;
        obj.AddedOn = DateTime.Today.ToShortDateString();
        obj.Op      = 1;
        obj.ManufacturerMaster(obj);
        msg.Text            = "<script type='text/javascript'>alert('Saved');</script>";
        txtName.Text        = "";
        txtAddress.Text     = "";
        txtPhone.Text       = "";
        txtEmail.Text       = "";
        pnlExisting.Visible = true;
        LoadData();
    }
示例#16
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we wnat to create
            clsManufacturerCollection AllManufacturers = new clsManufacturerCollection();
            //create the item of test data
            clsManufacturer TestItem = new clsManufacturer();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            // set its properties
            TestItem.Available         = true;
            TestItem.ManufacturerID    = 456;
            TestItem.BatchProductionNo = 4;
            TestItem.YearMade          = DateTime.Now.Date;
            TestItem.CarModel          = "a31";
            TestItem.ChairMan          = "zack";
            TestItem.Email             = "*****@*****.**";
            TestItem.PhoneNo           = 987647652;
            //set ThisCar to the test data
            AllManufacturers.ThisManufacturer = TestItem;
            //set this manufacturer to the test data
            PrimaryKey = AllManufacturers.Add();
            //set primary key
            TestItem.ManufacturerID = PrimaryKey;
            //modify the test data
            TestItem.Available         = true;
            TestItem.ManufacturerID    = 456;
            TestItem.BatchProductionNo = 4;
            TestItem.YearMade          = DateTime.Now.Date;
            TestItem.CarModel          = "a31";
            TestItem.ChairMan          = "dan";
            TestItem.Email             = "*****@*****.**";
            TestItem.PhoneNo           = 987647652;
            //set the record based on the new test data
            AllManufacturers.ThisManufacturer = TestItem;
            //update the record
            AllManufacturers.Update();
            //find the record
            AllManufacturers.ThisManufacturer.Find(PrimaryKey);
            //test to see thismanufacture matches the test data
            Assert.AreEqual(AllManufacturers.ThisManufacturer, TestItem);
        }
示例#17
0
        public void YearMadeMin()

        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

            //set the date totodays date
            TestDate = DateTime.Now.Date;
            //convert the date variable to a string variable
            string YearMade = TestDate.ToString();

            //invoke the method
            Error = AnManufacturer.Valid(CarModel, ChairMan, Email, YearMade);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#18
0
        private void LoadBrand()
        {
            clsManufacturer Dal       = new clsManufacturer();
            DataSet         dsBrand   = Dal.LoadManufacturer();
            string          htmlBrand = string.Empty;

            if (dsBrand != null && dsBrand.Tables.Count > 0 && dsBrand.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsBrand.Tables[0].Rows)
                {
                    htmlBrand += "<li><a href='SearchMedicine.aspx?BrandId=" + int.Parse("0" + dr["ManufacturerID"]) + "'>" + Convert.ToString(dr["ManufacturerName"]) + "</a></li>";
                }
                ltrlBrand.Text = htmlBrand;
            }
            else
            {
                htmlBrand      = "<li><a href='#'>No Brand Found</a></li>";
                ltrlBrand.Text = htmlBrand;
            }
        }
示例#19
0
    protected void grdManufacturers_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        HiddenField     hdEID       = (HiddenField)grdManufacturers.Rows[e.RowIndex].FindControl("hdEID");
        TextBox         txtEName    = (TextBox)grdManufacturers.Rows[e.RowIndex].FindControl("txtEName");
        TextBox         txtEAddress = (TextBox)grdManufacturers.Rows[e.RowIndex].FindControl("txtEAddress");
        TextBox         txtEPhone   = (TextBox)grdManufacturers.Rows[e.RowIndex].FindControl("txtEPhone");
        TextBox         txtEEmail   = (TextBox)grdManufacturers.Rows[e.RowIndex].FindControl("txtEEmail");
        clsManufacturer obj         = new clsManufacturer();

        obj.ID      = Convert.ToInt32(hdEID.Value);
        obj.Name    = txtEName.Text;
        obj.Address = txtEAddress.Text;
        obj.PhoneNo = txtEPhone.Text;
        obj.Email   = txtEEmail.Text;
        obj.Op      = 3;
        obj.ManufacturerMaster(obj);
        msg.Text = "<script type='text/javascript'>alert('Updated');</script>";
        grdManufacturers.EditIndex = -1;
        LoadData();
    }
示例#20
0
        public void ThisManufacturerPropertyOK()
        {
            //create an instance of the class we want to create
            clsManufacturerCollection AllManufacturers = new clsManufacturerCollection();
            //create sme test data to assign to tthe property
            clsManufacturer TestManufacturer = new clsManufacturer();

            // set the properties of the test object
            TestManufacturer.Available         = true;
            TestManufacturer.ManufacturerID    = 456;
            TestManufacturer.BatchProductionNo = 4;
            TestManufacturer.YearMade          = DateTime.Now.Date;
            TestManufacturer.CarModel          = "a31";
            TestManufacturer.ChairMan          = "zack";
            TestManufacturer.Email             = "*****@*****.**";
            TestManufacturer.PhoneNo           = 987647652;
            //assign data to the property
            AllManufacturers.ThisManufacturer = TestManufacturer;
            //test to see that the two values are the same
            Assert.AreEqual(AllManufacturers.ThisManufacturer, TestManufacturer);
        }
示例#21
0
        public void TestEmailFound()
        {
            //create an instance of the class we want to create
            clsManufacturer AnManufacturer = new clsManufacturer();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            // boolean variable to record if data is ok (assume it is)
            Boolean OK = true;
            // create some test data to use with the method
            Int32 ManufacturerID = 123;

            // invoke the method
            Found = AnManufacturer.Find(ManufacturerID);
            // check the property
            if (AnManufacturer.Email != "*****@*****.**")
            {
                OK = false;
            }
            // test to see that the result is correct
            Assert.IsTrue(OK);
        }
示例#22
0
        public void TestCheckFound()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //Boolean variable to store the result of the search
            Boolean Found = false;
            //Boolean variable to record if data is Ok(assume it is)
            Boolean OK = true;
            //Create some test data to use with the method
            Int32 ManufacturerNo = 1;

            //Invoke the method
            Found = AnManufacturer.Find(ManufacturerNo);
            //Check the property
            if (AnManufacturer.Check != true)
            {
                OK = false;
            }
            //Test to see that the result is correct
            Assert.IsTrue(OK);
        }
示例#23
0
        public void TestDateAddedFound()
        {
            // Create instance of the class
            clsManufacturer AnManufacturer = new clsManufacturer();
            //Boolean variable to store the result of the search
            Boolean Found = false;
            //Boolean variable to record if data is Ok(assume it is)
            Boolean OK = true;
            //Create some test data to use with the method
            Int32 ManufacturerNo = 1;

            //Invoke the method
            Found = AnManufacturer.Find(ManufacturerNo);
            //Check the ManufacturerNo
            if (AnManufacturer.DateAdded != Convert.ToDateTime("14/03/2019 00:00:00"))
            {
                OK = false;
            }
            //Test to see that the result is correct
            Assert.IsTrue(OK);
        }
示例#24
0
        public void ThisManufacturerPropertyOk()
        {
            // Create instance of the class
            clsManufacturerCollection AllManufacturers = new clsManufacturerCollection();
            //Create some test data to assign to the property
            clsManufacturer TestManufacturer = new clsManufacturer();

            //Set the properties of the test object
            TestManufacturer.Check            = true;
            TestManufacturer.DateAdded        = DateTime.Now.Date;
            TestManufacturer.ManufacturerName = "Apple";
            TestManufacturer.ManufacturerNo   = 1;
            TestManufacturer.Address          = "40 Paynell Road";
            TestManufacturer.PostCode         = "PE1 5ST";
            TestManufacturer.Town             = "Peterborough";
            TestManufacturer.TelephoneNo      = "01733389454";
            TestManufacturer.Email            = "*****@*****.**";
            //Assign data to the property
            AllManufacturers.ThisManufacturer = TestManufacturer;
            //Test to see that the two values are the same
            Assert.AreEqual(AllManufacturers.ThisManufacturer, TestManufacturer);
        }
示例#25
0
    void LoadData()
    {
        clsManufacturer obj = new clsManufacturer();

        obj.Op = 4;
        DataTable dt = obj.ManufacturerMaster(obj).Tables[0];

        foreach (DataRow dr in dt.Rows)
        {
            dr["Address"] = dr["Address"].ToString().Replace("\n", "<br>");
        }
        grdManufacturers.DataSource = dt;
        grdManufacturers.DataBind();
        if (grdManufacturers.Rows.Count > 0)
        {
            lblError.Text = "";
        }
        else
        {
            lblError.Text = "No Records Found";
        }
    }