Example #1
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        ClsPosition position     = new ClsPosition();
        string      positionName = TbPositionName.Text;
        string      description  = TbDescription.Text;
        string      salary       = TbSalary.Text;

        string error = "";

        error = position.Valid(positionName, description, salary);
        if (error == "")
        {
            position.PositionID   = positionID;
            position.PositionName = positionName;
            position.Description  = description;
            position.Salary       = Decimal.Parse(salary);

            ClsPositionCollection positionList = new ClsPositionCollection();

            if (positionID == -1)
            {
                positionList.ThisPosition = position;
                positionList.Add();
            }
            else
            {
                positionList.ThisPosition.Find(positionID);
                positionList.ThisPosition = position;
                positionList.Update();
            }

            Response.Redirect("PositionList.aspx");
        }
        else
        {
            LblError.Text = error;
        }
    }
        public void UpdateMethodOK()
        {
            ClsPositionCollection allPosition = new ClsPositionCollection();
            ClsPosition           testItem    = new ClsPosition();

            int primaryKey = 0;

            testItem.PositionName = "Software Engineer";
            testItem.Description  = "Develop and deploy software.";
            testItem.Salary       = 35000.00M;

            allPosition.ThisPosition = testItem;
            primaryKey = allPosition.Add();

            testItem.PositionName = "Penetration Tester";
            testItem.Description  = "";
            testItem.Salary       = 50000.00M;

            allPosition.ThisPosition = testItem;
            allPosition.Update();
            allPosition.ThisPosition.Find(primaryKey);

            Assert.AreEqual(allPosition.ThisPosition, testItem);
        }