Example #1
0
        public HttpResponseMessage Isvaliduser(String userName, String userPassword)
        {
            DataTable dt = objDbTrx.GetBDMSLoginDtlMobile(userName, userPassword);

            if (dt.Rows.Count > 0)
            {
                DataTable dtRefInfo = new DataTable();
                _objUser              = new UserSec();
                _objUser.UserType     = dt.Rows[0]["USER_TYPE"].ToString();
                _objUser.UserId       = dt.Rows[0]["USER_ID"].ToString();
                _objUser.DisplayName  = dt.Rows[0]["DISPLAY_NAME"].ToString();
                _objUser.UserUniqueId = dt.Rows[0]["ID"].ToString();

                return(Request.CreateResponse(HttpStatusCode.OK, new { Success = 1, Message = true }));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, new { Success = default(int), Message = false }));
        }
Example #2
0
        public ActionResult Index(UserLogin objcust)
        {
            /*var isNavigateToUpdateProfile = default(bool);*/
            if (ModelState.IsValid)
            {
                try
                {
                    DataTable dt = objDbTrx.GetBDMSLoginDtl(objcust.UserName, objcust.UserPassword, objcust.AccadmicYear);
                    if (dt.Rows.Count > 0)
                    {
                        DataTable dtRefInfo = new DataTable();
                        UserSec   objUser   = new UserSec();
                        objUser.UserType                   = dt.Rows[0]["USER_TYPE"].ToString();
                        objUser.UserId                     = dt.Rows[0]["USER_ID"].ToString();
                        objUser.DisplayName                = dt.Rows[0]["DISPLAY_NAME"].ToString();
                        objUser.UserUniqueId               = dt.Rows[0]["ID"].ToString();
                        objUser.AcademicYearId             = objcust.AccadmicYear;
                        objUser.AcademicYear               = dt.Rows[0]["ACAD_YEAR"].ToString();
                        objUser.HasReqEditPermission       = Convert.ToInt32(dt.Rows[0]["HasReqEditPermission"].ToString());
                        objUser.HasChallanRevertPermission = Convert.ToInt32(dt.Rows[0]["HasChallanRevert"].ToString());
                        objUser.CircleID                   = "";
                        objUser.DistrictID                 = "";
                        objUser.CircleName                 = "";
                        objUser.DistrictNname              = "";
                        if (objUser.UserType == "1")//Circle User
                        {
                            Session["REF_CRCL_ID_NEW"] = Convert.ToInt32(dt.Rows[0]["REF_ID"].ToString());
                            dtRefInfo = objDbTrx.GetCircleDtilById(Convert.ToInt32(dt.Rows[0]["REF_ID"].ToString()));
                            if (dtRefInfo.Rows.Count > 0)
                            {
                                objUser.CircleID      = dtRefInfo.Rows[0]["ID"].ToString();
                                objUser.DistrictID    = dtRefInfo.Rows[0]["DISTRICT_ID"].ToString();
                                objUser.CircleName    = dtRefInfo.Rows[0]["CIRCLE_NAME"].ToString();
                                objUser.DistrictNname = dtRefInfo.Rows[0]["DISTRICT"].ToString();

                                /*if (string.IsNullOrWhiteSpace(dtRefInfo.Rows[0]["EMAIL_ID"].ToString())
                                || string.IsNullOrWhiteSpace(dtRefInfo.Rows[0]["MOBILE_NO"].ToString())
                                || string.IsNullOrWhiteSpace(dtRefInfo.Rows[0]["ALTERNATE_MOBILE_NO"].ToString())
                                || string.IsNullOrWhiteSpace(dtRefInfo.Rows[0]["CIRCLE_OFFICER_NAME"].ToString()))
                                || {
                                ||  isNavigateToUpdateProfile = true;
                                || }
                                || else
                                || {
                                ||  isNavigateToUpdateProfile = default(bool);
                                || }*/
                            }
                        }
                        if (objUser.UserType == "2")//District User User
                        {
                            dtRefInfo = objDbTrx.GetCircleDtilById(Convert.ToInt32(dt.Rows[0]["REF_ID"].ToString()));

                            if (dtRefInfo.Rows.Count > 0)
                            {
                                objUser.CircleID   = dtRefInfo.Rows[0]["ID"].ToString();
                                objUser.CircleName = dtRefInfo.Rows[0]["CIRCLE_NAME"].ToString();

                                try
                                {
                                    DataTable dtbl = objDbTrx.GetCircleDtilByDistId(Convert.ToInt32(dt.Rows[0]["REF_ID"].ToString()));
                                    if (dtbl.Rows.Count > 0)
                                    {
                                        objUser.DistrictID    = dtbl.Rows[0]["DISTRICT_ID"].ToString();
                                        objUser.DistrictNname = dtbl.Rows[0]["DISTRICT"].ToString();
                                    }
                                    else
                                    {
                                        objUser.DistrictID    = dtRefInfo.Rows[0]["DISTRICT_ID"].ToString();
                                        objUser.DistrictNname = dtRefInfo.Rows[0]["DISTRICT"].ToString();
                                    }
                                }
                                catch (Exception)
                                {
                                    objUser.DistrictID    = dtRefInfo.Rows[0]["DISTRICT_ID"].ToString();
                                    objUser.DistrictNname = dtRefInfo.Rows[0]["DISTRICT"].ToString();
                                }
                            }
                            else
                            {
                                dtRefInfo = objDbTrx.GetCircleDtilByDistId(Convert.ToInt32(dt.Rows[0]["REF_ID"].ToString()));
                                if (dtRefInfo.Rows.Count > 0)
                                {
                                    objUser.DistrictID    = dtRefInfo.Rows[0]["DISTRICT_ID"].ToString();
                                    objUser.DistrictNname = dtRefInfo.Rows[0]["DISTRICT"].ToString();
                                }
                            }
                        }
                        Session["UserSec"]       = objUser;
                        GlobalSettings.oUserData = objUser;

                        DataTable dto = objDbTrx.GetAcademicYearByID(objUser.AcademicYearId);
                        if (dto != null && dto.Rows.Count > default(int))
                        {
                            AcademicYear oAcY = new AcademicYear();
                            oAcY.ACAD_YEAR       = dto.Rows[0]["ACAD_YEAR"].ToString();
                            oAcY.ACAD_YEAR_SHORT = dto.Rows[0]["ACAD_YEAR_SHORT"].ToString();
                            oAcY.ID                      = Convert.ToInt32(dto.Rows[0]["ID"].ToString());
                            oAcY.ISACTIVE                = Convert.ToInt32(dto.Rows[0]["ISACTIVE"].ToString());
                            oAcY.PFX_BINDER              = dto.Rows[0]["PFX_BINDER"].ToString();
                            oAcY.PFX_CHALLAN             = dto.Rows[0]["PFX_CHALLAN"].ToString();
                            oAcY.PFX_INVOICE             = dto.Rows[0]["PFX_INVOICE"].ToString();
                            oAcY.PFX_REQ                 = dto.Rows[0]["PFX_REQ"].ToString();
                            oAcY.PFX_SCHCHALLAN          = dto.Rows[0]["PFX_SCHCHALLAN"].ToString();
                            GlobalSettings.oAcademicYear = oAcY;
                        }

                        if (objUser.UserType == "1")//Circle User
                        {
                            Session["BDMSLoginType"]           = "CIRCLE";
                            GlobalSettings.oUserData.vUserRole = UserRole.CIRCLE;
                        }
                        else if (objUser.UserType == "2")//District
                        {
                            Session["BDMSLoginType"]           = "DISTRICT";
                            GlobalSettings.oUserData.vUserRole = UserRole.DISTRICT;
                            return(RedirectToAction("Index", "SchRequisitionApproval"));
                        }
                        else if (objUser.UserType == "3") //ADMIN
                        {
                            Session["BDMSLoginType"]           = "ADMIN";
                            GlobalSettings.oUserData.vUserRole = UserRole.ADMIN;
                        }
                        else if (objUser.UserType == "4") //TB Login
                        {
                            Session["BDMSLoginType"]           = "TBLOGIN";
                            GlobalSettings.oUserData.vUserRole = UserRole.TBLOGIN;
                        }
                        else if (objUser.UserType == "5") //DIRECORATE
                        {
                            Session["BDMSLoginType"]           = "DIRECORATE";
                            GlobalSettings.oUserData.vUserRole = UserRole.DIRECTORATE;
                            return(RedirectToAction("Index", "SchRequisitionApproval"));
                        }
                        else if (objUser.UserType == "6") //TRANSPORTER
                        {
                            Session["BDMSLoginType"]           = "TRANSPORTER";
                            GlobalSettings.oUserData.vUserRole = UserRole.TRANSPORTER;
                        }
                        else if (objUser.UserType == "7") //TRANSPORTER
                        {
                            Session["BDMSLoginType"]           = "CHALLAN";
                            GlobalSettings.oUserData.vUserRole = UserRole.CHALLAN;
                            return(RedirectToAction("Index", "LandingPage"));
                        }
                        else if (objUser.UserType == "11") //Logistic User For Challan
                        {
                            Session["BDMSLoginType"]           = "LOGISTIC";
                            GlobalSettings.oUserData.vUserRole = UserRole.LOGISTIC;
                        }

                        /*if (isNavigateToUpdateProfile)
                         * {
                         *  return RedirectToAction("Index", "CircleUserEdit");
                         * }
                         * else
                         * {
                         *  return RedirectToAction("Index", "WelcomeLandingPage");
                         * }*/
                        return(RedirectToAction("Index", "WelcomeLandingPage"));
                    }
                    else
                    {
                        TempData["AppMessage"] = "Invalid User name or password..";
                    }
                }
                catch (Exception ex)
                {
                    objDbTrx.SaveSystemErrorLog(ex, Request.UserHostAddress);
                }
                finally { }
            }
            return(RedirectToAction("Index", "CircleLogin"));
        }
Example #3
0
        public ActionResult Validate(string username, string password)
        {
            try
            {
                Login obj = new Login();
                obj.Opmode       = 1;
                obj.UserName     = username;
                obj.UserPassword = password;
                var objLogin = DBOperations <Login> .GetSpecific(obj, Constant.usp_Login);

                UserSec objsession = new UserSec();

                if (objLogin != null && objLogin.UserPassword == password)
                {
                    objsession.UserId   = objLogin.UserId;
                    objsession.UserName = objLogin.UserName;
                    objsession.FullName = objLogin.FullName;
                    objsession.UserRole = objLogin.UserRole;
                    objsession.RefId    = objLogin.RefId;
                    objsession.MobileNo = objLogin.MobileNo;
                    objsession.EmailId  = objLogin.EmailId;
                    objsession.Active   = objLogin.Active;

                    if (objLogin.UserRole == 1) // circle user
                    {
                        var objCircleProfile = DBOperations <CircleProfile> .GetSpecific(new CircleProfile()
                        {
                            Opmode = 0, CircleMasterId = objLogin.RefId
                        }, Constant.usp_CircleProfile);

                        objsession.CircleMasterId = objCircleProfile.CircleMasterId;
                        objsession.CircleName     = objCircleProfile.CircleName;
                        objsession.DistrictId     = objCircleProfile.DistrictId;

                        var objDistrictProfile = DBOperations <DistrictProfile> .GetSpecific(new DistrictProfile()
                        {
                            Opmode = 0, DistrictId = objCircleProfile.DistrictId
                        }, Constant.usp_DistrictProfile);

                        objsession.DIstrictName = objDistrictProfile.DIstrictName;
                    }
                    if (objLogin.UserRole == 2) // district user
                    {
                        var objDistrictProfile = DBOperations <DistrictProfile> .GetSpecific(new DistrictProfile()
                        {
                            Opmode = 0, DistrictId = objLogin.RefId
                        }, Constant.usp_DistrictProfile);

                        objsession.DistrictId   = objDistrictProfile.DistrictId;
                        objsession.DIstrictName = objDistrictProfile.DIstrictName;
                    }


                    GlobalSettings.oUserMaster = objsession;
                }
                else
                {
                    throw new Exception("Invalid login credential!");
                }

                return(Json(new { Success = 1, Message = "Login Successfull", Role = GlobalSettings.oUserMaster.UserRole }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Success = 0, Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }