コード例 #1
0
    private void LoadGrid()
    {
        string userid = Request.QueryString["val1"];
        BLItem objBL  = new BLItem(); // declare and initialize BLItem object
        int    temp   = objBL.check_student_username(userid);

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

            DataTable dt = objBL.GetStudent(userid, 1);
            grdContact.DataSource = dt;
            grdContact.DataBind();
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Student Does Not Exist.')", true);
            //Response.Redirect("View_Student.aspx");
        }
    }
コード例 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            BLItem objBL = new BLItem(); // declare and initialize BLItem object
            int    temp  = objBL.check_student_username(TextBox1.Text);
            if (temp == 1)
            {
                string image = objBL.get_image(TextBox1.Text);
                if (image.Length <= 0)
                {
                    image = "uploadedimages/default.png";
                }
                Image1.ImageUrl    = image;
                student.DataSource = objBL.GetStudent_Personal(TextBox1.Text);
                student.DataBind();
                student.HeaderRow.Visible = false;
                student.BorderStyle       = BorderStyle.None;
                update.Visible            = true;

                for (int i = 0; i < student.Rows.Count; i++)
                {
                    student.Rows[i].Cells[1].BorderStyle = BorderStyle.None;
                    student.Rows[i].Cells[1].ForeColor   = Color.White;
                    student.Rows[i].Cells[1].Font.Bold   = false;
                }
                for (int i = 0; i < student.Rows.Count; i++)
                {
                    student.Rows[i].BorderStyle          = BorderStyle.None;
                    student.Rows[i].Cells[0].BorderStyle = BorderStyle.None;
                    student.Rows[i].Cells[0].ForeColor   = Color.Khaki;
                    student.Rows[i].Cells[0].Font.Bold   = true;
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Student Does Not Exist.')", true);
                //Response.Redirect("View_Student.aspx");
            }
        }
        catch (SqlException)
        {
            throw;
        }
    }
コード例 #3
0
    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_en      = d_en.Text;
            string _bg        = bg.SelectedItem.Text;
            float  _cgpa      = float.Parse(cgpa.Text);
            int    _wc        = Convert.ToInt32(wc.Text);
            string _status    = status1.Text;
            string section    = sec.Text;
            //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_student_username(username);
            if (temp2 == 0)
            {
                int temp = objBL.insertIntoStudent(username, fname, lname, password, campus, _Mname, _gid, _gender, _dob, _temp_addr, _p_addr, _p_em, _o_em, _cgpa, _c_no, _cnic, _deptid, _bg, _d_en, _wc, _status, section, 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;
        }
    }
コード例 #4
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;
        }
    }