示例#1
0
        protected void btnRetrieve_Click(object sender, EventArgs e)
        {
            lbAlert.Text      = "";
            txtUserLogin.Text = txtUserLogin.Text.Trim();
            if (txtUserLogin.Text.Length > 0)
            {
                Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls();
                DataTable dt = ws.getUser(txtUserLogin.Text);
                if (dt.Rows.Count > 0)
                {
                    txtUserLogin.Text = dt.Rows[0]["SSUSR_Initials"].ToString();
                    string name = dt.Rows[0]["SSUSR_Name"].ToString();
                    if (name.Length > 0)
                    {
                        var sName = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        txtFirstName.Text = sName.FirstOrDefault();
                        txtLastName.Text  = sName.LastOrDefault();

                        //txtFirstName.Text = name.Substring(0, name.IndexOf(" ")).Trim();
                        //txtLastName.Text = name.Substring(name.IndexOf(" ")).Trim();
                    }
                    else
                    {
                        lbAlert.Text      = "Unknown User's Name.";
                        txtFirstName.Text = "";
                        txtLastName.Text  = "";
                    }
                    chActive.Checked = true;
                }
                else
                {
                    lbAlert.Text      = "User Not Found.";
                    txtFirstName.Text = "";
                    txtLastName.Text  = "";
                    chActive.Checked  = false;
                }
            }
            else
            {
                lbAlert.Text      = "Please Insert Username.";
                txtFirstName.Text = "";
                txtLastName.Text  = "";
                chActive.Checked  = false;
            }
        }