protected void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                usersLogin = new UsersLogin();
                teachers = new Teacher();
                scDao = new SchoolDao();

                string strTeacherLastName = txtLastName.Text;
                string strTeacherFirstName = txtFirstName.Text;
                string strTeacherDepartment = txtDepartament.Text;
                string strUserEmail = inputEmail.Text;
                string strPassword = inputPassword.Text;

                teachers.TeacherLastName = strTeacherLastName;
                teachers.TeacherFirstName = strTeacherFirstName;
                teachers.TeacherDepartment = strTeacherDepartment;
                usersLogin.UserEmail = strUserEmail;
                usersLogin.UserPassword = scDao.CreatePasswordHash(strPassword);
                scDao.InsetTeachers(teachers, usersLogin);
                lblMsg.Text = "Teacher Inserted!";
                btnInsert.Enabled = false;

            }
            catch (Exception ex)
            {

                lblMsg.Text=ex.Message.ToString();
            }
        }
示例#2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            bool passwordVerified = false;

            try
            {
                scDao = new SchoolDao();
                passwordVerified = scDao.VerifyPassword(inputEmail.Text, inputPassword.Text);
            }
            catch (Exception ex)
            {

                lblMsg.Text = ex.Message.ToString();
                return;
            }

            if (passwordVerified)
            {
                FormsAuthentication.RedirectFromLoginPage(inputEmail.Text, true);
            }

            else {
                lblMsg.Text = "Invalid email or password";

            }
        }
        public void FillGrid()
        {
            try
            {
                scDao = new SchoolDao();

                DataTableReader reader = scDao.ListTeachers().CreateDataReader();
                DataTable dtTeachers = new DataTable();
                dtTeachers.Load(reader);
                dvTeachers = dtTeachers.DefaultView;

                dvTeachers.Sort = ViewState["SortExpr"].ToString();

                //if (ViewState["FilterLastName"] !=null)
                //{
                //    dvTeachers.RowFilter = "TeacherLastName LIKE '*" + ViewState["FilterLastName"] + "*'";
                //}

                if (ViewState["FilterLastName"] != null || ViewState["FilterDepartment"] != null) {
                    string strFilter = "";

                    if (ViewState["FilterLastName"] != null) {
                        strFilter = "TeacherLastName LIKE '*" + ViewState["FilterLastName"] + "*'";

                        if (ViewState["FilterDepartment"] != null)
                        {
                            strFilter = strFilter + " AND TeacherDepartment LIKE '*" + ViewState["FilterDepartment"].ToString() + "*'";
                        }

                    }

                    else if (ViewState["FilterDepartment"] != null)
                    {
                        strFilter = strFilter + "TeacherDepartment LIKE '*" + ViewState["FilterDepartment"].ToString() + "*'";
                    }

                    dvTeachers.RowFilter = strFilter;

                }

                gvTeachers.DataSource = dvTeachers;
                gvTeachers.DataBind();

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
示例#4
0
        public void OpenConnection()
        {
            SchoolDao scdao = new SchoolDao();

            try
            {
                scdao.GravaLog("Abrindo conexão");
                cn.Open();
                cmd.Connection = cn;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        // protected String conexao = ConfigurationManager.ConnectionStrings["DES"].ConnectionString;
        // protected String conexao = ConfigurationManager.AppSettings.Keys[1].ToString();
        //protected String conexao = ConfigurationManager.ConnectionStrings[FunctionsGen.GetEnvironmentVariableServerPre].ConnectionString;

        public Dao()
        {
            SchoolDao scdao = new SchoolDao();

            try
            {
                cn  = new SqlConnection(conexao);
                cmd = new SqlCommand();
                da  = new SqlDataAdapter();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#6
0
        public void OpenConnection()
        {
            SchoolDao scdao = new SchoolDao();
            try
            {
                scdao.GravaLog("Abrindo conexão");
                cn.Open();
                cmd.Connection = cn;
            }
            catch (Exception ex)
            {

                throw ex;

            }
        }
示例#7
0
        protected SqlDataReader reader; // consultas - modo conectado

        #endregion Fields

        #region Constructors

        // protected String conexao = ConfigurationManager.ConnectionStrings["DES"].ConnectionString;
        // protected String conexao = ConfigurationManager.AppSettings.Keys[1].ToString();
        //protected String conexao = ConfigurationManager.ConnectionStrings[FunctionsGen.GetEnvironmentVariableServerPre].ConnectionString;
        public Dao()
        {
            SchoolDao scdao = new SchoolDao();
            try
            {

                cn = new SqlConnection(conexao);
                cmd = new SqlCommand();
                da = new SqlDataAdapter();

            }
            catch (Exception ex)
            {

                throw ex;

            }
        }
        protected void gvTeachers_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            teachers = new Teacher();
            scDao = new SchoolDao();

            int intID = Convert.ToInt32(gvTeachers.DataKeys[e.RowIndex].Value.ToString());
            string strLastName = ((TextBox)gvTeachers.Rows[e.RowIndex].FindControl("txtLastName")).Text;
            string strFirstName = ((TextBox)gvTeachers.Rows[e.RowIndex].FindControl("txtFirstName")).Text;
            string strDateJoin = ((TextBox)gvTeachers.Rows[e.RowIndex].FindControl("txtDateJoin")).Text;
            string strDepartment = ((TextBox)gvTeachers.Rows[e.RowIndex].FindControl("txtDepartment")).Text;

            teachers.TeacherID = intID;
            teachers.TeacherLastName = strLastName;
            teachers.TeacherFirstName = strFirstName;
            teachers.TeacherDateJoin = Convert.ToDateTime(strDateJoin);
            teachers.TeacherDepartment = strDepartment;

            scDao.AlterTeachers(teachers);
            gvTeachers.EditIndex = -1;
            FillGrid();
        }
 protected void gvTeachers_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     teachers = new Teacher();
     scDao = new SchoolDao();
     int intID = Convert.ToInt32(gvTeachers.DataKeys[e.RowIndex].Value.ToString());
     teachers.TeacherID = intID;
     scDao.DeleteTeachers(teachers);
     FillGrid();
 }