Example #1
0
        public ActionResult UpdateSubAdmin(SubAdmin usr, HttpPostedFileBase newImg)
        {
            MembersBLL memBLL = new MembersBLL();
            string     Images = "";

            if (!string.IsNullOrEmpty(Convert.ToString(newImg)))
            {
                if (Request.Files.Count > 0)
                {
                    int i = 0;
                    HttpPostedFileBase files = Request.Files[i];
                    if (files.ContentLength > 0)
                    {
                        string filestoragename = Guid.NewGuid().ToString() + ".jpeg";
                        string directory       = Server.MapPath("~/images/");
                        string path            = Path.Combine(directory, filestoragename);
                        files.SaveAs(path);
                        Images = filestoragename;
                    }
                }
                usr.Media_File_Location = string.IsNullOrEmpty(Images) ? "/img/default_ProfilePicture.jpg" : "/images/" + Images;
            }

            usr.Updated_by = Convert.ToString(Session["AdminId"]);
            usr.Created_by = Convert.ToString(Session["AdminId"]);
            bool status = memBLL.UpdateSubAdmin(usr);

            return(RedirectToAction("Index", "SubAdmin"));
        }
Example #2
0
        public bool UpdateSubAdmin(SubAdmin usr)
        {
            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(@"http://" + GeneralBLL.Service_Link + "/Services/AdminService.svc/UpdateSubAdmin");
                httpWebRequest.Method      = "POST";
                httpWebRequest.ContentType = @"application/json; charset=utf-8";

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = new JavaScriptSerializer().Serialize(usr);

                    streamWriter.Write(json);
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    result = result.Replace("\"", "");
                    return(Convert.ToBoolean(result));
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
                return(false);
            }
        }
Example #3
0
        public ActionResult SubAdminProfile(string id)
        {
            MembersBLL memBLL = new MembersBLL();
            SubAdmin   data   = memBLL.GetSingleSubAdminDetails(id);

            return(View(data));
        }
Example #4
0
        public void GetAllSubAdmins_Test()
        {
            //arrange

            //act

            //assert
            Assert.IsType <List <SubAdmin> >(SubAdmin.GetAllSubAdmins());
        }
Example #5
0
        public void AddIdentity_Test()
        {
            //arrange

            //act
            SubAdmin admin = new SubAdmin(10016);

            admin.RegisterIdentityUser(User.ApplicationRoles.SubAdmin, "abdul123", "123456");
            //assert
        }
Example #6
0
        public void AddArea_Test(string name)
        {
            //arrange

            //act
            SubAdmin admin = new SubAdmin(10016);

            //assert
            Assert.Equal(name, admin.AddArea(name).AreaName);
        }
Example #7
0
        public void GetAllAreas_Test()
        {
            //arrange

            //act
            SubAdmin             admin  = new SubAdmin(10016);
            List <SubAdmin.Area> actual = admin.GetAllAreas();

            //assert
            Assert.IsType <List <SubAdmin.Area> >(actual);
            Assert.Equal(2, actual.Count);
        }
Example #8
0
        public void RemoveArea_Test()
        {
            //arrange

            //act
            SubAdmin admin = new SubAdmin(10016);

            admin.RemoveArea(new SubAdmin.Area
            {
                AreaId = 4
            });
            //assert
        }
Example #9
0
        /// <summary>
        /// Action to show the list of subadmins registered to the system
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            List <ViewSubAdminViewModel> model = new List <ViewSubAdminViewModel>();

            foreach (var item in SubAdmin.GetAllSubAdmins())
            {
                model.Add(new ViewSubAdminViewModel(item.GetAllAreas())
                {
                    Contact = item.ContactNumber.LocalFormatedPhoneNumber,
                    Name    = item.FullName.FirstName + " " + item.FullName.LastName,
                    Id      = item.UserId
                });
            }
            return(View(model));
        }
Example #10
0
 /// <summary>
 /// Method to remove an area under a sub admin
 /// </summary>
 /// <param name="uId">sub admin id</param>
 /// <param name="aId">area id</param>
 /// <returns></returns>
 public ActionResult RemoveArea2(long uId, int aId)
 {
     try
     {
         SubAdmin subAdmin = new SubAdmin(uId);
         subAdmin.RemoveArea(new SubAdmin.Area
         {
             AreaId = aId
         });
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
Example #11
0
        /// <summary>
        /// Admin
        /// </summary>
        /// <param name="member"></param>
        ///


        public void SetAdmin(SubAdmin Admin)
        {
            string AdminData = JsonConvert.SerializeObject(Admin);
            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket
                                                   (
                1, Admin.Name_Admin, DateTime.Now, DateTime.Now.AddMinutes(15), false, AdminData
                                                   );

            string enTicket = FormsAuthentication.Encrypt(authTicket);

            HttpCookie Admincookie = new HttpCookie("cookieAdmin", enTicket);

            Admincookie.Expires  = DateTime.Now.AddYears(1);
            Admincookie.HttpOnly = true;
            _context.Response.SetCookie(Admincookie);
        }
Example #12
0
 public ActionResult AddArea(AddAreaViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     try
     {
         SubAdmin subAdmin = new SubAdmin(model.SubAdminId);
         subAdmin.AddArea(model.AreaName);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
Example #13
0
        public void MakeSubAdmin_Test()
        {
            //arrange
            User.NameFormat expectedName = new User.NameFormat
            {
                FirstName = "Abdul",
                LastName  = "Samad"
            };
            User.ContactNumberFormat expectedContact = new User.ContactNumberFormat("+92", "345", "1234567");
            //act
            SubAdmin actual = new SubAdmin(expectedName, expectedContact);

            //assert
            Assert.StrictEqual(User.ApplicationRoles.SubAdmin, actual.Role);
            Assert.Equal(expectedName, actual.FullName);
            Assert.Equal(expectedContact, actual.ContactNumber);
        }
        public bool UpdateSubAdmin(SubAdmin subAdmin)
        {
            var updateModel = entities.cor_sub_admin.Find(subAdmin.SubId);

            if (updateModel != null)
            {
                updateModel.Firstname   = subAdmin.Firstname;
                updateModel.Lastname    = subAdmin.Lastname;
                updateModel.FullName    = $"{subAdmin.Firstname} {subAdmin.Lastname}";
                updateModel.Username    = subAdmin.Username;
                updateModel.PhoneNo     = subAdmin.PhoneNo;
                updateModel.UpdatedBy   = subAdmin.UpdatedBy;
                updateModel.Email       = subAdmin.Email;
                updateModel.UpdatedDate = subAdmin.UpdatedDate;
            }
            return(entities.SaveChanges() > 0);
        }
 public ActionResult RegisterSubAdmin(RegisterSubAdminViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     try
     {
         //personal details
         SubAdmin subAdmin = new SubAdmin(new User.NameFormat
         {
             FirstName = model.FirstName,
             LastName  = model.LastName
         }, new User.ContactNumberFormat(model.CountryCode, model.CompanyCode, model.Number));
         //areas
         List <string> lstAreas = new List <string>();
         string        temp     = "";
         foreach (var item in model.Areas.ToCharArray())
         {
             if (item == ',')
             {
                 lstAreas.Add(temp);
                 temp = "";
             }
             else
             {
                 temp += item;
             }
         }
         lstAreas.Add(temp);
         foreach (var item in lstAreas)
         {
             subAdmin.AddArea(item);
         }
         //register identity
         subAdmin.RegisterIdentityUser(model.Username, Constants.DEFAULT_PASSWORD);
         return(View("RegisterationConfirmation", model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
        public bool AddSubAdmin(SubAdmin subAdmin)
        {
            var model = new cor_sub_admin()
            {
                Firstname   = subAdmin.Firstname,
                Lastname    = subAdmin.Lastname,
                FullName    = $"{subAdmin.Firstname} {subAdmin.Lastname}",
                Password    = subAdmin.Password,
                Username    = subAdmin.Username,
                Email       = subAdmin.Email,
                PhoneNo     = subAdmin.PhoneNo,
                CreatedBy   = subAdmin.CreatedBy,
                CreatedDate = subAdmin.CreatedDate,
                UpdatedBy   = subAdmin.UpdatedBy,
                UpdatedDate = subAdmin.UpdatedDate
            };

            entities.cor_sub_admin.Add(model);
            return(entities.SaveChanges() > 0);
        }
Example #17
0
 public ActionResult Sub_Admin(SubAdmin SuA)
 {
     try
     {
         if (ModelState.IsValid)
         {
             SubAdminRegHandleDb sarhdb = new SubAdminRegHandleDb();
             if (sarhdb.AddSubAdmin(SuA))
             {
                 ViewBag.Message = "Sub Admin Details Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch
     {
         ViewBag.Message = "Sub Admin Details Added not Successfully";
         return(View());
     }
 }
Example #18
0
        public SubAdmin GetSingleSubAdminDetails(string id)
        {
            try
            {
                StreamReader   readStream;
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(@"http://" + GeneralBLL.Service_Link + "/Services/AdminService.svc/SingleSubAdminDetails/" + id);
                httpWebRequest.Method      = "GET";
                httpWebRequest.ContentType = @"application/json; charset=utf-8";
                HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                readStream = new StreamReader(httpResponse.GetResponseStream());

                var      serializer = new DataContractJsonSerializer(typeof(SubAdmin));
                SubAdmin obj        = serializer.ReadObject(readStream.BaseStream) as SubAdmin;
                return(obj);
            }
            catch (Exception e)
            {
                Console.Write(e);
                return(null);
            }
        }
        // GET: Account
        // Đăng nhập
        public ActionResult LogIn(SubAdmin ss, SubMember sm)
        {
            string password = FormsAuthentication.HashPasswordForStoringInConfigFile(ss.Password, "MD5");
            var    member   = db.Members.Where(o => o.Email == ss.Email && o.Password == password).FirstOrDefault();
            var    admin    = db.Admins.Where(o => o.Email == sm.Email && o.Password == password).FirstOrDefault();

            ViewBag.Message = null;
            if (member != null)
            {
                if (sm.CheckBox == "on")
                {
                    Xcookie.Instance.SetMember(AutoMapper.Mapper.Map <SubMember>(member));
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    Xsession.Member = AutoMapper.Mapper.Map <SubMember>(member);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else if (admin != null)
            {
                if (ss.CheckBox == "on")

                {
                    Xcookie.Instance.SetAdmin(AutoMapper.Mapper.Map <SubAdmin>(admin));
                    return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                }
                else
                {
                    Xsession.Admin = AutoMapper.Mapper.Map <SubAdmin>(admin);
                    return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                }
            }
            else
            {
                ViewBag.Message = "Tên đăng nhập hoặc mật khẩu không chính xác";
            }
            return(View());
        }
Example #20
0
 /// <summary>
 /// Action to show areas to be removed
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult RemoveArea(long id)
 {
     try
     {
         SubAdmin             subAdmin = new SubAdmin(id);
         List <AreaViewModel> model    = new List <AreaViewModel>();
         foreach (var item in subAdmin.GetAllAreas())
         {
             model.Add(new AreaViewModel
             {
                 Id         = item.AreaId,
                 Name       = item.AreaName,
                 SubAdminId = subAdmin.UserId
             });
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
        public ActionResult LogIn(Models.Admin me, string checkBox)
        {
            try
            {
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(me.Password, "MD5");

                var admin = db.Admins.Where(m => m.Email == me.Email && m.Password == password).FirstOrDefault();

                if (admin != null)
                {
                    SubAdmin sub = new SubAdmin();
                    sub.Email       = admin.Email;
                    sub.ID_Admin    = admin.ID_Admin;
                    sub.Name_Admin  = admin.Name_Admin;
                    sub.Phone_Admin = admin.Phone_Admin;

                    if (checkBox == "on")
                    {
                        Xcookie.Instance.SetAdmin(sub);
                    }
                    else
                    {
                        Xsession.Admin = sub;
                    }
                    return(RedirectToAction("Index", "Home", new { area = "Admin" }));
                }
                else
                {
                    ViewBag.message = "Tên tài khoản hoặc mật khẩu không chính xác";
                    return(View());
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Example #22
0
        public SubAdmin GetSingleSubAdminDetailsDb(string id)
        {
            SqlConnection con = null;

            SqlParameter[] aParms = new SqlParameter[] { new SqlParameter(PARAM_Usr_Id, id) };
            SubAdmin       member = new SubAdmin();

            try
            {
                con = General.GetConnection();
                SqlDataReader reader = SqlHelper.ExecuteReader(con, CommandType.Text, SQL_SELECT_SingleSubAdmin, aParms);
                while (reader.Read())
                {
                    member.Usr_Id              = reader.GetString(0);
                    member.First_Name          = reader.GetString(1);
                    member.Last_Name           = reader.GetString(2);
                    member.Gender              = reader.GetString(3);
                    member.Alt_Email_Id        = reader.GetString(4);
                    member.Mobile_Number       = reader.GetString(5);
                    member.Login_status        = reader.GetInt32(6);
                    member.Usr_role_Id         = reader.GetString(7);
                    member.Media_File_Location = reader.GetString(8);
                    member.Created_Date        = reader.GetDateTime(9);
                    member.Updated_Date        = reader.GetDateTime(10);
                    member.Created_by          = reader.GetString(11);
                    member.Updated_by          = reader.GetString(12);
                }
                reader.Close();
                return(member);
            }
            catch (Exception e)
            {
                Console.Write(e);
                return(null);
            }
        }
        public SubAdmin GetSubAdmin(long SubAdminId)
        {
            var model = entities.cor_sub_admin.Find(SubAdminId);

            if (model != null)
            {
                SubAdmin SubAdmin = new SubAdmin()
                {
                    SubId       = model.SubId,
                    Firstname   = model.Firstname,
                    Lastname    = model.Lastname,
                    FullName    = model.FullName,
                    Username    = model.Username,
                    Email       = model.Email,
                    PhoneNo     = model.PhoneNo,
                    CreatedBy   = model.CreatedBy,
                    CreatedDate = model.CreatedDate,
                    UpdatedBy   = model.UpdatedBy,
                    UpdatedDate = model.UpdatedDate
                };
                return(SubAdmin);
            }
            return(null);
        }
Example #24
0
        public ActionResult SendNotification(SendSmsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                Sms sms;
                if (model.MessageId != 0)
                {
                    sms = new Sms(model.MessageId);
                    if (sms.Body != model.Body)
                    {
                        sms = new Sms(DateTime.Now, model.Body);
                    }
                }
                else
                {
                    sms = new Sms(DateTime.Now, model.Body);
                }

                if (model.Receiver == SendSmsViewModel.Receivers.All)
                {
                    foreach (var item in ZATAppApi.Models.User.GetAllUsers())
                    {
                        SendSMS(sms.Body, item.ContactNumber.PhoneNumberFormat);
                        item.SendSms(sms);
                    }
                }
                else if (model.Receiver == SendSmsViewModel.Receivers.Drivers)
                {
                    foreach (var item in Driver.GetAllDrivers())
                    {
                        SendSMS(model.Body, item.ContactNumber.PhoneNumberFormat);
                        item.SendSms(sms);
                    }
                }
                else if (model.Receiver == SendSmsViewModel.Receivers.Riders)
                {
                    foreach (var item in Rider.GetAllRiders())
                    {
                        SendSMS(model.Body, item.ContactNumber.PhoneNumberFormat);
                        item.SendSms(sms);
                    }
                }
                else if (model.Receiver == SendSmsViewModel.Receivers.SubAdmin)
                {
                    foreach (var item in SubAdmin.GetAllSubAdmins())
                    {
                        SendSMS(model.Body, item.ContactNumber.PhoneNumberFormat);
                        item.SendSms(sms);
                    }
                }
                return(View("Confirmation"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("ErrorPage", "Error", ex));
            }
        }
Example #25
0
 private void btn_Add_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_Firstname.Text == string.Empty)
         {
             MessageBox.Show("Firstname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Firstname.Focus();
             return;
         }
         if (txt_Lastname.Text == string.Empty)
         {
             MessageBox.Show("Lastname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Lastname.Focus();
             return;
         }
         if (txt_Email.Text == string.Empty)
         {
             MessageBox.Show("Email is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Email.Focus();
             return;
         }
         if (txt_Phone.Text == string.Empty)
         {
             MessageBox.Show("Phone number is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Phone.Focus();
             return;
         }
         if (txt_Password.Text == string.Empty)
         {
             MessageBox.Show("Password is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Password.Focus();
             return;
         }
         if (txt_Password.Text == string.Empty)
         {
             MessageBox.Show("Password is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Password.Focus();
             return;
         }
         if (txt_ConfirmPassword.Text == string.Empty)
         {
             MessageBox.Show("Please confirm password!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_ConfirmPassword.Focus();
             return;
         }
         if (usernameVerified == true && txt_Password.Text.Length >= 6 && txt_Password.Text.Equals(txt_ConfirmPassword.Text) && txt_Firstname.Text != string.Empty && txt_Lastname.Text != string.Empty &&
             Utilities.IsValidEmail(txt_Email.Text) && isEmailExisting == false && isPhoneNoExisting == false && Utilities.EnsureNumericOnly(txt_Phone.Text) &&
             txt_Email.Text != string.Empty && txt_Phone.Text != string.Empty)
         {
             SubAdmin subAdmin = new SubAdmin()
             {
                 Firstname   = txt_Firstname.Text,
                 Lastname    = txt_Lastname.Text,
                 Email       = txt_Email.Text,
                 PhoneNo     = txt_Phone.Text,
                 Password    = Cryptography.Encrypt(txt_Password.Text, "SuperiorInvestment#"),
                 Username    = txt_Username.Text.ToLower(),
                 CreatedBy   = Utilities.USERNAME,
                 CreatedDate = DateTime.Now.Date
             };
             if (_SubAdminRepo.AddSubAdmin(subAdmin))
             {
                 MessageBox.Show("Sub admin added successfully!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_Firstname.Text       = string.Empty; txt_Firstname.Focus(); lb_DangerFirstname.Hide(); toolTip.Hide(lb_DangerFirstname);
                 txt_Lastname.Text        = string.Empty; lb_DangerLastname.Hide(); toolTip.Hide(lb_DangerLastname);
                 txt_Email.Text           = string.Empty; toolTip.Hide(lb_DangerEmail); lb_DangerEmail.Hide();
                 txt_Phone.Text           = string.Empty; toolTip.Hide(lb_DangerPhone); lb_DangerPhone.Hide();
                 txt_Username.Text        = string.Empty; lb_DangerUsername.Hide(); toolTip.Hide(lb_DangerUsername);
                 txt_Password.Text        = string.Empty; lb_DangerPassword.Hide(); toolTip.Hide(lb_DangerPassword);
                 txt_ConfirmPassword.Text = string.Empty; lb_DangerConfirmPassword.Hide(); toolTip.Hide(lb_DangerConfirmPassword);
                 usernameVerified         = true;
             }
         }
         else
         {
             MessageBox.Show("Please ensure filled-in information is correct and complete!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #26
0
        public bool GetUpdateSubAdmin(SubAdmin usr)
        {
            U_USR_MASTERDAL       userDAL  = new U_USR_MASTERDAL();
            U_USR_LgnDAL          logDAL   = new U_USR_LgnDAL();
            SubAdmin              NewData  = new SubAdmin();
            U_ADM_MEDIA_MASTERDAL ImgDAL   = new U_ADM_MEDIA_MASTERDAL();
            U_ADM_MEDIA_MASTER    imgData  = new U_ADM_MEDIA_MASTER();
            U_USR_MASTER          NewData1 = new U_USR_MASTER();

            var OldData = userDAL.GetSingleSubAdminDetailsDb(usr.Usr_Id);

            if (!(string.IsNullOrEmpty(usr.Media_File_Location)))
            {
                imgData.Media_Id            = Guid.NewGuid().ToString();
                imgData.Media_Type          = "Image";
                imgData.Media_File_Location = usr.Media_File_Location;
                imgData.Media_Source        = " ";
                imgData.Media_Oth_Dtl       = " ";
                imgData.Created_by          = usr.Created_by;
                imgData.Updated_by          = usr.Updated_by;
                imgData.Created_Date        = DateTime.Now;
                imgData.Updated_Date        = DateTime.Now;
                ImgDAL.InsertU_ADM_MEDIA_MASTER(imgData);
                NewData.Media_File_Location = imgData.Media_Id;
            }
            else
            {
                NewData.Media_File_Location = userDAL.GetMemberMediaIdDb(usr.Usr_Id);
            }

            NewData.Usr_Id        = usr.Usr_Id;
            NewData.First_Name    = string.IsNullOrEmpty(usr.First_Name) ? OldData.First_Name : usr.First_Name;
            NewData.Last_Name     = string.IsNullOrEmpty(usr.Last_Name) ? OldData.Last_Name : usr.Last_Name;
            NewData.Alt_Email_Id  = string.IsNullOrEmpty(usr.Alt_Email_Id) ? OldData.Alt_Email_Id : usr.Alt_Email_Id;
            NewData.Gender        = string.IsNullOrEmpty(usr.Gender) ? OldData.Gender : usr.Gender;
            NewData.Usr_role_Id   = string.IsNullOrEmpty(Convert.ToString(usr.Usr_role_Id)) ? OldData.Usr_role_Id : usr.Usr_role_Id;
            NewData.Mobile_Number = string.IsNullOrEmpty(usr.Mobile_Number) ? OldData.Mobile_Number : usr.Mobile_Number;
            NewData.Login_status  = string.IsNullOrEmpty(Convert.ToString(usr.Login_status)) ? OldData.Login_status : usr.Login_status;
            NewData.Created_Date  = OldData.Created_Date;
            NewData.Updated_Date  = DateTime.Now;
            NewData.Created_by    = OldData.Created_by;
            NewData.Updated_by    = string.IsNullOrEmpty(usr.Updated_by) ? OldData.Updated_by : usr.Updated_by;

            NewData1.Usr_Id          = NewData.Usr_Id;
            NewData1.First_Name      = NewData.First_Name;
            NewData1.Last_Name       = NewData.Last_Name;
            NewData1.Gender          = NewData.Gender;
            NewData1.Usr_role_Id     = NewData.Usr_role_Id;
            NewData1.Media_Id_Img    = NewData.Media_File_Location;
            NewData1.Updated_Date    = NewData.Updated_Date;
            NewData1.Updated_by      = NewData.Updated_by;
            NewData1.Date_Of_Birth   = DateTime.Now;
            NewData1.Wed_anniversary = DateTime.Now;
            NewData1.Created_Date    = DateTime.Now;

            bool status = logDAL.UpdateMobileStatusDb(NewData.Usr_Id, NewData.Mobile_Number, NewData.Login_status, NewData.Updated_Date, NewData.Updated_by);

            status = userDAL.Update_SubAdminProfileDb(NewData1);

            return(true);
        }
Example #27
0
 public EditSubAdmin(SubAdmin model)
 {
     InitializeComponent(); _subAdmin = model;
 }
Example #28
0
 private void btn_Update_Click(object sender, EventArgs e)
 {
     try
     {
         string previousSubAdminUsername = _subAdmin.Username;
         if (txt_Firstname.Text == string.Empty)
         {
             MessageBox.Show("Firstname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Firstname.Focus();
             return;
         }
         if (txt_Lastname.Text == string.Empty)
         {
             MessageBox.Show("Lastname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Lastname.Focus();
             return;
         }
         if (txt_Email.Text == string.Empty)
         {
             MessageBox.Show("Email is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Email.Focus();
             return;
         }
         if (txt_Phone.Text == string.Empty)
         {
             MessageBox.Show("Phone number is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Phone.Focus();
             return;
         }
         if (usernameVerified == true && txt_Firstname.Text != string.Empty && txt_Lastname.Text != string.Empty &&
             Utilities.IsValidEmail(txt_Email.Text) && isEmailExisting == false && isPhoneNoExisting == false && Utilities.EnsureNumericOnly(txt_Phone.Text) &&
             txt_Email.Text != string.Empty && txt_Phone.Text != string.Empty)
         {
             Cursor.Current = Cursors.WaitCursor;
             SubAdmin subAdmin = new SubAdmin()
             {
                 SubId       = int.Parse(txt_ID.Text),
                 Firstname   = txt_Firstname.Text,
                 Lastname    = txt_Lastname.Text,
                 Email       = txt_Email.Text,
                 PhoneNo     = txt_Phone.Text,
                 Username    = txt_Username.Text,
                 UpdatedBy   = Utilities.USERNAME,
                 UpdatedDate = DateTime.Now.Date
             };
             if (_SubAdminRepo.UpdateSubAdmin(subAdmin))
             {
                 _SubAdminRepo.UpdateRecordsCreatedByUpdatedSubAdmin(previousSubAdminUsername, _subAdmin.SubId);
                 Cursor.Current = Cursors.Default;
                 MessageBox.Show("Sub admin updated successfully!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_Firstname.Focus();
             }
         }
         else
         {
             MessageBox.Show("Please ensure filled-in information is correct and complete!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }