Esempio n. 1
0
    //customzed data operations over databound controls in form view
    protected void FormViewEmployee_DataBound(object sender, System.EventArgs e)
    {
        TextBox      txtFirstName = (TextBox)formViewEmployee.FindControl("txtFirstName");
        TextBox      txtLastName  = (TextBox)formViewEmployee.FindControl("txtLastName");
        TextBox      txtHireDate  = (TextBox)formViewEmployee.FindControl("txtHireDate");
        TextBox      txtAddress   = (TextBox)formViewEmployee.FindControl("txtAddress");
        TextBox      txtHomePhone = (TextBox)formViewEmployee.FindControl("txtHomePhone");
        DropDownList ddlCountry   = (DropDownList)formViewEmployee.FindControl("ddlCountry");

        //since in read-only mode there is no text box control
        if (formViewEmployee.CurrentMode != FormViewMode.ReadOnly)
        {
            //using data value in form in custom way
            if (formViewEmployee.CurrentMode == FormViewMode.Edit)
            {
                Entity.Employee employee = (Entity.Employee)formViewEmployee.DataItem;
            }

            //populating per-fill data
            if (formViewEmployee.CurrentMode == FormViewMode.Insert)
            {
                txtFirstName.Text = "Ashraful";
                txtLastName.Text  = "Alam";
                txtHireDate.Text  = DateTime.Now.ToString();
                txtAddress.Text   = "One Microsoft Way";
                txtHomePhone.Text = "912200022";
                ddlCountry.Items.FindByText("USA").Selected = true;
            }
        }

        //binding last data operation message
        Label lblMessage = (Label)formViewEmployee.FindControl("lblMessage");

        if (lblMessage != null)
        {
            lblMessage.Text = Message;
        }
    }
Esempio n. 2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = txtusername.Text.ToString().ToLower();
        string password = txtpassword.Text.ToString().ToLower();
        try
        {
            if ((username.Substring(0, 2) + username.Substring(5, 4).ToString()).Equals("020461"))
            {
                Entity.Student stdRole = new Entity.Student();
                stdRole = BLL.Student.checkRoleLogin(username, password);

                if (stdRole.Std_Type.Equals("ST"))
                {
                    Session["userid"] = stdRole.Std_Campus_Code;
                    Session["userType"] = stdRole.Std_Type;
                    Session["username"] = stdRole.Std_FName;
                    Session["name"] = stdRole.Std_FName + "  " + stdRole.Std_LName;
                    Session["yearEducate"] = 2552;// stdRole.Std_YearEducate;
                    Session["picturepath"] = stdRole.std_picturepath;

                    if (stdRole.Std_Username.Equals(stdRole.Std_Password))
                        Response.Redirect("ChangeNewPassword.aspx?id=1" + stdRole.Std_Username);
                    else
                        Response.Redirect("../BackYard/Plane/Education2.aspx");

                }
                else if (stdRole.Std_Type.Equals("AL"))
                {
                    Session["username"] = stdRole.Std_FName;
                    Session["userType"] = stdRole.Std_Type;
                    Session["userid"] = stdRole.Std_Campus_Code;
                    Session["name"] = stdRole.Std_FName + "  " + stdRole.Std_LName;
                    Session["yearEducate"] = stdRole.Std_YearEducate;
                    Session["picturepath"] = stdRole.std_picturepath;

                    if (stdRole.Std_Username.Equals(stdRole.Std_Password))
                        Response.Redirect("ChangeNewPassword.aspx?id=1" + stdRole.Std_Username);
                    else
                        Response.Redirect("../Plane/Education2.aspx");
                }
                else
                {
                    CommonClass.MessageBox.Show("กรุณาตรวจสอบความถูกต้องของ username และ password ! ");
                }

            }
            else if ((username.Substring(username.Length - 5, 5)).Equals("admin"))
            {

                Entity.Employee empRole = new Entity.Employee();
                empRole = BLL.Employee.checkRoleLogin(username, password);
                if (empRole.Emp_Type.Equals("AD"))
                {
                    Session["username"] = empRole.Emp_FName;
                    Session["userType"] = empRole.Emp_Type;
                    Session["userid"] = empRole.Emp_ID;
                    Session["name"] = empRole.Emp_FName + "  " + empRole.Emp_LName;
                    if (empRole.Emp_username.Equals(empRole.Emp_password))
                        Response.Redirect("ChangeNewPassword.aspx?id=2" + empRole.Emp_username);
                    else
                        Response.Redirect("../BackYard/Admin/MainAdmin.aspx");
                }
                else if (empRole.Emp_Type.Equals("EM"))
                {
                    Session["username"] = empRole.Emp_FName;
                    Session["userType"] = empRole.Emp_Type;
                    Session["userid"] = empRole.Emp_ID;
                    Session["name"] = empRole.Emp_FName + "  " + empRole.Emp_LName;
                    if (empRole.Emp_username.Equals(empRole.Emp_password))
                        Response.Redirect("ChangeNewPassword.aspx?id=2" + empRole.Emp_username);
                    else
                        Response.Redirect("../BackYard/Admin/MainAdmin.aspx");
                }
                else
                {
                    CommonClass.MessageBox.Show("กรุณาตรวจสอบความถูกต้องของ username และ password ! ");
                }

            }
            else if ((username.Substring(username.Length - 4, 1)).Equals("."))
            {
                Entity.Teacher tchRole = new Entity.Teacher();
                tchRole = BLL.Teacher.checkRoleLogin(username, password);
                if (tchRole.Tch_Type.Equals("TE"))
                {
                    Session["username"] = tchRole.Tch_FName;
                    Session["userType"] = tchRole.Tch_Type;
                    Session["userid"] = tchRole.Tch_ID;
                    Session["name"] = tchRole.Tch_FName + "  " + tchRole.Tch_LName;
                    Session["picturepath"] = tchRole.Tch_picturepath;
                    if (tchRole.Tch_username.Equals(tchRole.Tch_password))
                        Response.Redirect("ChangeNewPassword.aspx?id=3" + tchRole.Tch_username);
                    else
                        Response.Redirect("../BackYard/ClassRoom/mainClassroom.aspx");
                }
                else if (tchRole.Tch_Type.Equals("TS"))
                {
                    Session["username"] = tchRole.Tch_FName;
                    Session["userType"] = tchRole.Tch_Type;
                    Session["userid"] = tchRole.Tch_ID;
                    Session["name"] = tchRole.Tch_FName + "  " + tchRole.Tch_LName;
                    Session["picturepath"] = tchRole.Tch_picturepath;
                    if (tchRole.Tch_username.Equals(tchRole.Tch_password))
                        Response.Redirect("ChangeNewPassword.aspx?id=3" + tchRole.Tch_username);
                    else
                        Response.Redirect("../BackYard/ClassRoom/mainClassroom.aspx");
                }
                else
                {
                    CommonClass.MessageBox.Show("กรุณาตรวจสอบความถูกต้องของ username และ password ! ");
                }
            }
            else
            {
                CommonClass.MessageBox.Show("กรุณาตรวจสอบความถูกต้องของ username และ password ! ");
            }
        }
        catch (Exception)
        {
            CommonClass.MessageBox.Show("กรุณาตรวจสอบความถูกต้องของ username และ password ! ");
        }

    }
Esempio n. 3
0
    protected void butOK_Click(object sender, EventArgs e)
    {  
        string username = txtusername.Text.ToString().ToLower();
        string email = txtEmail.Text.ToString(); 
        try
        {
            string title = "แจ้งเตือน username และ password เข้าใช้ระบบ "; 
            if ((username.Substring(0, 2) + username.Substring(5, 4).ToString()).Equals("020461"))
            {
                Entity.Student std = new Entity.Student();
                std = BLL.Student.checkForgotPassword(username, email);

                if (!std.Std_Password.Equals("") || !std.Std_Password.Equals(null))
                {
                    name = std.Std_FName + "  " + std.Std_LName;
                    string detail = showMessageMail(name, std.Std_Username, std.Std_Password);
                    string e_mail = std.Std_email.ToString().Trim();
                    sendMail(std.Std_email.ToString(), "*****@*****.**", title, detail);
                }
                else
                {
                    CommonClass.MessageBox.Show("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !");
                }
            }
            else if ((username.Substring(username.Length - 5, 5)).Equals("admin"))
            {
                Entity.Employee emp = new Entity.Employee();
                emp = BLL.Employee.checkForgotPassword(username, email);

                if (!emp.Equals("") || !emp.Emp_password.Equals(null))
                {
                    name = emp.Emp_FName + "  " + emp.Emp_LName;
                    string detail = showMessageMail(name, emp.Emp_username, emp.Emp_password);
                    string e_mail = emp.Emp_Email.ToString().Trim();
                    sendMail(emp.Emp_Email.ToString(), "*****@*****.**", title, detail);
                }
                else
                {
                    CommonClass.MessageBox.Show("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !");
                }

            }
            else if ((username.Substring(username.Length - 4, 1)).Equals("."))
            {
                Entity.Teacher tea = new Entity.Teacher();
                tea = BLL.Teacher.checkForgotPassword(username, email);

                if (!tea.Tch_password.Equals("") || !tea.Tch_password.Equals(null))
                {
                    name = tea.Tch_FName + "  " + tea.Tch_LName;
                    string detail = showMessageMail(name, tea.Tch_username, tea.Tch_password);
                    string e_mail = tea.Tch_email.ToString().Trim();
                    sendMail(tea.Tch_email.ToString(), "*****@*****.**", title, detail);
                }
                else
                {
                    CommonClass.MessageBox.Show("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !");
                }

            }
            else
            {
                CommonClass.MessageBox.Show("ไม่พบ username หรือ email ที่คุณกรอก กรุณาตรวจสอบอีกครั้ง !");
            }


        }
        catch (Exception)
        { 
            CommonClass.MessageBox.Show("การเชื่อมต่อระหว่างเมล์เซฟเวอร์มีปัญหา อาจเนื่องจากมีการบล็อกพอร์ตเมล์ กรุณาเปลี่ยนการเชื่อมต่ออินเตอร์เน็ต !");
        }
    }