private void ImagePofile()
        {
            if (!string.IsNullOrEmpty(inputFile.Value))
            {
                var n              = 0;
                var getImage       = new Profile_image_table().getAllRecords();
                var positionString = getImage.Count == 0 ? 0 : int.Parse(getImage[getImage.Count - 1].Id);
                switch (positionString.ToString())
                {
                case "": n = 1; break;

                default: n = int.Parse(positionString.ToString()) + 1; break;
                }
                Stream stream    = inputFile.PostedFile.InputStream;
                var    filename  = Path.GetFileName(inputFile.PostedFile.FileName);
                var    imageName = enc.GetMD5(n.ToString()).ToLower() + ".jpg";
                var    saveTo    = Server.MapPath($"~/Images/{inputFile.PostedFile.FileName.Replace(filename, $"{imageName}")}");
                try
                {
                    var profImage = new Profile_image_table();
                    SaveImage(Ratio(inputFile.PostedFile.ContentLength), stream, saveTo);
                    profImage.insert(SV.Uid, imageName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    Session["image"]   = imageName;
                    Session["message"] = " Profile image has been updated!";
                }
                catch (Exception) {}
            }
        }
Beispiel #2
0
        private void ImagePofile()
        {
            saveBtn.ServerClick += delegate
            {
                if (!string.IsNullOrEmpty(inputFile.Value))
                {
                    var n = 0; var In = 0;
                    var getImage       = new Profile_image_table().getAllRecords();
                    var positionString = getImage.Count == 0 ? 0 : int.Parse(getImage[getImage.Count - 1].Id);
                    switch (positionString.ToString())
                    {
                    case "": n = 1; break;

                    default: n = int.Parse(positionString.ToString()) + 1; break;
                    }
                    Stream stream    = inputFile.PostedFile.InputStream;
                    var    filename  = Path.GetFileName(inputFile.PostedFile.FileName);
                    var    imageName = enc.GetMD5(n.ToString()).ToLower() + ".jpg";
                    var    saveTo    = Server.MapPath($"~/Images/{inputFile.PostedFile.FileName.Replace(filename, $"{imageName}")}");
                    try
                    {
                        var profImage = new Profile_image_table();
                        SaveImage(Ratio(inputFile.PostedFile.ContentLength), stream, saveTo);
                        profImage.insert(SV.Uid, imageName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Session["image"]   = imageName;
                        Session["message"] = elements.GetMesage(" Profile image has been updated!", HtmlElements.MessageType.SUCCESS, HtmlElements.UserType.MANAGEMENT);
                    }
                    catch (Exception) { }
                }
                else
                {
                    Session["message"] = elements.GetMesage(" Profile image has been updated!", HtmlElements.MessageType.SUCCESS, HtmlElements.UserType.MANAGEMENT);
                }
                Response.Redirect(nav.ManPicture);
            };
        }
Beispiel #3
0
 private void LoginEvent()
 {
     loginBtn.ServerClick += delegate
     {
         var redirectTo = string.Empty;
         redirectTo = nav.Index;
         var att    = int.Parse(Session["attempt"].ToString());
         var logins = new Login_table().Load_record_with(Login_table_support.Column.Username, Login_table_support.LogicalOperator.EQUAL_TO, userBox.Value);
         if (att > 0)
         {
             if (!string.IsNullOrEmpty(logins.Id))
             {
                 var attempts = int.Parse(logins.Attempts);
                 if (attempts > 0)
                 {
                     var d = enc.GetMD5(enc.StrongEncrypt(passBox.Value));
                     if (enc.GetMD5(enc.StrongEncrypt(passBox.Value)) == logins.Password)
                     {
                         var uDetails = new User_details().Load_record_with(User_details_support.Column.User_id, User_details_support.LogicalOperator.EQUAL_TO, logins.Id);
                         var uImage   = new Profile_image_table().Load_record_with(Profile_image_table_support.Column.User_id, Profile_image_table_support.LogicalOperator.EQUAL_TO, logins.Id);
                         Session["uid"]      = logins.Id;
                         Session["name"]     = uDetails.Fname + " " + uDetails.Lname;
                         Session["username"] = logins.Username;
                         Session["address"]  = uDetails.Address;
                         Session["contact"]  = uDetails.Contact;
                         Session["email"]    = uDetails.Email;
                         Session["gender"]   = uDetails.Gender;
                         Session["dob"]      = uDetails.Dob;
                         Session["staus"]    = uDetails.User_type;
                         Session["image"]    = uImage.Url;
                         logins.Attempts     = "3";
                         var f = UserTypes.MANAGEMENT.ToString();
                         if (uDetails.User_type == UserTypes.MANAGEMENT.ToString().ToLower())
                         {
                             redirectTo = nav.Dashboard;
                         }
                         else if (uDetails.User_type == UserTypes.PATIENT.ToString().ToLower())
                         {
                             redirectTo = nav.PatientHome;
                         }
                         else if (uDetails.User_type == UserTypes.DOCTOR.ToString().ToLower())
                         {
                             redirectTo = nav.DoctorHome;
                         }
                         else
                         {
                             redirectTo = nav.Index;
                         }
                     }
                     else
                     {
                         attempts           = attempts - 1;
                         logins.Attempts    = attempts.ToString();
                         Session["message"] = elements.GetMesage($"Wrong username or password! left with {attempts} attemps", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
                     }
                 }
                 else if (attempts == 0)
                 {
                     Session["message"] = elements.GetMesage($"Max attempts reached, try again later or contact the mnagement.", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
                 }
                 else
                 {
                     attempts           = attempts - 1;
                     logins.Attempts    = attempts.ToString();
                     Session["message"] = elements.GetMesage($"Wrong username or password! left with {attempts} attemps", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
                 }
             }
             else
             {
                 Session["message"] = elements.GetMesage("Wrong username or password!", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
             }
         }
         else if (att == 0)
         {
             Session["message"] = elements.GetMesage($"Max attempts reached, try again later or contact the mnagement.", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
         }
         else
         {
             att = att - 1;
             Session["attempt"] = att.ToString();
             Session["message"] = elements.GetMesage("Wrong username or password!", HtmlElements.MessageType.INFO, HtmlElements.UserType.ALL);
         }
         Response.Redirect(redirectTo);
     };
 }