Exemplo n.º 1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lbllevelid.Text.Length > 0)
            {
                try
                {
                    EduLevelsRepository elir = new EduLevelsRepository();

                    if (elir.FindBytitle(TextBox1.Text) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatTitle, Color.Red);

                        return;
                    }
                    EduLevel editlevel = new EduLevel();
                    if ((TextBox1.Text.Length > 0) && (TextBox1.Text != lbltitle.Text))
                    {
                        editlevel.LevelTitle = TextBox1.Text;
                    }

                    editlevel.LevelID = lbllevelid.Text.ToInt();
                    elir.SaveEduLevel(editlevel);

                    ClearForm();


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            EduLevelsRepository level = new EduLevelsRepository();

            if (level.FindBytitle(TextBox1.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;



            try
            {
                EduLevel newEduLevel = new EduLevel();
                newEduLevel.LevelTitle = TextBox1.Text.Trim();

                EduLevelsRepository elir = new EduLevelsRepository();
                elir.SaveEduLevel(newEduLevel);



                ClearForm();
            }
            catch (System.Exception err)
            {
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }