示例#1
0
        public int ChangePassword(UserMasterPOCO pOCO)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("ChangePassword", con);

            cmd.CommandType = CommandType.StoredProcedure;

            if (pOCO.UserId > 0)
            {
                cmd.Parameters.AddWithValue("@UserId", pOCO.UserId);
            }
            cmd.Parameters.AddWithValue("@Password", pOCO.Password.ToString());
            cmd.Parameters.AddWithValue("@NewPassword", pOCO.NewPassword.ToString());
            cmd.Parameters.Add("@IsValid", SqlDbType.Int, 0);
            cmd.Parameters["@IsValid"].Direction = ParameterDirection.Output;

            int recordsAffected = cmd.ExecuteNonQuery();
            int isValid         = Convert.ToInt32(cmd.Parameters["@IsValid"].Value);

            con.Close();

            return(isValid);
        }
        //for Ship drp
        public void GetAllShipForDrp()
        {
            UserMasterBL          bL       = new UserMasterBL();
            List <UserMasterPOCO> pocoList = new List <UserMasterPOCO>();

            pocoList = bL.GetAllShipForDrp(/*int.Parse(Session["VesselID"].ToString())*/);


            List <UserMasterPOCO> itmasterList = new List <UserMasterPOCO>();

            foreach (UserMasterPOCO up in pocoList)
            {
                UserMasterPOCO unt = new UserMasterPOCO();
                unt.ShipId   = up.ShipId;
                unt.ShipName = up.ShipName;

                itmasterList.Add(unt);
            }
            //itmasterList.Add(new UserMasterPOCO { ShipId = -1, ShipName = "Please Select One" });
            ViewBag.Ships = itmasterList.OrderBy(s => s.ShipId).Select(x =>
                                                                       new SelectListItem()
            {
                Text  = x.ShipName,
                Value = x.ShipId.ToString()
            });
        }
示例#3
0
        public int ForgotPassword(UserMasterPOCO pOCO, ref string initialPwd, ref string userCode)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("ForgotPassword", con);

            cmd.CommandType = CommandType.StoredProcedure;


            cmd.Parameters.AddWithValue("@EmailId", pOCO.Email);
            cmd.Parameters.Add("@IsValid", SqlDbType.Int, 0);
            cmd.Parameters["@IsValid"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@InitialPassword", SqlDbType.NVarChar, 50);
            cmd.Parameters["@InitialPassword"].Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@UserCode", SqlDbType.NVarChar, 50);
            cmd.Parameters["@UserCode"].Direction = ParameterDirection.Output;

            int recordsAffected = cmd.ExecuteNonQuery();
            int isValid         = Convert.ToInt32(cmd.Parameters["@IsValid"].Value);

            initialPwd = Convert.ToString(cmd.Parameters["@InitialPassword"].Value);
            userCode   = Convert.ToString(cmd.Parameters["@UserCode"].Value);
            con.Close();

            return(isValid);
        }
        public JsonResult GetUserByUserId(int UserId)
        {
            UserMasterBL   bL       = new UserMasterBL();
            UserMasterPOCO pOCOList = new UserMasterPOCO();

            pOCOList = bL.GetUserByUserId(UserId);

            UserMasterPOCO dept = new UserMasterPOCO();

            dept.UserId    = pOCOList.UserId;
            dept.UserName  = pOCOList.UserName;
            dept.UserCode  = pOCOList.UserCode;//Added on 02nd Feb 2021
            dept.Password  = pOCOList.Password;
            dept.CreatedOn = pOCOList.CreatedOn;
            dept.Email     = pOCOList.Email;
            //dept.CreatedBy = pOCOList.CreatedBy;
            //dept.ModifiedBy = pOCOList.ModifiedBy;
            dept.Gender    = pOCOList.Gender;
            dept.VesselIMO = pOCOList.VesselIMO;
            dept.RankId    = pOCOList.RankId;
            dept.ShipId    = pOCOList.ShipId;

            dept.UserType = pOCOList.UserType;
            dept.IsAdmin  = pOCOList.IsAdmin;
            dept.RoleId   = pOCOList.RoleId;

            var data = dept;

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public ActionResult ChangePassword(UserMasterPOCO aUserMaster)
        {
            try
            {
                UserMasterBL umBL    = new UserMasterBL();
                int          isValid = 0;
                if (aUserMaster.UserId == 0)
                {
                    aUserMaster.UserId = int.Parse(Session["UserId"].ToString());
                }
                isValid = umBL.ChangePassword(aUserMaster);

                if (isValid == 0)
                {
                    //return Json(isValid, JsonRequestBehavior.AllowGet);
                    aUserMaster.hasChange = 2;
                    return(View(aUserMaster));
                }
                else
                {
                    //return RedirectToAction("Login", "Home");
                    return(new RedirectToRouteResult(new RouteValueDictionary(
                                                         new { action = "Login", controller = "Home" })));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
示例#6
0
        private List <UserMasterPOCO> ConvertDataTableToUserByRankIdList(DataSet ds)
        {
            List <UserMasterPOCO> pcList = new List <UserMasterPOCO>();

            //check if there is at all any data
            if (ds.Tables.Count > 0)
            {
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    UserMasterPOCO pPOCOPC = new UserMasterPOCO();

                    //if (item["ID"] != null)
                    //    pPOCOPC.ID = Convert.ToInt32(item["ID"].ToString());

                    if (item["UserName"] != System.DBNull.Value)
                    {
                        pPOCOPC.UserName = item["UserName"].ToString();
                    }

                    if (item["CreatedOn"] != System.DBNull.Value)
                    {
                        pPOCOPC.CreatedOn1 = item["CreatedOn"].ToString();
                    }

                    if (item["Email"] != System.DBNull.Value)
                    {
                        pPOCOPC.Email = item["Email"].ToString();
                    }

                    if (item["CreatedBy"] != System.DBNull.Value)
                    {
                        pPOCOPC.CreatedBy = item["CreatedBy"].ToString();
                    }

                    if (item["ModifiedBy"] != System.DBNull.Value)
                    {
                        pPOCOPC.ModifiedBy = item["ModifiedBy"].ToString();
                    }

                    if (item["Gender"] != System.DBNull.Value)
                    {
                        pPOCOPC.Gender = item["Gender"].ToString();
                    }

                    if (item["VesselIMO"] != System.DBNull.Value)
                    {
                        pPOCOPC.VesselIMO = item["VesselIMO"].ToString();
                    }

                    if (item["RankName"] != System.DBNull.Value)
                    {
                        pPOCOPC.RankName = item["RankName"].ToString();
                    }

                    pcList.Add(pPOCOPC);
                }
            }
            return(pcList);
        }
示例#7
0
        public List <ApproverMaster> GetAllApproverListPageWise(int pageIndex, ref int totalCount, int pageSize)
        {
            List <ApproverMaster> approverList = new List <ApproverMaster>();

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetAllApproverListPageWise", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
                    cmd.Parameters.AddWithValue("@PageSize", pageSize);
                    cmd.Parameters.Add("@TotalCount", SqlDbType.Int, 4);
                    cmd.Parameters["@TotalCount"].Direction = ParameterDirection.Output;
                    con.Open();

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ApproverMaster approver = new ApproverMaster();
                        approver.ID              = Convert.ToInt32(dr["ID"]);
                        approver.ShipId          = Convert.ToInt32(dr["ShipId"]);
                        approver.RankId          = Convert.ToInt32(dr["RankId"]);
                        approver.UserId          = Convert.ToInt32(dr["UserId"]);
                        approver.ApproverId      = Convert.ToInt32(dr["ApproverId"]);
                        approver.VesselIMONumber = Convert.ToInt32(dr["VesselIMONumber"]);

                        Ship ship = new Ship();
                        ship.ID       = Convert.ToInt32(dr["ID"]);
                        ship.ShipName = Convert.ToString(dr["ShipName"]);
                        approver.Ship = ship;

                        RankPOCO rank = new RankPOCO();
                        rank.RankId   = Convert.ToInt32(dr["RankId"]);
                        rank.RankName = Convert.ToString(dr["RankName"]);
                        approver.Rank = rank;

                        UserMasterPOCO user = new UserMasterPOCO();
                        user.UserId   = Convert.ToInt32(dr["UserId"]);
                        user.UserName = Convert.ToString(dr["UserName"]);
                        approver.User = user;

                        approver.ApproverDescription = Convert.ToString(dr["ApproverDescription"]);
                        approver.RowNumber           = Convert.ToInt32(dr["RowNumber"]);


                        approverList.Add(approver);
                    }
                    totalCount = Convert.ToInt32(cmd.Parameters["@TotalCount"].Value);

                    con.Close();
                }
            }


            return(approverList);
        }
示例#8
0
        public TemporaryCrewViewModel GetAllTemporaryCrews()
        {
            TemporaryCrewViewModel tcVM = new TemporaryCrewViewModel();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetTempCrewAndExistingCrew", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);
                    List <UserMasterPOCO> tcList = new List <UserMasterPOCO>();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        UserMasterPOCO tc = new UserMasterPOCO();
                        tc.UserId   = Convert.ToInt32(dr["ID"]);
                        tc.UserName = Convert.ToString(dr["CrewName"]);
                        tc.RankName = Convert.ToString(dr["RankName"]);
                        tc.Email    = Convert.ToString(dr["Email"]);
                        tc.ShipId   = Convert.ToInt32(dr["ShipId"]);

                        var histRows = ds.Tables[1].Rows
                                       .Cast <DataRow>()
                                       .Where(x => x.Field <string>(3) == tc.RankName && x.Field <int>(4) == tc.ShipId).ToList();

                        List <UserMasterPOCO> replaceableUserList = new List <UserMasterPOCO>();
                        UserMasterPOCO        initial             = new UserMasterPOCO();
                        initial.UserId   = 0;
                        initial.UserName = "******";
                        replaceableUserList.Add(initial);
                        foreach (DataRow drh in histRows)
                        {
                            UserMasterPOCO replaceableUser = new UserMasterPOCO();
                            replaceableUser.UserId   = Convert.ToInt32(drh["UserId"]);
                            replaceableUser.UserName = Convert.ToString(drh["UserName"]) + "(" + Convert.ToString(drh["UserCode"]) + ")";
                            replaceableUser.UserCode = Convert.ToString(drh["UserCode"]);

                            replaceableUserList.Add(replaceableUser);
                        }
                        tc.ReplaceableCrews = replaceableUserList;


                        tcList.Add(tc);
                    }
                    tcVM.TemporaryCrewList = tcList;
                }
            }


            return(tcVM);
        }
示例#9
0
        /// <summary>
        /// this method used to get Rank by UserId
        /// and call from JS on change User
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public JsonResult GetUserDetailsByUser(string userId)
        {
            ApproverMaster approver = new ApproverMaster();
            UserMasterBL   userBl   = new UserMasterBL();
            UserMasterPOCO user     = new UserMasterPOCO();

            user            = userBl.GetUserByUserId(Convert.ToInt32(userId));
            approver.RankId = user.RankId;
            approver.User   = user;
            return(Json(approver, JsonRequestBehavior.AllowGet));
        }
示例#10
0
        public ActionResult ForgotPassword()
        {
            UserMasterPOCO userMaster = new UserMasterPOCO();

            try
            {
                userMaster.hasChange = 0;
                return(View(userMaster));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="approverUserId"></param>
        /// <param name="shipNo">Added on 30th Nov 2021</param>
        /// <returns></returns>
        public List <Forms> GetFilledupFormRequiredApprovalList(int approverUserId, int shipNo)
        {
            List <Forms> filledupFormList = new List <Forms>();

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetFilledupFormRequiredApprovalListPageWise", con))
                {   ///-----------------
                    con.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ApproverUserId", approverUserId);
                    //cmd.Parameters.AddWithValue("@ShipNo", approverUserId); //Added on 30th Nov 2021
                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        Ship ship = new Ship();
                        ship.ID       = Convert.ToInt32(dr["ShipId"]);
                        ship.ShipName = Convert.ToString(dr["ShipName"]);

                        UserMasterPOCO user = new UserMasterPOCO();
                        user.UserId   = Convert.ToInt32(dr["UserId"]);
                        user.UserName = Convert.ToString(dr["UserName"]);

                        filledupFormList.Add(new Forms
                        {
                            ID = Convert.ToInt32(dr["ID"]),                 //--FilledUp Form Id
                            FilledUpFormName = Convert.ToString(dr["FilledupFormName"]),
                            FilePath         = Convert.ToString(dr["FormsPath"]),
                            IsApproved       = Convert.ToInt32(dr["IsApprove"]),

                            ShipId = Convert.ToInt32(dr["ShipId"]),
                            Ship   = ship,

                            User = user,
                            Task = Convert.ToString(dr["Task"]),
                            IsPreviousApprove = Convert.ToInt32(dr["IsPreviousApprove"]),
                            CategoryId        = Convert.ToInt32(dr["CategoryId"])   // Added on 5th Aug 2021 @BK
                        });
                    }
                    con.Close();
                }
            }


            return(filledupFormList);
        }
示例#12
0
        public ActionResult ChangePassword()
        {
            UserMasterPOCO userMaster = new UserMasterPOCO();

            try
            {
                if (Session["Role"].ToString() == "OfficeUser" || Session["Role"].ToString() == "ShipUser")
                {
                    userMaster.hasChange = 0;
                    return(View(userMaster));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
示例#13
0
        public UserMasterPOCO GetUserByUserId(int UserId)
        {
            UserMasterPOCO prodPOList = new UserMasterPOCO();
            UserMasterPOCO prodPO     = new UserMasterPOCO();
            DataSet        ds         = new DataSet();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("stpGetUserByUserId", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserId", UserId);
                    con.Open();

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);
                    con.Close();
                }
            }
            return(ConvertDataTableToUserByUserIdList(ds));
        }
示例#14
0
        public JsonResult SaveUpdateUser(UserMasterPOCO pOCO)
        {
            UserMasterBL   bL = new UserMasterBL();
            UserMasterPOCO pC = new UserMasterPOCO();

            pC.UserId     = pOCO.UserId;
            pC.RankId     = pOCO.RankId;
            pC.ShipId     = pOCO.ShipId;
            pC.UserName   = pOCO.UserName;
            pC.UserCode   = pOCO.UserCode;
            pC.Password   = pOCO.Password;
            pC.Email      = pOCO.Email;
            pC.CreatedBy  = pOCO.CreatedBy;
            pC.ModifiedBy = pOCO.ModifiedBy;
            pC.Gender     = pOCO.Gender;
            pC.VesselIMO  = pOCO.VesselIMO;
            pC.RoleType   = pOCO.RoleType;
            //pC.UserCode = pOCO.UserCode;
            pC.UserType = pOCO.UserType;
            //pC.IsAdmin      = pOCO.IsAdmin;

            return(Json(bL.SaveUpdateUser(pC), JsonRequestBehavior.AllowGet));
        }
示例#15
0
        public JsonResult SaveUpdateSupportUser(UserMasterPOCO pOCO)
        {
            UserMasterBL   bL = new UserMasterBL();
            UserMasterPOCO pC = new UserMasterPOCO();

            pC.UserId = pOCO.UserId;

            pC.RankId     = pOCO.RankId;
            pC.ShipId     = pOCO.ShipId;
            pC.UserName   = pOCO.UserName;
            pC.Password   = pOCO.Password;
            pC.Email      = pOCO.Email;
            pC.CreatedBy  = pOCO.CreatedBy;
            pC.ModifiedBy = pOCO.ModifiedBy;
            pC.Gender     = pOCO.Gender;
            pC.VesselIMO  = pOCO.VesselIMO;

            //pC.UserCode = pOCO.UserCode;
            pC.UserType = 0;
            pC.IsAdmin  = pOCO.IsAdmin;

            return(Json(bL.SaveUpdateUser(pC /*, int.Parse(Session["VesselID"].ToString())*/), JsonRequestBehavior.AllowGet));
        }
示例#16
0
        /// <summary>
        /// Added on 13th Jul 2021 @BK
        /// </summary>
        /// <param name="pOCO"></param>
        /// <returns></returns>
        public int ChangePassword(UserMasterPOCO aUserMaster)
        {
            UserMasterDAL umDAL = new UserMasterDAL();

            return(umDAL.ChangePassword(aUserMaster));
        }
示例#17
0
        public int ForgotPassword(UserMasterPOCO pOCO, ref string initialPwd, ref string userCode)
        {
            UserMasterDAL umDAL = new UserMasterDAL();

            return(umDAL.ForgotPassword(pOCO, ref initialPwd, ref userCode));
        }
示例#18
0
        public int SaveUpdateUser(UserMasterPOCO pOCO /*,int VesselID*/)
        {
            UserMasterDAL dAL = new UserMasterDAL();

            return(dAL.SaveUpdateUser(pOCO /*, VesselID*/));
        }
示例#19
0
        public UserMasterPOCO CheckUserLogin(UserMasterPOCO aUser, ref string asReturnMessage)
        {
            UserMasterPOCO lUser = new UserMasterPOCO();
            DataSet        ds    = new DataSet();

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("CheckUserLogin", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserCode", aUser.UserCode);
                    cmd.Parameters.AddWithValue("@Password", aUser.Password);
                    con.Open();

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(ds);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        lUser.UserId   = Convert.ToInt32(ds.Tables[0].Rows[0]["UserId"].ToString());
                        lUser.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                        lUser.UserCode = ds.Tables[0].Rows[0]["UserCode"].ToString();

                        if (ds.Tables[0].Rows[0]["Email"] != null)
                        {
                            lUser.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                        }
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            if (ds.Tables[1].Rows[0]["Id"] != null)
                            {
                                lUser.ShipId = Convert.ToInt32(ds.Tables[1].Rows[0]["Id"].ToString());
                            }
                            else
                            {
                                lUser.ShipId = 0;
                            }

                            if (ds.Tables[1].Rows[0]["ShipName"] != null)
                            {
                                lUser.ShipName = ds.Tables[1].Rows[0]["ShipName"].ToString();
                            }
                        }


                        if (ds.Tables[0].Rows[0]["VesselIMO"] != null)
                        {
                            lUser.VesselIMO = ds.Tables[0].Rows[0]["VesselIMO"].ToString();
                        }

                        lUser.UserType = Convert.ToInt32(ds.Tables[0].Rows[0]["UserType"].ToString());

                        //lUser.IsAdmin       = Convert.ToInt32(ds.Tables[0].Rows[0]["IsAdmin"].ToString());

                        lUser.IsApprover = Convert.ToInt32(ds.Tables[0].Rows[0]["IsApprover"].ToString());
                        if (ds.Tables[0].Rows[0]["IsAllowSign"] != null)
                        {
                            lUser.IsAllowSign = Convert.ToInt32(ds.Tables[0].Rows[0]["IsAllowSign"].ToString());
                        }

                        asReturnMessage = "1";
                    }
                    else
                    {
                        asReturnMessage = "0";
                    }



                    con.Close();
                }
            }

            return(lUser);
        }
示例#20
0
        private UserMasterPOCO ConvertDataTableToUserByUserIdList(DataSet ds)
        {
            UserMasterPOCO pPOCOPC = new UserMasterPOCO();

            //check if there is at all any data
            if (ds.Tables.Count > 0)
            {
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    //UserMasterPOCO pPOCOPC = new UserMasterPOCO();
                    RankPOCO rank = new RankPOCO();
                    //Ship ship       = new Ship();

                    if (item["UserId"] != null)
                    {
                        pPOCOPC.UserId = Convert.ToInt32(item["UserId"].ToString());
                    }

                    if (item["UserName"] != System.DBNull.Value)
                    {
                        pPOCOPC.UserName = item["UserName"].ToString();
                    }

                    if (item["UserCode"] != System.DBNull.Value)//Added on 20th JAN 2021 @BK
                    {
                        pPOCOPC.UserCode = item["UserCode"].ToString();
                    }

                    if (item["Password"] != System.DBNull.Value)
                    {
                        pPOCOPC.Password = item["Password"].ToString();
                    }

                    if (item["CreatedOn"] != System.DBNull.Value)
                    {
                        pPOCOPC.CreatedOn1 = item["CreatedOn"].ToString();
                    }

                    if (item["Email"] != System.DBNull.Value)
                    {
                        pPOCOPC.Email = item["Email"].ToString();
                    }

                    //if (item["CreatedBy"] != System.DBNull.Value)
                    //    pPOCOPC.CreatedBy = item["CreatedBy"].ToString();

                    //if (item["ModifiedBy"] != System.DBNull.Value)
                    //    pPOCOPC.ModifiedBy = item["ModifiedBy"].ToString();

                    if (item["Gender"] != System.DBNull.Value)
                    {
                        pPOCOPC.Gender = item["Gender"].ToString();
                    }

                    if (item["VesselIMO"] != System.DBNull.Value)
                    {
                        pPOCOPC.VesselIMO = item["VesselIMO"].ToString();
                    }

                    if (item["RankId"] != null)
                    {
                        pPOCOPC.RankId = Convert.ToInt32(item["RankId"].ToString());
                        rank.RankId    = Convert.ToInt32(item["RankId"].ToString());
                        rank.RankName  = item["RankName"].ToString();
                        pPOCOPC.Rank   = rank;
                    }
                    if (item["ShipId"] != null)
                    {
                        pPOCOPC.ShipId = Convert.ToInt32(item["ShipId"].ToString());
                    }
                    if (item["RoleId"] != null)
                    {
                        pPOCOPC.RoleId = Convert.ToInt32(item["RoleId"].ToString());
                    }



                    //if (item["UserCode"] != System.DBNull.Value)
                    //    pPOCOPC.UserCode = item["UserCode"].ToString();

                    if (item["UserType"] != null)
                    {
                        pPOCOPC.UserType = Convert.ToInt32(item["UserType"].ToString());
                    }

                    //if (item["IsAdmin"] != null || item["IsAdmin"] != "")
                    //    pPOCOPC.IsAdmin = Convert.ToInt32(item["IsAdmin"].ToString());

                    //pcList.Add(pPOCOPC);
                }
            }
            return(pPOCOPC);
        }
示例#21
0
        public int SaveUpdateUser(UserMasterPOCO pOCO)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("stpSaveUpdateUser", con);

            cmd.CommandType = CommandType.StoredProcedure;

            if (pOCO.UserId > 0)
            {
                cmd.Parameters.AddWithValue("@UserId ", pOCO.UserId);
            }
            else
            {
                cmd.Parameters.AddWithValue("@UserId ", DBNull.Value);
            }

            cmd.Parameters.AddWithValue("@UserName", pOCO.UserName.ToString());

            cmd.Parameters.AddWithValue("@Password", pOCO.Password.ToString());

            if (!String.IsNullOrEmpty(pOCO.Email))
            {
                cmd.Parameters.AddWithValue("@Email", pOCO.Email.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@Email", DBNull.Value);
            }

            if (!String.IsNullOrEmpty(pOCO.CreatedBy))
            {
                cmd.Parameters.AddWithValue("@CreatedBy", pOCO.CreatedBy.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@CreatedBy", DBNull.Value);
            }

            if (!String.IsNullOrEmpty(pOCO.ModifiedBy))
            {
                cmd.Parameters.AddWithValue("@ModifiedBy", pOCO.ModifiedBy.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@ModifiedBy", DBNull.Value);
            }

            if (!String.IsNullOrEmpty(pOCO.Gender))
            {
                cmd.Parameters.AddWithValue("@Gender", pOCO.Gender.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@Gender", DBNull.Value);
            }

            if (!String.IsNullOrEmpty(pOCO.VesselIMO))
            {
                cmd.Parameters.AddWithValue("@VesselIMO", pOCO.VesselIMO.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@VesselIMO", DBNull.Value);
            }

            if (pOCO.RankId == -1 || pOCO.RankId > 0)
            {
                cmd.Parameters.AddWithValue("@RankId", pOCO.RankId);
            }
            else
            {
                cmd.Parameters.AddWithValue("@RankId", 0);
            }

            if (pOCO.ShipId == -1 || pOCO.ShipId > 0)
            {
                cmd.Parameters.AddWithValue("@ShipId", pOCO.ShipId);
            }
            else
            {
                cmd.Parameters.AddWithValue("@ShipId", 0);
            }

            cmd.Parameters.AddWithValue("@UserCode", pOCO.UserCode.ToString());

            cmd.Parameters.AddWithValue("@UserType", pOCO.UserType);

            cmd.Parameters.AddWithValue("@RoleType", pOCO.RoleType);

            //cmd.Parameters.AddWithValue("@IsAdmin", DBNull.Value);

            int recordsAffected = cmd.ExecuteNonQuery();

            con.Close();

            return(recordsAffected);
        }
示例#22
0
        public ActionResult ForgotPassword(UserMasterPOCO aUserMaster)
        {
            bool isSendSuccessfully = false;

            try
            {
                UserMasterBL umBL          = new UserMasterBL();
                int          isValid       = 0;
                string       initialPwd    = "";
                string       userCode      = "";
                string       receiverEmail = aUserMaster.Email;
                isValid = umBL.ForgotPassword(aUserMaster, ref initialPwd, ref userCode);

                StringBuilder mailBody = new StringBuilder();

                if (isValid == 0)
                {
                    //return Json(isValid, JsonRequestBehavior.AllowGet);
                    aUserMaster.hasChange = 2;
                    return(View(aUserMaster));
                }
                else if (isValid == 1)
                {
                    aUserMaster.hasChange = 1;

                    #region send mail----

                    //receiverEmail = um.Email.ToString();

                    MailMessage mail = new MailMessage();

                    mailBody.Append("User Code : ");
                    mailBody.Append(userCode.ToString());
                    mailBody.Append("\n");
                    mailBody.Append("Initial Password : "******"\n");
                    mailBody.Append("\n");
                    mailBody.Append("Messege : ");
                    mailBody.Append("Login with above User Code and Password and Change your Password");
                    mailBody.Append("\n");
                    mail.Body = mailBody.ToString();


                    SendEmail.SendMail("TCC Request for Forgot Password", "", receiverEmail, mail, ref isSendSuccessfully);



                    #endregion

                    return(View(aUserMaster));
                }
                else
                {
                    //return RedirectToAction("Login", "Home");
                    return(new RedirectToRouteResult(new RouteValueDictionary(
                                                         new { action = "Login", controller = "Home" })));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
示例#23
0
        public UserMasterPOCO CheckUserLogin(UserMasterPOCO aUser, ref string asReturnMessage)
        {
            HomeDAL homeDal = new HomeDAL();

            return(homeDal.CheckUserLogin(aUser, ref asReturnMessage));
        }
示例#24
0
        public ActionResult Login(UserMasterPOCO user)
        {
            UserMasterBL   userMasterBL    = new UserMasterBL();
            HomeBL         homeBl          = new HomeBL();
            string         lsReturnMessage = "0";
            string         lsApprover      = "0"; // Added on 29th Jul 2021 @BK
            string         lsAllowSign     = "0"; // Added on 29th Jul 2021 @BK
            UserMasterPOCO lUser           = new UserMasterPOCO();

            lUser = homeBl.CheckUserLogin(user, ref lsReturnMessage);
            if (lsReturnMessage == "1")
            {
                string role = userMasterBL.GetRoleByUserId(lUser.UserId);
                if (!string.IsNullOrEmpty(role))
                {
                    System.Web.HttpContext.Current.Session["Role"] = role;
                }
                else
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }


                ////----------------------------------------------------------------------------------
                ///

                //_cache.Insert("VolMenuData", Server.MapPath("~/xmlMenu/" + "ALLVOLUMES.xml"));
                //_cache.Insert("ShipMenuData", Server.MapPath("~/xmlMenu/" + "ALLSHIPS1.xml"));


                ///---------------------------------------------------------------------------------
                ///



                Session["UserId"]          = lUser.UserId.ToString();
                Session["UserCode"]        = lUser.UserCode.ToString();
                Session["UserName"]        = lUser.UserName.ToString();
                Session["Email"]           = lUser.Email.ToString();
                Session["ShipId"]          = lUser.ShipId.ToString();
                Session["DashboardShipId"] = lUser.ShipId.ToString();
                Session["IsApprover"]      = lUser.IsApprover.ToString(); //Added on 29th Jul 2021 @BK
                lsApprover             = lUser.IsApprover.ToString();     //Added on 29th Jul 2021 @BK
                Session["IsAllowSign"] = lUser.IsAllowSign.ToString();    //Added on 29th Jul 2021 @BK
                lsAllowSign            = lUser.IsAllowSign.ToString();    //Added on 29th Jul 2021 @BK

                if (!string.IsNullOrEmpty(lUser.ShipName))
                {
                    Session["ShipName"] = lUser.ShipName.ToString();
                }
                else
                {
                    Session["ShipName"] = "";
                }

                if (!string.IsNullOrEmpty(lUser.VesselIMO))
                {
                    Session["VesselIMO"] = lUser.VesselIMO.ToString();
                }
                else
                {
                    Session["VesselIMO"] = "";
                }

                Session["UserType"] = lUser.UserType.ToString();
                //Session["IsAdmin"]      = lUser.IsAdmin.ToString();


                if (role == "OfficeAdmin" || role == "ShipAdmin")
                {
                    return(RedirectToAction("AdminDashboard", "Dashboard"));
                }
                else if (role == "OfficeUser")
                {
                    if (lsApprover == "1" && lsAllowSign == "0")
                    {
                        return(RedirectToAction("Index", "ApproverSign"));
                    }
                    else
                    {
                        return(RedirectToAction("UserDashboard", "Dashboard"));
                    }
                }
                else
                {
                    return(RedirectToAction("UserDashboard", "Dashboard"));
                }


                //return new RedirectToRouteResult(new RouteValueDictionary(
                //new { action = "UserDashboard", controller = "Dashboard" }));
            }
            else
            {
                return(Json(lsReturnMessage, JsonRequestBehavior.AllowGet));
            }
        }