protected void Page_Load(object sender, EventArgs e)
 {
     whitfielduser wUser = new whitfielduser();
     DataSet dsUser = wUser.GetUserRecord("admin");
     DataTable myControls;
     myControls = dsUser.Tables[0];
     if (myControls.Rows.Count > 0)
     {
         try
         {
             foreach (DataRow dRow in myControls.Rows)
             {
                 Response.Write(dRow["FirstName"].ToString() + " " + dRow["LastName"].ToString());
                 Response.Write(dRow["LoginId"].ToString().Trim());
                 Response.Write(dRow["EmployeeNo"].ToString().Trim());
                 Response.Write( dRow["RoleId"].ToString().Trim());
             }
         }
         catch (Exception ex)
         {
             HttpResponse objResponse = HttpContext.Current.Response;
             objResponse.Write(ex.Message);
         }
     }
 }
示例#2
0
    public void LoginUser()
    {
        //[FirstName] [varchar](50) NOT NULL,
            //[LastName] [varchar](50) NOT NULL,
            //[Address] [varchar](250) NOT NULL,
            //[City] [varchar](50) NOT NULL,
            //[State] [varchar](50) NOT NULL,
            //[Zip] [varchar](50) NOT NULL,
            //[ContactNo1] [varchar](50) NOT NULL,
            //[ContactNo2] [varchar](50) NOT NULL,
            //[LoginId] [varchar](50) NOT NULL,
            //[Password] [varchar](50) NOT NULL,
            //[CreatedBy] [int] NULL,
            //[CreatedOn] [datetime] NULL,
            //[ModifiedBy] [int] NULL,
            //[ModifiedOn] [timestamp] NULL,
            //[EmployeeNo] [varchar](50) NOT NULL,
            //[IsActive] [bit] NOT NULL
        whitfielduser wUser = new whitfielduser();
        if (wUser.IsUserExists(tbUserID.Text.Trim(),tbpassword.Text.Trim()))
        {
            DataSet dsUser = wUser.GetUserRecord(tbUserID.Text.Trim());
            DataTable myControls;
            myControls = dsUser.Tables[0];
            if (myControls.Rows.Count > 0)
            {
                try
                {
                    foreach (DataRow dRow in myControls.Rows)
                    {
                        Response.Cookies["useridentifier"].Value = dRow["Userid"].ToString().Trim();
                        Response.Cookies["Name"].Value = dRow["FirstName"].ToString() +" " + dRow["LastName"].ToString();
                        Response.Cookies["UserId"].Value = dRow["LoginId"].ToString().Trim();
                        Response.Cookies["EmployeeNo"].Value = dRow["EmployeeNo"].ToString().Trim();
                        Response.Cookies["RoleId"].Value = dRow["RoleId"].ToString().Trim();

                        if (dRow["RoleId"].ToString().Trim() == "5")
                            Response.Redirect("installer_projects.aspx");
                        else
                            Response.Redirect("whitfieldmain.aspx");
                    }
                }
                catch (Exception ex)
                {
                    HttpResponse objResponse = HttpContext.Current.Response;
                    objResponse.Write(ex.Message);
                }
            }

        }
        else{
            lblMsg.Text = "Check your Userid and password";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        whitfielduser _wuser = new whitfielduser();
        if (!Page.IsPostBack)
        {
            Bindroles();
            Bindstates();
            BindEmplyeeType();
            if (Request.QueryString["hFlag"] == "E")
            {
                DataSet dsUser = _wuser.GetUserRecord(Request.QueryString["hUserid"]);
                DataTable dtUsr = dsUser.Tables[0];
                foreach (DataRow dRow in dtUsr.Rows)
                {
                    txtfn.Text = dRow["FirstName"].ToString();
                    txtln.Text = dRow["LastName"].ToString();
                    txtem.Text = dRow["email_address"].ToString();
                    txtEmpNo.Text = dRow["EmployeeNo"].ToString();
                    txtaddress.Text = dRow["Address"].ToString();
                    txtphno.Text = dRow["ContactNo1"].ToString();
                    BindCitiesforState(dRow["state"].ToString());
                    ddlstate.SelectedIndex = ddlstate.Items.IndexOf(ddlstate.Items.FindByValue(dRow["state"].ToString()));
                    ddlcity.SelectedIndex = ddlcity.Items.IndexOf(ddlcity.Items.FindByValue(dRow["city"].ToString()));
                    txtzip.Text = dRow["zip"].ToString();
                    txtuserid.Text = dRow["Loginid"].ToString();
                    txtpasswd.Text = dRow["password"].ToString();
                    ddlrole.SelectedIndex = ddlrole.Items.IndexOf(ddlrole.Items.FindByValue(dRow["roleid"].ToString()));
                    ddlEmplyType.SelectedIndex = ddlEmplyType.Items.IndexOf(ddlEmplyType.Items.FindByValue(dRow["empl_type_id"].ToString()));
                    txtrate.Text = dRow["hourly_rate"].ToString();
                }

            }
            else
            {
                txtuserid.ReadOnly = false;
            }

        }
    }