public ActionResult ShowAllMobileDetails(UserMaster_Formpara UMFRM)
 {
     UserMaster UM = new UserMaster();
     UMFRM.type = "Grid_Data";
     UMFRM.corporate = "1";
     UMFRM.FormType = "1";
     UMFRM.FormTabCode = "1";
     UM.StoreAllData = _obj_db_UM.RetrieveAllUserData(UMFRM);
     return View(UM);
 }
        public DataSet insert_data(UserMaster UM)
        {
            try
            {
                _cn.Open();
                SqlCommand _cmd = new SqlCommand("sp_save_user_details_master", _cn);
                _cmd.CommandType = CommandType.StoredProcedure;
                _cmd.Parameters.AddWithValue("@srno", UM.srno);
                _cmd.Parameters.AddWithValue("@Corporate", UM.Corporate);
                _cmd.Parameters.AddWithValue("@Unit", UM.Unit);
                _cmd.Parameters.AddWithValue("@Branch", UM.Branch);
                _cmd.Parameters.AddWithValue("@Location", UM.Location);
                _cmd.Parameters.AddWithValue("@FirstName", UM.FirstName);
                _cmd.Parameters.AddWithValue("@LastName", UM.LastName);
                _cmd.Parameters.AddWithValue("@Email", UM.Email);
                _cmd.Parameters.AddWithValue("@Password", UM.Password);
                _cmd.Parameters.AddWithValue("@Attribute1", UM.Attribute1);
                _cmd.Parameters.AddWithValue("@Attribute2", UM.Attribute2);
                _cmd.Parameters.AddWithValue("@Attribute3", UM.Attribute3);
                _cmd.Parameters.AddWithValue("@Attribute4", UM.Attribute4);
                _cmd.Parameters.AddWithValue("@Attribute5", UM.Attribute5);
                _cmd.Parameters.AddWithValue("@Attribute6", UM.Attribute6);
                _cmd.Parameters.AddWithValue("@Attribute7", UM.Attribute7);
                _cmd.Parameters.AddWithValue("@Attribute8", UM.Attribute8);
                _cmd.Parameters.AddWithValue("@Attribute9", UM.Attribute9);
                _cmd.Parameters.AddWithValue("@Attribute10", UM.Attribute10);
                _cmd.Parameters.AddWithValue("@CreatedBy", UM.CreatedBy);
                _cmd.Parameters.AddWithValue("@CorpcentreBy", UM.CorpcentreBy);
                _cmd.Parameters.AddWithValue("@UnitCorpBy", UM.UnitCorpBy);
                _cmd.Parameters.AddWithValue("@TerminalBy", UM.TerminalBy);
                _cmd.Parameters.AddWithValue("@BranchBy", UM.BranchBy);
                SqlDataAdapter adp = new SqlDataAdapter(_cmd);
                DataSet ds = new DataSet();
                adp.Fill(ds);
                adp.Dispose();
                _cmd.Dispose();
                return ds;
            }
            catch
            {
                throw;
            }
            finally
            {
                _cn.Close();
                _cn.Dispose();
            }

        }
        // insert_Data
        public ActionResult insert_Data(UserMaster UM)
        {
            try
            {
                DataSet result = _obj_db_UM.insert_data(UM);
                if (result != null)
                {
                    ViewBag.Message = result.Tables[0].Rows[0]["msg"].ToString();
                    if (result.Tables[0].Rows[0]["Help"].ToString() == "Save" || result.Tables[0].Rows[0]["Help"].ToString() == "Update")
                    { ViewBag.Event = "success"; }
                    else if (result.Tables[0].Rows[0]["Help"].ToString() == "Duplicate")
                    { ViewBag.Event = "error"; }
                    ViewBag.Srno = result.Tables[0].Rows[0]["SrNo"].ToString();
                }
                var result1 = ViewBag.Message;
                var Srno = ViewBag.Srno;
                return Json(new { success = result1, Event = ViewBag.Event, Srno = Srno }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public DataSet Edit_data(UserMaster UM)
        {
            try
            {
                _cn.Open();
                SqlCommand _cmd = new SqlCommand("sp_Edit_User_Details_Master", _cn);
                _cmd.CommandType = CommandType.StoredProcedure;
                _cmd.Parameters.AddWithValue("@tablename", UM.tablename);
                _cmd.Parameters.AddWithValue("@Corporate", UM.Corporate);
                _cmd.Parameters.AddWithValue("@unit", UM.Unit);
                _cmd.Parameters.AddWithValue("@Formcode", UM.Formcode);
                _cmd.Parameters.AddWithValue("@Formtabcode", UM.Formtabcode);
                _cmd.Parameters.AddWithValue("@srno", UM.srno);
                _cmd.Parameters.AddWithValue("@Type", "EditMode");
                _cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter _adp = new SqlDataAdapter(_cmd);
                DataSet _ds = new DataSet();
                _adp.Fill(_ds);
                _adp.Dispose();
                _cmd.Dispose();
                return _ds;
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                _cn.Close();
                _cn.Dispose();
            }
        }
        public ActionResult Edit_AccessRights(UserWiseRights _objUserWiseRights)
        {
            try
            {
                DataSet dsList = _objWhitelabelAccessRights.Edit_AccessRights(_objUserWiseRights);

                UserMaster CV = new UserMaster();
                GridRights _grid = new GridRights();
                List<GridColumnScreen> GridColumnScreen = new List<GridColumnScreen>();
                List<GridRights> lstGrid = new List<GridRights>();
                ViewBag.OtherData = "";
                if (dsList != null)
                {
                    if (dsList.Tables[1] != null)
                    {
                        if (dsList.Tables[1].Rows.Count > 0)
                        {
                            ViewBag.GridColumnScreen = dsList.Tables[1];
                            foreach (System.Data.DataRow dr in ViewBag.GridColumnScreen.Rows)
                            {
                                GridColumnScreen.Add(new GridColumnScreen
                                {
                                    SrNo = @dr["Srno"].ToString(),
                                    SCR = @dr["Screencode"].ToString(),
                                    Module = @dr["Modulecode"].ToString(),
                                    view = @dr["Viewrights"].ToString(),
                                    update = @dr["Updaterights"].ToString(),
                                    deletee = @dr["Deleterights"].ToString(),
                                    create = @dr["Addrights"].ToString(),
                                    screen = @dr["Screencode"].ToString(),
                                });
                            }
                        }
                    } if (dsList.Tables[0] != null)
                    {
                        if (dsList.Tables[0].Rows.Count > 0)
                        {
                            _objUserWiseRights.IsActive = dsList.Tables[0].Rows[0]["IsActive"].ToString();
                            _objUserWiseRights.EffectiveDate = dsList.Tables[0].Rows[0]["EffectiveDate"].ToString();
                            _objUserWiseRights.Status = dsList.Tables[0].Rows[0]["Isdefault"].ToString();
                            _objUserWiseRights.srno = dsList.Tables[0].Rows[0]["SrNo"].ToString();
                            //  ViewBag.OtherData = dsList.Tables[0];
                        }
                    }
                }
                // ViewBag.Columns = GridColumnScreen.ToList();

                return Json(new { IsActive = _objUserWiseRights.IsActive, EffectiveDate = _objUserWiseRights.EffectiveDate, Status = _objUserWiseRights.Status, Grid = GridColumnScreen.ToList(), Srno = _objUserWiseRights.srno }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ActionResult Edit_Data(UserMaster UM)
        {
            try
            {
                DataSet ds = _objWhitelabelAccessRights.Edit_data(UM);
                List<UserMaster> UserMaster = new List<UserMaster>();
                List<UserWiseRights> UserWiseRights = new List<UserWiseRights>();



                if (ds.Tables[0].Rows.Count > 0)
                {
                    ViewBag.fname = ds.Tables[0];
                    foreach (System.Data.DataRow dr in ViewBag.fname.Rows)
                    {
                        UserMaster.Add(new UserMaster
                        {
                            srno = @dr["srno"].ToString(),
                            FirstName = @dr["FirstName"].ToString(),
                            LastName = @dr["LastName"].ToString(),
                            Email = @dr["Email"].ToString(),
                            Password = @dr["Password"].ToString(),
                            Corporate = @dr["Corporate"].ToString(),
                            Unit = @dr["Unit"].ToString(),
                            Branch = @dr["Branch"].ToString(),
                            Location = @dr["Location"].ToString(),
                            BranchBy = @dr["BranchBy"].ToString(),
                            CreatedBy = @dr["CreatedBy"].ToString(),
                            UnitCorpBy = @dr["UnitCorpBy"].ToString(),

                        });
                    }
                }
                if (ds.Tables[1].Rows.Count > 0)
                {
                    ViewBag.UserWiseRights = ds.Tables[1];
                    foreach (System.Data.DataRow dr in ViewBag.UserWiseRights.Rows)
                    {
                        UserWiseRights.Add(new UserWiseRights
                        {
                            srno = @dr["srno"].ToString(),
                            Corporate = @dr["Corporate"].ToString(),
                            Unit = @dr["Unit"].ToString(),
                            Branch = @dr["Branch"].ToString(),
                            Location = @dr["Location"].ToString(),
                            Role = @dr["Role"].ToString(),
                            UserId = @dr["UserId"].ToString(),
                        });
                    }
                }



                var result = UserMaster;
                var result2 = UserWiseRights;
                return Json(new { UserMasterresjs = result, UserWiseRights = UserWiseRights }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public ActionResult Edit_Data(UserMaster UM)
        {
            try
            {
                DataSet ds = _obj_db_UM.Edit_data(UM);
                List<UserMaster> UserMaster = new List<UserMaster>();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    ViewBag.fname = ds.Tables[0];
                    foreach (System.Data.DataRow dr in ViewBag.fname.Rows)
                    {
                        UserMaster.Add(new UserMaster
                        {
                            srno = @dr["srno"].ToString(),
                            FirstName = @dr["FirstName"].ToString(),
                            LastName = @dr["LastName"].ToString(),
                            Email = @dr["Email"].ToString(),
                            Password = @dr["Password"].ToString(),
                            Corporate = @dr["Corporate"].ToString(),
                            Unit = @dr["Unit"].ToString(),
                            Branch = @dr["Branch"].ToString(),
                            BranchBy = @dr["BranchBy"].ToString(),
                            CreatedBy = @dr["CreatedBy"].ToString(),
                            UnitCorpBy = @dr["UnitCorpBy"].ToString(),

                        });
                    }
                }
                var result = UserMaster;

                return Json(new { UserMasterresjs = result }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public ActionResult Edit_AccessRights(UserWiseRights _objUserWiseRights)
        {
            try
            {
                DataSet dsList = _objRoleRightsDb.Edit_AccessRights(_objUserWiseRights);

                UserMaster CV = new UserMaster();
                GridRights _grid = new GridRights();
                List<GridColumnScreen> GridColumnScreen = new List<GridColumnScreen>();
                List<GridRights> lstGrid = new List<GridRights>();
                List<UserWiseRights> UserWiseRights = new List<UserWiseRights>();
                ViewBag.OtherData = "";
                if (dsList != null)
                {
                    if (dsList.Tables[1] != null)
                    {
                        if (dsList.Tables[1].Rows.Count > 0)
                        {
                            ViewBag.GridColumnScreen = dsList.Tables[1];
                            foreach (System.Data.DataRow dr in ViewBag.GridColumnScreen.Rows)
                            {
                                GridColumnScreen.Add(new GridColumnScreen
                                {
                                    SrNo = @dr["Srno"].ToString(),
                                    SCR = @dr["Screencode"].ToString(),
                                    Module = @dr["Modulecode"].ToString(),
                                    view = @dr["Viewrights"].ToString(),
                                    update = @dr["Updaterights"].ToString(),
                                    deletee = @dr["Deleterights"].ToString(),
                                    create = @dr["Addrights"].ToString(),
                                    screen = @dr["Screencode"].ToString(),
                                });
                            }
                        }
                    }
                    if (dsList.Tables[0].Rows.Count > 0)
                    {
                        ViewBag.UserWiseRights = dsList.Tables[0];
                        foreach (System.Data.DataRow dr in ViewBag.UserWiseRights.Rows)
                        {
                            UserWiseRights.Add(new UserWiseRights
                            {
                                srno = @dr["srno"].ToString(),
                                Corporate = @dr["Corporate"].ToString(),
                                Unit = @dr["Unit"].ToString(),
                                Branch = @dr["Branch"].ToString(),
                                Location = @dr["Location"].ToString(),
                                Role = @dr["Role"].ToString(),
                                // UserId = @dr["UserId"].ToString(),
                            });
                        }
                    }
                    // if (dsList.Tables[0] != null)
                    //{
                    //    if (dsList.Tables[0].Rows.Count > 0)
                    //    {
                    //        _objUserWiseRights.Corporate = dsList.Tables[0].Rows[0]["Corporate"].ToString();
                    //        _objUserWiseRights.Unit = dsList.Tables[0].Rows[0]["Unit"].ToString();
                    //        _objUserWiseRights.Location = dsList.Tables[0].Rows[0]["Location"].ToString();
                    //        _objUserWiseRights.srno = dsList.Tables[0].Rows[0]["SrNo"].ToString();
                    //        //  ViewBag.OtherData = dsList.Tables[0];
                    //    }
                    //}
                }
                var result = GridColumnScreen.ToList();
                var result2 = UserWiseRights;
                // ViewBag.Columns = GridColumnScreen.ToList();
                return Json(new { Grid = result, UserWiseRights = UserWiseRights }, JsonRequestBehavior.AllowGet);
                // return Json(new { Corporate = _objUserWiseRights.Corporate, Unit = _objUserWiseRights.Unit, Location = _objUserWiseRights.Location, Grid = GridColumnScreen.ToList(), Srno = _objUserWiseRights.srno }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                throw;
            }
        }