コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: ASupplier.aspx.cs プロジェクト: P2503333/MADteam
    protected void btnFind_Click(object sender, EventArgs e)
    {
        clsSuppliers ASupplier = new clsSuppliers();
        Int32        ID;
        Boolean      Found = false;

        try
        {
            ID    = Convert.ToInt32(txtID.Text);
            Found = ASupplier.Find(ID);
            if (Found)
            {
                txtName.Text      = ASupplier.Name;
                txtEmail.Text     = ASupplier.Email;
                txtDelivery.Text  = Convert.ToString(ASupplier.LastDelivery.ToShortDateString());
                txtAddress.Text   = ASupplier.Address;
                cbxActive.Checked = ASupplier.Active;
                lblResult.Text    = "Successfully found entry " + ID;
            }
            else
            {
                lblResult.Text = "Could not find entry " + ID;
            }
        }
        catch (FormatException)
        {
            lblResult.Text = "ID must be a number";
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        clsSuppliers ASupplier = new clsSuppliers();

        ASupplier = (clsSuppliers)Session["ASupplier"];
        Response.Write(ASupplier.ID);
        Response.Write(ASupplier.Name);
        Response.Write(ASupplier.Address);
        Response.Write(ASupplier.Email);
        Response.Write(ASupplier.LastDelivery);
        Response.Write(ASupplier.Active);
    }
コード例 #5
0
        public void ThisSupplierPropertyOk()
        {
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();
            clsSuppliers          TestSupplier = new clsSuppliers();

            TestSupplier.Active       = true;
            TestSupplier.Address      = "123 WotC Lane";
            TestSupplier.Email        = "*****@*****.**";
            TestSupplier.ID           = 10;
            TestSupplier.LastDelivery = DateTime.Now.Date;
            TestSupplier.Name         = "WotC";

            AllSuppliers.ThisSupplier = TestSupplier;
            Assert.AreEqual(AllSuppliers.ThisSupplier, TestSupplier);
        }
コード例 #6
0
        public void ThisSupplierPropertyOK()
        {
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();

            clsSuppliers TestItem = new clsSuppliers();

            TestItem.ID           = 1;
            TestItem.Address      = "Test Address";
            TestItem.Email        = "*****@*****.**";
            TestItem.Name         = "Test Name";
            TestItem.LastDelivery = DateTime.Now.Date;
            TestItem.Active       = true;

            AllSuppliers.ThisSupplier = TestItem;
            Assert.AreEqual(AllSuppliers.ThisSupplier, TestItem);
        }
コード例 #7
0
        public void SupplierListOK()
        {
            clsSupplierCollection AllSuppliers = new clsSupplierCollection();

            List <clsSuppliers> TestList = new List <clsSuppliers>();

            clsSuppliers TestItem = new clsSuppliers();

            TestItem.ID           = 1;
            TestItem.Address      = "Test Address";
            TestItem.Email        = "*****@*****.**";
            TestItem.Name         = "Test Name";
            TestItem.LastDelivery = DateTime.Now.Date;
            TestItem.Active       = true;

            TestList.Add(TestItem);
            AllSuppliers.SupplierList = TestList;
            Assert.AreEqual(AllSuppliers.SupplierList, TestList);
        }
コード例 #8
0
ファイル: ASupplier.aspx.cs プロジェクト: P2503333/MADteam
    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;
        }
    }
コード例 #9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtFullName.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)
                 {
                     //byte[] i = null;
                     //FileStream fs = new FileStream(this.txtImagePath.Text, FileMode.Open, FileAccess.Read);
                     //BinaryReader rdr = new BinaryReader(fs);
                     //i = rdr.ReadBytes((int)fs.Length);
                     clsSuppliers x = new clsSuppliers();
                     x.ID       = Convert.ToInt32(txtID.Text.Trim());
                     x.Name     = Convert.ToString(txtFullName.Text.Trim());
                     x.Email    = Convert.ToString(txtEmail.Text.Trim());
                     x.Tel      = Convert.ToString(txtTel.Text.Trim());
                     x.City     = Convert.ToString(txtCity.Text.Trim());
                     x.CAddress = Convert.ToString(txtContactAddress.Text.Trim());
                     x.Remarks  = Convert.ToString(txtRemarks.Text.Trim());
                     //x.Flagg = i;
                     int r = clsSuppliers.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
                 //byte[] i = null;
                 //FileStream fs = new FileStream(this.txtImagePath.Text,FileMode.Open,FileAccess.Read);
                 //BinaryReader rdr = new BinaryReader(fs);
                 //i = rdr.ReadBytes((int)fs.Length);
                 clsSuppliers x = new clsSuppliers();
                 x.Name     = Convert.ToString(txtFullName.Text.Trim());
                 x.Email    = Convert.ToString(txtEmail.Text.Trim());
                 x.Tel      = Convert.ToString(txtTel.Text.Trim());
                 x.City     = Convert.ToString(txtCity.Text.Trim());
                 x.CAddress = Convert.ToString(txtContactAddress.Text.Trim());
                 x.Remarks  = Convert.ToString(txtRemarks.Text.Trim());
                 // x.Flagg = i;
                 int r = clsSuppliers.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);
     }
 }