public object checkUserName(string userName)
        {
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch h = new HelperSearch();
                int list = h.checkUniqUser(userName);

                if (list == 1)
                {
                    result.Message = "";
                    result.IsSuccessfull = true;
                }
                else if (list == 2)
                {
                    result.Message = "نام کاربری تکراری است.";
                    result.IsSuccessfull = false;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
 public int AddPostInfo(postInfo pi)
 {
     HelperSearch h = new HelperSearch();
     try
     {
         if (h.checkUniqPost(pi.postName) == 1)
         {
             db.postInfos.InsertOnSubmit(pi);
             db.SubmitChanges();
             return pi.postCode;
         }
         else
         {
             return 0;
         }
     }
     catch (Exception error)
     {
         return -1;
     }
 }
 public int AddFieldInfo(fieldInfo fi)
 {
     HelperSearch h = new HelperSearch();
     try
     {
         if (h.checkUniqField(fi.fieldName)==1)
         {
             db.fieldInfos.InsertOnSubmit(fi);
             db.SubmitChanges();
             return fi.fieldCode;
         }
         else
         {
             return 0;
         }
     }
     catch (Exception error)
     {
         return 0;
     }
 }
 public int AddGradeInfo(gradeInfo gr)
 {
     HelperSearch h = new HelperSearch();
     try
     {
         if (h.checkUniqGrade(gr.gradeName) == 1)
         {
             gr.deleted = false;
             db.gradeInfos.InsertOnSubmit(gr);
             db.SubmitChanges();
             return gr.gradeCode;
         }
         else
         {
             return 0;
         }
     }
     catch (Exception error)
     {
         return 3;
     }
 }
        public object showFieldDetail(int reqCode)
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.showFieldDetail(reqCode);

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
        public object SearchInTable(string fieldName, string tendencyName, string gardeName, int firstRow)
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.searchPostField(firstRow, firstRow + 6 - 1, fieldName, tendencyName, gardeName);

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
        public object SearchByPostName1(string postName, int firstRow)
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.SearchByPostName1(firstRow, firstRow + 6 - 1,postName);

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
        public object PostReqSeByID(int postCode)
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.searchPost(postCode);

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
        public object PostFieldReq(int firstRow)
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.searchPostFieldReq(firstRow, firstRow +6 -1);

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
 public object FillCmbTendency1()
 {
     DataTable list = new DataTable();
     Results<DataTable> result = new Results<DataTable>();
     try
     {
         HelperSearch sHelper = new HelperSearch();
         list = sHelper.fillCombo("tendencyInfo", "tendencyCode", "tendencyName");
         if (list.Rows.Count == 0)
         {
             result.Message = "";
             result.IsSuccessfull = false;
         }
         else
         {
             result.Value = list;
             result.IsSuccessfull = true;
         }
         return result;
     }
     catch
     {
         return result;
     }
 }
        public object UserReq()
        {
            DataTable list = new DataTable();
            Results<DataTable> result = new Results<DataTable>();
            try
            {

                HelperSearch sHelper = new HelperSearch();
                list = sHelper.UserReq();

                if (list.Rows.Count == 0)
                {
                    result.Message = "";
                    result.IsSuccessfull = false;
                }
                else
                {
                    result.Value = list;
                    result.IsSuccessfull = true;
                }
                return result;
            }
            catch
            {
                return result;
            }
        }
 public override bool ValidateUser(string username, string password)
 {
     string encodedPassword = EncryptPassword(password);
     HelperSearch sHelper = new HelperSearch();
     Results<userInfo> result = sHelper.checkUserPass(username, encodedPassword);
     if (result != null)
     {
         if (result.IsSuccessfull)
         {
             bool isPersistent = false;
             //FormsAuthentication.SetAuthCookie(username, isPersistent);
             FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, result.Value.userCode.ToString(), DateTime.Now,
             DateTime.Now.AddMinutes(240), isPersistent, "", FormsAuthentication.FormsCookiePath);
             System.Web.HttpContext.Current.Session["Name"] = result.Value.fName + " " + result.Value.lName;
             System.Web.HttpContext.Current.Session["userCode"] = result.Value.userCode;
             string encTicket = FormsAuthentication.Encrypt(ticket);
             HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         return false;
     }
 }