示例#1
0
        private void btnDeleteTestElt_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Delete this test element?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                Element_test element_Test = new Element_test();
                element_Test.class_name   = txtBoxClassnameTestElt.Text;
                element_Test.id_element   = txtBoxIdElementTest.Text;
                element_Test.id_testcase  = ID_Testcase;
                element_Test.id_url       = ID_URL;
                element_Test.value_test   = txtBoxTestValue.Text;
                element_Test.xpath        = txtBoxXpathTestElt.Text;
                element_Test.xpath_full   = txtBoxFullxpathTestElt.Text;
                element_Test.value_return = txtBoxOutputValue.Text;
                if (!BUL.TestElementBUL.Delete_TestElement(element_Test))
                {
                    MessageBox.Show("Error when delete test element", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Delete test element successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (result == DialogResult.No)
            {
            }
            dgvOutputtest.DataSource = BUL.TestElementBUL.Get_ListTestElemt(ID_URL, ID_Testcase);
        }
示例#2
0
 public bool insert_TestElement(Element_test newElement)
 {
     try
     {
         using (ElementDBEntities db = new ElementDBEntities())
         {
             db.Element_test.Add(newElement);
             db.SaveChanges();
             return(true);
         }
     }
     catch { }
     return(false);
 }
示例#3
0
 public bool Delete_TestElement(Element_test oldElement)
 {
     try
     {
         using (ElementDBEntities db = new ElementDBEntities())
         {
             db.Element_test.Attach(oldElement);
             db.Element_test.Remove(oldElement);
             db.SaveChanges();
             return(true);
         }
     }
     catch { }
     return(false);
 }
示例#4
0
 public bool Update_TestElement(Element_test newElement)
 {
     try
     {
         using (ElementDBEntities db = new ElementDBEntities())
         {
             db.Element_test.Attach(newElement);
             db.Entry(newElement).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(true);
         }
     }
     catch { }
     return(false);
 }
示例#5
0
        private void btnSaveOutput_Click(object sender, EventArgs e)
        {
            if ((txtBoxFullxpathTestElt.Text.Equals("") && txtBoxXpathTestElt.Text.Equals("")))
            {
                MessageBox.Show("Please fill Xpath or Full Xpath", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (IsNew)
                {
                    Random       random       = new Random();
                    Element_test element_Test = new Element_test();
                    element_Test.class_name   = txtBoxClassnameTestElt.Text;
                    element_Test.id_element   = ID_Testcase + Generate_RandomString(random, 5, true);
                    element_Test.id_testcase  = ID_Testcase;
                    element_Test.id_url       = ID_URL;
                    element_Test.value_test   = txtBoxTestValue.Text;
                    element_Test.xpath        = txtBoxXpathTestElt.Text;
                    element_Test.xpath_full   = txtBoxFullxpathTestElt.Text;
                    element_Test.value_return = "";
                    if (!BUL.TestElementBUL.Insert_TestElement(element_Test))
                    {
                        MessageBox.Show("Error when save test element into database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Save test element successfully into database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    Element_test element_Test = new Element_test();
                    element_Test.class_name   = txtBoxClassnameTestElt.Text;
                    element_Test.id_element   = txtBoxIdElementTest.Text;
                    element_Test.id_testcase  = ID_Testcase;
                    element_Test.id_url       = ID_URL;
                    element_Test.value_test   = txtBoxTestValue.Text;
                    element_Test.xpath        = txtBoxXpathTestElt.Text;
                    element_Test.xpath_full   = txtBoxFullxpathTestElt.Text;
                    element_Test.value_return = txtBoxOutputValue.Text;
                    if (!BUL.TestElementBUL.Update_TestElement(element_Test))
                    {
                        MessageBox.Show("Error when update test element", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Update test element successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                txtBoxClassnameTestElt.Clear();
                txtBoxFullxpathTestElt.Clear();
                txtBoxXpathTestElt.Clear();
                txtBoxTestValue.Clear();
                txtBoxOutputValue.Clear();
                txtBoxIdElementTest.Clear();
                dgvOutputtest.DataSource        = BUL.TestElementBUL.Get_ListTestElemt(ID_URL, ID_Testcase);
                txtBoxClassnameTestElt.ReadOnly = true;
                txtBoxFullxpathTestElt.ReadOnly = true;
                txtBoxXpathTestElt.ReadOnly     = true;
                txtBoxTestValue.ReadOnly        = true;
                groupBoxActionOutput.Enabled    = true;
                groupBoxComfirmOutput.Visible   = false;
            }
        }