Пример #1
0
        public ClsUserDetails CheckUserIDPassword(string userID, string password)
        {
            ValidationException valex = new ValidationException();
            UserMaster          Table = new UserMaster();

            if (userID.IsNullOrWhiteSpace() && password.IsNullOrWhiteSpace())
            {
                valex.AddError("Please Enter UserID And Password");
            }
            else if (userID.IsNullOrWhiteSpace())
            {
                valex.AddError("Please Enter UserID");
            }
            else if (password.IsNullOrWhiteSpace())
            {
                valex.AddError("Please Enter Password");
            }
            if (valex.errorList.IsNotEmpty())
            {
                throw valex;
            }

            DataSet ds = Table.GetUserDetailsByCredentials(userID, Encrypt(password));

            if (IsvalidDataset(ds))
            {
                if (ds.Tables[0].Rows[0]["nID"].IsNotNull())
                {
                    int id = ds.Tables[0].Rows[0]["nID"].ToString().ToInt();

                    if (id > 0)
                    {
                        ClsUserDetails details = new ClsUserDetails();
                        //details.UserRowID = id;

                        if (ds.Tables[0].Rows[0]["nID"].IsNotNull())
                        {
                            details.UserID = ds.Tables[0].Rows[0]["nID"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["cFullName"].IsNotNull())
                        {
                            details.UserName = ds.Tables[0].Rows[0]["cFullName"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["cShortID"].IsNotNull())
                        {
                            details.ShortID = ds.Tables[0].Rows[0]["cShortID"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["cMailId"].IsNotNull())
                        {
                            details.Email = ds.Tables[0].Rows[0]["cMailId"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["cContactNumber"].IsNotNull())
                        {
                            details.ContactNo = ds.Tables[0].Rows[0]["cContactNumber"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["cPassword"].IsNotNull())
                        {
                            details.Password = Decrypt(ds.Tables[0].Rows[0]["cPassword"].ToString());
                        }

                        if (ds.Tables[0].Rows[0]["nLevelID"].IsNotNull())
                        {
                            details.LeveID = Convert.ToInt32(ds.Tables[0].Rows[0]["nLevelID"].ToString());
                        }

                        if (ds.Tables[0].Rows[0]["nDesignationID"].IsNotNull())
                        {
                            details.DesignationID = Convert.ToInt32(ds.Tables[0].Rows[0]["nDesignationID"].ToString());
                        }

                        if (ds.Tables[0].Rows[0]["nDepartmentID"].IsNotNull())
                        {
                            details.DepartmentID = Convert.ToInt32(ds.Tables[0].Rows[0]["nDepartmentID"].ToString());
                        }

                        return(details);
                    }
                }
            }
            else
            {
                valex.AddError("Incorrect User Name or Password");
                throw valex;
            }

            return(null);
        }