Ejemplo n.º 1
0
        public string Authenticate(string LoginID, string LoginPassword, int BranchID, int CompanyID,string BranchName ,string CompanyName,bool rememberMe)
        {
            DataSet ds = new DataSet();
            EnCryptionAndDecription Obj_ComEncript = new EnCryptionAndDecription();
            bel_login bel = new bel_login();
            dal_login dal = new dal_login();
            bel._LoginID = LoginID;
            bel._LoginPassword = Obj_ComEncript.fEncrypt(LoginPassword);
            bel._iMode = "login";
            bel._BranchID = BranchID;
            bel._CompanyID = CompanyID;
            ds = dal.dal_Logindetail(bel);
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows[0][0].ToString() != "ERROR_USERNAME")
                {
                    // string n = ds.Tables[1].Rows[0]["LoginID"].ToString();
                    HttpContext.Current.Session["UserName"] = ds.Tables[1].Rows[0]["LoginID"].ToString();
                    HttpContext.Current.Session["UserID"] = ds.Tables[1].Rows[0]["UserID"].ToString();
                    HttpContext.Current.Session["UserGroupID"] = ds.Tables[1].Rows[0]["UserGroupID"].ToString();
                    HttpContext.Current.Session["IsSuperAdmin"] = ds.Tables[1].Rows[0]["IsSuperAdmin"].ToString();
                    HttpContext.Current.Session["CompanyName"] = Convert.ToString(CompanyName);
                    HttpContext.Current.Session["Year"] = ds.Tables[2].Rows[0]["Year"].ToString();
                    HttpContext.Current.Session["CompanyID"] = CompanyID;
                    HttpContext.Current.Session["BranchName"] = Convert.ToString(BranchName);
                    HttpContext.Current.Session["BranchID"] = BranchID;
                    //context.Response.Write(Json.GetJson(ds.Tables[0]));
                    if (rememberMe)
                    {
                        HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30);
                        HttpContext.Current.Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
                    }
                    else
                    {
                        HttpContext.Current.Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                        HttpContext.Current.Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                    }
                    HttpContext.Current.Response.Cookies["UserName"].Value = LoginID.Trim();
                    HttpContext.Current.Response.Cookies["Password"].Value = LoginPassword.Trim();

                    return "SUCCESS";
                }
                else
                {
                    return "FAIL";
                }
            }
            else
            {
                return "FAIL";
            }
        }
Ejemplo n.º 2
0
 private void BindCompanyDropDownList()
 {
     //IEnumerable<DbGetOfficesResult> offices = Offices.GetOffices();
     bel_login bel = new bel_login();
     dal_login dal = new dal_login();
     bel._iMode = "ComboBind";
     DataSet ds1 = dal.dal_Logindetail(bel);
     this.CompanySelect.DataSource = ds1.Tables[0];
     this.CompanySelect.DataBind();
 }