protected void insert_courses(object sender, EventArgs e)

    {
        BLItem objBL     = new BLItem();
        string courseID  = dd.SelectedValue;
        string teacherID = empID.Text;
        int    temp      = objBL.check_Emp_username(teacherID);

        if (temp == 1)
        {
            submit.Visible  = false;
            Button1.Visible = true;

            DataTable dt = objBL.get_available_sections(courseID);
            dd1.Visible        = true;
            dd1.DataSource     = dt;
            dd1.DataTextField  = "SectionID";
            dd1.DataValueField = "SectionID";
            dd1.DataBind();
            dd1.Items.Insert(0, new ListItem("Select SectionID", "-1"));
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Employee Does Not Exist.')", true);
        }
    }
Ejemplo n.º 2
0
    private void LoadGrid()
    {
        string userid = Request.QueryString["val1"];
        BLItem objBL  = new BLItem(); // declare and initialize BLItem object
        int    temp   = objBL.check_Emp_username(userid);

        if (temp == 1)
        {
            string image = objBL.get_image_from_emp(userid);
            if (image.Length <= 0)
            {
                image = "uploadedimages/default.png";
            }
            //   Image1.ImageUrl = image;

            DataTable dt = objBL.GetEmployee(userid, 0);
            grdContact.DataSource = dt;
            grdContact.DataBind();
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Student Does Not Exist.')", true);
            //Response.Redirect("View_Student.aspx");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            BLItem objBL      = new BLItem(); // declare and initialize BLItem object
            string username   = User_ID.Text;
            string fname      = Fname.Text;
            string lname      = Lname.Text;
            string password   = Passwd.Text;
            int    campus     = Campus.SelectedIndex + 1;
            string _Mname     = Mname.Text;
            string _gid       = gid.Text;
            string _gender    = gender.SelectedItem.Text;
            string _dob       = dob.Text;
            string _temp_addr = temp_addr.Text;
            string _p_addr    = pr_addr.Text;
            string _c_no      = c_no.Text;
            string _cnic      = cnic.Text;
            string _p_em      = p_em.Text;
            string _o_em      = o_em.Text;
            int    _deptid    = deptid.SelectedIndex + 1;
            string _d_jn      = d_en.Text;
            string _bg        = bg.SelectedItem.Text;
            string _status    = status1.Text;
            string type       = Type.SelectedValue;
            //uplodaing image
            bool   image_loaded = true;
            string pathName     = null;
            if (imgupload.HasFile)
            {
                string extension = System.IO.Path.GetExtension(imgupload.FileName);
                if (extension.ToLower() != ".gif" && extension.ToLower() != ".png" && extension.ToLower() != ".jpg" && extension.ToLower() != ".jpeg")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('invalid image format');", true);
                }
                else
                {
                    int file_size = imgupload.PostedFile.ContentLength;
                    if (file_size > 1048576)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('max file size is 1 mb');", true);
                        image_loaded = false;
                    }
                    else
                    {
                        pathName = "uploadedimages/" + Path.GetFileName(imgupload.PostedFile.FileName);
                    }
                }
            }
            int temp2 = objBL.check_Emp_username(username);
            if (temp2 == 0)
            {
                int temp = objBL.insertIntoEmployee(username, fname, lname, password, campus, _Mname, _gid, _gender, _dob, _temp_addr, _p_addr, _p_em, _o_em, _c_no, _cnic, _deptid, _bg, _d_jn, _status, type, pathName);
                imgupload.SaveAs(Server.MapPath("~/uploadedimages/" + imgupload.FileName));
                if (temp >= 0 && image_loaded)
                {
                    status.Visible = true;
                    status.Text    = "Registration is successful";

                    //Response.Redirect("Admin_Student_Registeration.aspx");
                }
                else
                {
                    status.Visible = true;
                    status.Text    = "Unable to register";
                }
            }
            else if (temp2 != 0)
            {
                status.Visible = true;
                status.Text    = "username already exists";
                //Response.Redirect("Admin_Student_Registeration.aspx");
            }
        }
        catch (SqlException)
        {
            throw;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BLItem objBL = new BLItem();
        int    temp  = objBL.check_Emp_username(TextBox1.Text);

        if (temp == 1)
        {
            try
            {
                string userID = TextBox1.Text;
                string image  = objBL.get_image_from_emp(TextBox1.Text);
                if (image.Length <= 0)
                {
                    image = "uploadedimages/default.png";
                }
                Image1.ImageUrl = image;

                update.Visible = true;

                Empinfo.DataSource = objBL.GetEmployee_Personal(userID); //setting data source for the gridview
                Empinfo.DataBind();                                      //bind the data source to the gridview
                Empinfo.HeaderRow.Visible = false;
                Empinfo.BorderStyle       = BorderStyle.None;
                for (int i = 0; i < Empinfo.Rows.Count; i++)
                {
                    Empinfo.Rows[i].Cells[1].BorderStyle = BorderStyle.None;
                    Empinfo.Rows[i].Cells[1].ForeColor   = Color.White;
                    Empinfo.Rows[i].Cells[1].Font.Bold   = false;
                }
                for (int i = 0; i < Empinfo.Rows.Count; i++)
                {
                    Empinfo.Rows[i].BorderStyle          = BorderStyle.None;
                    Empinfo.Rows[i].Cells[0].BorderStyle = BorderStyle.None;
                    Empinfo.Rows[i].Cells[0].ForeColor   = Color.Khaki;
                    Empinfo.Rows[i].Cells[0].Font.Bold   = true;
                }
            }

            catch (SqlException)
            {
                throw;
            }

            try
            {
                string userID = TextBox1.Text;
                Empinfo2.DataSource = objBL.GetEmployee_University(userID); //setting data source for the gridview
                Empinfo2.DataBind();                                        //bind the data source to the gridview
                Empinfo2.HeaderRow.Visible = false;
                Empinfo2.BorderStyle       = BorderStyle.None;
                Empinfo2.Rows[0].Visible   = false;
                for (int i = 0; i < Empinfo2.Rows.Count; i++)
                {
                    Empinfo2.Rows[i].Cells[1].BorderStyle = BorderStyle.None;
                    Empinfo2.Rows[i].Cells[1].ForeColor   = Color.White;
                    Empinfo2.Rows[i].Cells[1].Font.Bold   = false;
                }
                for (int i = 0; i < Empinfo2.Rows.Count; i++)
                {
                    Empinfo2.Rows[i].BorderStyle          = BorderStyle.None;
                    Empinfo2.Rows[i].Cells[0].BorderStyle = BorderStyle.None;
                    Empinfo2.Rows[i].Cells[0].ForeColor   = Color.Khaki;
                    Empinfo2.Rows[i].Cells[0].Font.Bold   = true;
                }
            }

            catch (SqlException)
            {
                throw;
            }

            try
            {
                string userID = TextBox1.Text;
                Empinfo3.DataSource = objBL.GetEmployee_Contact(userID); //setting data source for the gridview
                Empinfo3.DataBind();                                     //bind the data source to the gridview
                Empinfo3.HeaderRow.Visible = false;
                Empinfo3.Rows[0].Visible   = false;
                Empinfo3.BorderStyle       = BorderStyle.None;
                for (int i = 0; i < Empinfo3.Rows.Count; i++)
                {
                    Empinfo3.Rows[i].Cells[1].BorderStyle = BorderStyle.None;
                    Empinfo3.Rows[i].Cells[1].ForeColor   = Color.White;
                    Empinfo3.Rows[i].Cells[1].Font.Bold   = false;
                }
                for (int i = 0; i < Empinfo3.Rows.Count; i++)
                {
                    Empinfo3.Rows[i].BorderStyle          = BorderStyle.None;
                    Empinfo3.Rows[i].Cells[0].BorderStyle = BorderStyle.None;
                    Empinfo3.Rows[i].Cells[0].ForeColor   = Color.Khaki;
                    Empinfo3.Rows[i].Cells[0].Font.Bold   = true;
                }
            }

            catch (SqlException)
            {
                throw;
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Employee DoesNot Exist.')", true);
        }
    }
Ejemplo n.º 5
0
    protected void b1_Click(object sender, EventArgs e)
    {
        try
        {
            BLItem objBL = new BLItem(); // declare and initialize BLItem object
            string username = user_id.Text;
            string campus = logincampus.SelectedItem.ToString();
            int    LoginAs = Login_As.SelectedIndex;
            int    temp = 0, temp2 = 1;
            if (LoginAs == 0)
            {
                temp = objBL.check_student_username(username);
                if (temp == 1)
                {
                    temp2 = objBL.check_student_campus(username, campus);
                    if (temp2 == 0)
                    {
                        string password = user_pass.Text;
                        int    temp1    = objBL.check_student_password(username, password);
                        if (temp1 == 0)
                        {
                            Session["New"] = user_id.Text;

                            Response.Write("Password is correct");
                            Response.Redirect("StudentProfile.aspx");
                        }
                        else
                        {
                            Response.Write("Incorrect Password");
                        }
                    }
                    else
                    {
                        Response.Write("incorrect username");
                    }
                }
                else
                {
                    Response.Write("incorrect username");
                }
            }
            else if (LoginAs == 2)
            {
                temp = objBL.check_admin_username(username);
                if (temp == 1)
                {
                    temp2 = objBL.check_admin_campus(username, campus);
                    if (temp2 == 0)
                    {
                        string password = user_pass.Text;
                        int    temp1    = objBL.check_admin_password(username, password);
                        if (temp1 == 0)
                        {
                            Session["New"] = user_id.Text;
                            Response.Write("Password is correct");
                            Response.Redirect("Admin_Profile.aspx");
                        }
                        else
                        {
                            Response.Write("Incorrect Password");
                        }
                    }
                    else
                    {
                        Response.Write("incorrect username");
                    }
                }
                else
                {
                    Response.Write("incorrect username");
                }
            }
            else if (LoginAs == 1)
            {
                temp = objBL.check_Emp_username(username);
                if (temp == 1)
                {
                    temp2 = objBL.check_Emp_campus(username, campus);
                    if (temp2 == 0)
                    {
                        string password = user_pass.Text;
                        int    temp1    = objBL.check_Emp_password(username, password);
                        if (temp1 == 0)
                        {
                            Session["New"] = user_id.Text;
                            Response.Write("Password is correct");
                            Response.Redirect("EmployeeProfile.aspx");
                        }
                        else
                        {
                            Response.Write("Incorrect Password");
                        }
                    }
                    else
                    {
                        Response.Write("incorrect username");
                    }
                }
                else
                {
                    Response.Write("incorrect username");
                }
            }
        }
        catch (SqlException)
        {
            throw;
        }
    }