Exemple #1
0
    protected void txtSName_TExtChnaged(object sender, EventArgs e)
    {
        maikal mk = new maikal();

        if (ddlRecivefrom.SelectedValue == "IM")
        {
            string strimsts = mk.SearchProfile(txtSName.Text.ToString());
            if (strimsts == "")
            {
                btnSaveDiary.Enabled = false;
                lblExceptiontbl.Text = "Invalid IM Membership No."; txtSName.Focus(); formstatus = "No";
                lblName.Text         = ""; txtSName.Text = "";
                lblCode.Text         = ""; lblCourseAddress.Text = "";
            }
            else
            {
                btnSaveDiary.Enabled = true;
                lblExceptiontbl.Text = ""; formstatus = "Yes";
                con.Close(); con.Open();
                SqlCommand    cmd = new SqlCommand("select * from IM where ID='" + txtSName.Text.ToString() + "'", con);
                SqlDataReader reader;
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lblName.Text          = reader["Name"].ToString();
                    lblCode.Text          = "City: " + reader["PCity"].ToString();
                    lblCourseAddress.Text = "Status: " + reader["Active"].ToString();
                }
                reader.Close();
                con.Close();
                con.Dispose();
                txtDate.Focus();
            }
        }
        else if (ddlRecivefrom.SelectedValue == "Student")
        {
            string[] stdsts = new string[2];
            Student  std    = new Student();
            stdsts = std.status(txtSName.Text.ToString());
            if (stdsts[1].ToString() == "No")
            {
                lblExceptiontbl.Text = "Invalid Student Membership No"; txtSName.Text = "";
                formstatus           = "No"; txtSName.Focus();
                btnSaveDiary.Enabled = false;
            }
            else
            {
                btnSaveDiary.Enabled = true;
                bool bl = mk.chkstatusStu(txtSName.Text.ToString());
                if (bl == false)
                {
                    lblExceptiontbl.Text = "Student Membership Not Activated"; formstatus = "No"; txtSName.Focus();
                }
                else
                {
                    lblExceptiontbl.Text = ""; formstatus = "Yes";
                    con.Close(); con.Open();
                    SqlCommand    cmd = new SqlCommand("select * from Student where SID='" + txtSName.Text.ToString() + "'", con);
                    SqlDataReader reader;
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        lblName.Text          = "Student Name: " + reader["Name"].ToString();
                        lblCode.Text          = "City: " + reader["PCity"].ToString();
                        lblCourseAddress.Text = "Status: " + reader["Status"].ToString();
                    }
                    reader.Close();
                    con.Close();
                    con.Dispose();
                    txtDate.Focus();
                }
            }
        }
        else if (ddlRecivefrom.SelectedValue == "Other")
        {
            ddlRecivefrom.Focus();
        }
    }