public HttpResponseMessage PostAdLogin([FromBody] Admin1 ad) { try { using (BankingDbEntities db = new BankingDbEntities()) { //var Obj = db.Admins.Find(ad.Admin_Id); var Obj = db.Admins.Where(a => a.Admin_Id == ad.Admin_Id).First(); var obj2 = Obj.Password; if (obj2 != ad.Password) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Admin invalid")); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Successful Login.")); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public int Login(Admin1 m) { string sql = $"select * from admin where adminname='{m.AdminName}' and adminpassword='******'"; DataSet ds = _db.GetDateSet(sql); int h = ds.Tables[0].Rows.Count; return(h); }
public ActionResult Login(Admin1 admin, string ReturnUrl = "") { try { if (ModelState.IsValid) { string message = admin.Login(); if (message.Equals("1")) { int timeout = 1440; // 1440 min = 1 day var ticket = new FormsAuthenticationTicket(admin.UserName, false, timeout); string encrypted = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie("admin", encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); Response.Cookies.Add(cookie); if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { return(RedirectToAction("Index", "Admin")); } } else { ViewBag.ErrorMessage = message; } } return(View()); } catch { return(View()); } }
public IActionResult Login(Admin1 m) { int h = _bll.Login(m); return(Ok(new { msg = h > 0?"登陆成功!":"用户名或密码不正确!", state = h > 0?true:false })); }
static void Main(string[] args) { //Console.WriteLine(Calculate()); const string constring = @"Data source=localhost; initial catalog=Client; Integrated Security=True"; SqlConnection con = new SqlConnection(constring); Console.WriteLine(@" Если вы уже регистрированый в приложении введите 1: иначе чтобы регистрироваться введите 2: Если хотите войти в качестве Admina то выводите 3: "); string n = Console.ReadLine(); T22 : int t = 0; if (n == "1") { while (t != 1) { con.Open(); Console.WriteLine("Введите Login:"******"Введите Parol:"); string s1 = Console.ReadLine(); string selectParol = "Select * from Registraciya"; SqlCommand commandText1 = new SqlCommand(selectParol, con); SqlDataReader reader = commandText1.ExecuteReader(); while (reader.Read()) { if (Convert.ToString(reader.GetValue("login")) == s && Convert.ToString(reader.GetValue("Parol")) == s1) { t = 1; Console.WriteLine("Добро пожаловать в свой личный кабинет"); Console.WriteLine(@" выводите 1 чтобы подать заявку выводите 2 если хотите посмотреть свои заявки выводите 3 если хотите оплатить кредита выводите 4 если хотите видит свои графики выводите 5 если хотите погащать свой кредит выводите 6 если хотите посмотреть остаток кредита выводите 6"); con.Close(); string s3 = Console.ReadLine(); if (s3 == "1") { Zayavka(s); } if (s3 == "2") { ProsmotrZayavka(s); } if (s3 == "4") { string selectSrok = $"Select * from Zayavka where [серийный номер]='{s}'"; SqlCommand commandText3 = new SqlCommand(selectSrok, con); con.Open(); SqlDataReader reader3 = commandText3.ExecuteReader(); reader3.Read(); int a = Convert.ToInt32(reader3.GetValue("срок кредита")); con.Close(); reader3.Close(); string selectSum = $"Select * from Zayavka where [серийный номер]='{s}'"; SqlCommand commandText4 = new SqlCommand(selectSum, con); con.Open(); SqlDataReader reader4 = commandText4.ExecuteReader(); reader4.Read(); int b = Convert.ToInt32(reader4.GetValue("сумма кредита")); reader4.Close(); con.Close(); int c = b / a; Console.WriteLine($"В течении {a} месяцов вы должни каждый месяц погашать по {c} сомони"); string addkredit = $"insert into KREDIT12([каждый месяц сколько должни],[остаток кредита],[серыйный номер]) Values('{c}','{b}','{s}')"; SqlCommand commandText5 = new SqlCommand(addkredit, con); con.Open(); var result = commandText5.ExecuteNonQuery(); goto T45; } if (s3 == "5") { string selectSrok = $"Select * from KREDIT12 where [серыйный номер]='{s}'"; SqlCommand commandText3 = new SqlCommand(selectSrok, con); con.Open(); SqlDataReader reader3 = commandText3.ExecuteReader(); reader3.Read(); int a = Convert.ToInt32(reader3.GetValue("остаток кредита")); int b = Convert.ToInt32(reader3.GetValue("каждый месяц сколько должни")); int c = a - b; if (a - b <= 0) { Console.WriteLine("У вас больше нету остатков кредита"); } con.Close(); string updateSrok = $"update KREDIT12 set [остаток кредита]={c} WHERE [серыйный номер]='{s}'"; SqlCommand commandText5 = new SqlCommand(updateSrok, con); con.Open(); var result = commandText5.ExecuteNonQuery(); con.Close(); goto T89; } if (s3 == "6") { showspisok(s); goto T19; } } } if (t == 0) { Console.WriteLine("Вы неправильно ввели Parol или Login"); } con.Close(); } } T89: Console.WriteLine(455464654646); T45: T19: if (n == "2")///////// Здесь заполняем поля для регистрации { string[] s2 = new string[] { "Firstname:", "Lastname:", "Middlename:", "BirthDate:", "Date of issue:", "Date of expire:", "Document №:", "Addres:", "Marital status", "Pol", "login", "Parol" }; string[] S = new string[] {}; string s1 = ""; Array.Resize(ref S, 12); int t1 = 0, k = 0; for (int j = 0; j < 10; j++) { t1 = 0; while (t1 != 1) { Console.WriteLine($"Выводите {s2[j]}"); s1 = Console.ReadLine(); if (string.IsNullOrWhiteSpace(s1)) { Console.WriteLine("Этот поля не должно быть пустым"); } else { t1 = 1; S[j] = s1; } } } t1 = 0; while (t1 != 1) { con.Open(); string selectParol = "Select * from Registraciya"; SqlCommand commandText1 = new SqlCommand(selectParol, con); SqlDataReader reader = commandText1.ExecuteReader(); string n13 = ""; Console.WriteLine($"Выводите {s2[10]}"); n13 = Console.ReadLine(); k = 0; while (reader.Read()) { if (Convert.ToString(reader.GetValue("login")) == n13) { k = 1; } } if (k != 1) { S[10] = n13; t1 = 1; } else { Console.WriteLine("Такой Login уже существуеть"); } con.Close(); } Console.WriteLine($"Введите {s2[11]}"); S[11] = Console.ReadLine(); Regist Client = new Regist(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], S[8], S[9], S[10], S[11]); Client.addRegistr(); t = 0; /////////////////////////////////////////////////////////////////////////////////////////////////////////// Console.WriteLine("Для дальнейший регистрации нужно запольнить анкету нажмите любую клавишу"); Console.ReadKey(); string[] s8 = new string[] {};///////Массив для сохранения данных Анкет; string n12; Array.Resize(ref s8, 10); int i = 0; t = 0; s8[i] = S[10]; // con.Close(); i++; T20 : Console.WriteLine($"Выберите пол"); Console.WriteLine(@"выводите 1 если муж выводите 2 если жен"); n12 = Console.ReadLine(); switch (n12) { case "1": s8[i] = "муж"; break; case "": s8[i] = "жен"; break; default: { Console.WriteLine("Неверная команда повторите пожалуйста еще раз"); goto T20; } } i++; T10 : Console.WriteLine("Выберите Семейное положение"); Console.WriteLine(@"Выводите 1 если холост 2 если семянин 3 если вразвоед 4 если вдовец/вдова"); n12 = Console.ReadLine(); switch (n12) { case "1": { s8[i] = "холост"; break; } case "2": { s8[i] = "семеянин"; break; } case "3": { s8[i] = "вразводе"; break; } case "4": { s8[i] = "вдовец/вдова"; break; } default: { Console.WriteLine("Пожалуйста вывоводите правильно то что требуется "); goto T10; } } t = 0; i++; Console.WriteLine("Введите возраст"); s8[i] = Console.ReadLine(); T11 : Console.WriteLine(@"Введите 1 если вы Гражданин Таджикистана 2 если вы гражданин другого государство"); n12 = Console.ReadLine(); i++; switch (n12) { case "1": s8[i] = "Таджикистан"; break; case "2": s8[i] = "Таджикистан"; break; default: { Console.WriteLine("Пожалуйста введите правильно то что требуется"); goto T11; } } i++; int number; T : Console.WriteLine("Введите Сумма кредита от общего дохода в %"); string input = Console.ReadLine(); if (int.TryParse(input, out number)) { s8[i] = input; } else { goto T; } i++; T1 : Console.WriteLine("Выводите кредитную историю"); string input1 = Console.ReadLine(); if (int.TryParse(input1, out number)) { s8[i] = input1; } else { goto T1; } i++; T5 : Console.WriteLine("Выводите просрока в кредитной истории"); string input3 = Console.ReadLine(); if (int.TryParse(input3, out number)) { s8[i] = input1; } else { Console.WriteLine("Непрвильно ввели число"); goto T5; } i++; T2 : Console.WriteLine(@"Цель Кредита введите 1 если это бытовая техника 2 если это ремонт 3 если телефон 4 если прочее"); string n1 = Console.ReadLine(); switch (n1) { case "1": { s8[i] = "бытовая техника"; break; } case "2": { s8[i] = "ремонт"; break; } case "3": { s8[i] = " телефон"; break; } case "4": { s8[i] = "прочее"; break; } default: { Console.WriteLine("Не правилно ввели команду повторите еще раз"); goto T2; } } i++; T3 : Console.WriteLine("Введите срок кредита"); string input2 = Console.ReadLine(); if (int.TryParse(input1, out number)) { s8[i] = input2; } else { goto T3; } Anceta p1 = new Anceta(s8[0], s8[1], s8[2], s8[3], s8[4], s8[5], s8[6], s8[7], s8[8], s8[9]); t = 0; //Calculate(s8[0]); p1.addanceta(); if (Calculate() > 11) { Console.WriteLine("Чтобы подать заявку нужно войти вличный кабинет для этого надо нажать любую клавищу"); Console.ReadKey(); n = "1"; goto T22; } else { Console.WriteLine(Calculate()); Console.WriteLine("Извенити что мы не сможем вам заполнить заявку на кредите т.к ваш бали нехватает"); } } string s5 = "", s6 = ""; t = 0; if (n == "3") { T1 : Console.WriteLine("Введите Login:"******"Введите Parol:"); s6 = Console.ReadLine(); con.Open(); string selectParol = "Select * from Admin1"; SqlCommand commandText1 = new SqlCommand(selectParol, con); SqlDataReader reader = commandText1.ExecuteReader(); while (reader.Read()) { if (Convert.ToString(reader.GetValue("login")) == s5 && Convert.ToString(reader.GetValue("Parol")) == s6) { t = 1; Console.WriteLine("Добро пожаловать в личный кабинет Админа"); Console.WriteLine("Если хотите посмотреть заявок всех клиентов выводите 1"); Console.WriteLine("Если хотите добавить Админа введите 2"); n = Console.ReadLine(); //reader.Close(); con.Close(); if (n == "1") { ProsmotrZayavkaAdmin(); reader.Close(); con.Close(); } if (n == "2")///////////////////// { Console.WriteLine("Вводите Firstname"); string s1 = Console.ReadLine(); Console.WriteLine("Вводите Lastname"); string s2 = Console.ReadLine(); Console.WriteLine("Вводите Middlename"); string s3 = Console.ReadLine(); T9 : Console.WriteLine("Вводите Login"); string s4 = Console.ReadLine(); con.Open(); string SelectAdmin1 = $"select Login from Admin1"; SqlCommand commandText13 = new SqlCommand(SelectAdmin1, con); reader = commandText13.ExecuteReader(); while (reader.Read()) { if (Convert.ToString(reader.GetValue("Login")) == s4) { Console.WriteLine("Такой Login уже существует"); con.Close(); goto T9; } } con.Close(); Console.WriteLine("Вводите Parol"); string s51 = Console.ReadLine(); reader.Close(); Admin1 p = new Admin1(s1, s2, s3, s4, s51); p.addAdmin(); reader.Close(); goto T26; } } goto T56; } T26: T56: if (t == 1) { } else { Console.WriteLine("Не правильный Parol или Login"); //reader.Close(); con.Close(); goto T1; } } }