Esempio n. 1
0
        public ActionResult Registration(Tbl_UserMaster URobject)
        {
            if (string.IsNullOrEmpty(URobject.UserName))
            {
                ModelState.AddModelError("UserName", "Please Enter User Name");
            }

            if (!string.IsNullOrEmpty(URobject.EmailId))
            {
                string emailRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                                    @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                                    @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
                Regex re = new Regex(emailRegex);

                if (!re.IsMatch(URobject.EmailId))
                {
                    ModelState.AddModelError("MailId", "Invalid Email");
                }
            }
            else
            {
                ModelState.AddModelError("MailId", "Please Enter Email ID");
            }

            if (URobject.MobileNumber == 0)
            {
                ModelState.AddModelError("MobileNumber", "Please Enter Mobile Number");
            }
            if (string.IsNullOrEmpty(URobject.Password))
            {
                ModelState.AddModelError("Password", "Please Enter Password");
            }


            if (ModelState.IsValid) //checking model is valid or not
            {
                DataAccessLayer objDB = new DataAccessLayer();

                string result = objDB.RegistrationDetail(URobject);
                ViewBag.MyString = result;
                //     ModelState.Clear(); //clearing model



                ViewBag.MyString = result;
                ModelState.Clear();
                return(View());
            }
            else
            {
                ModelState.AddModelError("", "");
                return(View());
            }
        }
Esempio n. 2
0
        public String RegistrationDetail(Tbl_UserMaster Urobject)
        {
            con = Utility.Util.Connection("DBEntities");
            string result   = "";
            string result2  = "";
            string pageName = "Register";

            try
            {
                SqlCommand cmd = new SqlCommand("Registration_SP", con);
                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@userName", Urobject.UserName);
                cmd.Parameters.AddWithValue("@MailId", Urobject.EmailId);
                cmd.Parameters.AddWithValue("@MobileNumber", Urobject.MobileNumber);
                cmd.Parameters.AddWithValue("@Password", Urobject.Password);
                cmd.Parameters.AddWithValue("@Created_by", "");
                cmd.Parameters.AddWithValue("@Modified_by", "");
                cmd.Parameters.AddWithValue("@Msg", "");
                //cmd.Parameters.AddWithValue("@Flag", 0);
                result = cmd.ExecuteScalar().ToString();
                int authvalue = result == "Register Successfully" ? 1 : 0;


                #region insert into audit procedure

                result2 = AuditData.AduitFile.FillAudit(pageName, Urobject.UserName, authvalue);

                #endregion
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                return(result);
            }
            finally
            {
                con.Close();
            }

            return(result);
        }
Esempio n. 3
0
        public int  LoginDetail(Tbl_UserMaster Uobject)
        {
            //List<RoleDesc> sessionrole = new List<RoleDesc>();

            int sessionrole = 0;

            con = Utility.Util.Connection("DBEntities");
            string result   = "";
            string result2  = "";
            string pageName = "Login";

            try
            {
                #region CheckLogin
                SqlCommand cmd = new SqlCommand("SP_Login", con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@userName", Uobject.UserName);
                cmd.Parameters.AddWithValue("@Password", Uobject.Password);
                cmd.Parameters.AddWithValue("@Msg", "");
                result = cmd.ExecuteScalar().ToString();
                string[] lines     = result.Split('-');
                int      authvalue = lines[0].Contains("Login Successfull") ? 1 : 0;

                int id = Convert.ToInt16(lines[1]);
                #endregion

                #region insert into audit procedure

                result2 = AuditData.AduitFile.FillAudit(pageName, Uobject.UserName, authvalue);

                #endregion

                if (authvalue != 0)
                {
                    getId       = lines[1];
                    customerid  = Convert.ToInt16(lines[2]);
                    custType    = lines[3];
                    getName     = Uobject.UserName;
                    sessionrole = Selectrole(id);
                    return(sessionrole);
                }

                else
                {
                    //List<RoleDesc> errorlog = new List<RoleDesc>();
                    RoleDesc rp = new RoleDesc();
                    rp.id       = 001;
                    getName     = result;
                    sessionrole = 0;
                    //return errorlog;
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
                return(sessionrole);
            }
            finally
            {
                con.Close();
            }
            return(sessionrole);
        }
Esempio n. 4
0
        public ActionResult Login(Tbl_UserMaster Uobject)
        {
            if (string.IsNullOrEmpty(Uobject.UserName))
            {
                ModelState.AddModelError("UserName", "User Name Cannot be blank");
            }
            if (string.IsNullOrEmpty(Uobject.Password))
            {
                ModelState.AddModelError("Password", "Password Came cannot be blank");
            }

            if (ModelState.IsValid) //checking model is valid or not
            {
                RoleDesc        rp    = new RoleDesc();
                DataAccessLayer objDB = new DataAccessLayer();
                //  rp.Showall = objDB.LoginDetail(Uobject);
                int roleids = objDB.LoginDetail(Uobject);
                if (roleids == 0)
                {
                    TempData["Message"] = objDB.getName;
                    return(View("AppliedPage"));
                }
                string Uid   = objDB.getId;
                string Uname = objDB.getName;
                Session["U_ID"]     = Uid;
                Session["U_Name"]   = Uname;
                Session["Cust_ID"]  = objDB.customerid;
                Session["CustType"] = objDB.custType;
                #region List version
                //rp.Showall

                //if (rp.Showall != null && rp.Showall.Count > 0)
                //{
                //    for (int i = 0; i < rp.Showall.Count; i++)
                //    {
                //        if (rp.Showall[i].id != 0)
                //        {
                //            a = rp.Showall[i].id;
                //            UserRoleList.Add(a);

                //        }
                //        else
                //        {
                //            return RedirectToAction("AppliedPage");
                //        }
                //    }
                //}
                #endregion

                string strTmp = "";

                //Session["SortedList1"] = UserRoleList;
                Session["SortedList1"] = roleids;

                if (roleids == 2 || roleids == 4 || roleids == 8)
                {
                    strTmp = "view";
                    TempData["ErrorMessage"] = "Applied";
                    TempData["Roleid"]       = roleids.ToString();
                }
                else if (roleids == 1)
                {
                    strTmp = "Max";
                    TempData["ErrorMessage"] = "Applied";
                    TempData["Roleid"]       = roleids.ToString();
                }
                else if (roleids == 3 || roleids == 6)
                {
                    strTmp = "Admin";
                    TempData["ErrorMessage"] = "Applied";
                    TempData["Roleid"]       = roleids.ToString();
                }


                TempData["Viewstr"] = strTmp;
                Session["ViewData"] = strTmp;
                return(RedirectToAction("Index"));
            }
            return(View(Uobject));
        }