private void Button1_Clicked(object sender, EventArgs e) { Vibration.Vibrate(TimeSpan.FromMilliseconds(3)); User user = new User() { firstName = Entry3.Text, lastName = Entry4.Text, password = Entry2.Text, phone = Entry1.Text, DOB = date.Date }; user.gender = (RadioButton1.IsChecked == true) ? "М" : "Ж"; //DbWorking.AddDeviceID(); if (DbWorking.RegUser(user)) { DisplayActionSheet("Кондитер", "Ок", null, "Вы успешно прошли регистрацию!", null, null); } else { DisplayActionSheet("Кондитер", "Ок", null, "Такой пользователь уже зарегистрирован!", null, null); } Navigation.PopAsync(); }
// добавляет id-телефона пользователя при регистрации static public void AddDeviceID() { if (!(DbWorking.checkDeviceID())) { var sql = @"INSERT INTO Device (DeviceId)" + $"VALUES(N'{deviceId}')"; SqlCommand sqlCommand = new SqlCommand(sql, connection); sqlCommand.ExecuteNonQuery(); } }
// добавление пользователя в базу данных static public bool RegUser(User register) { if (!(DbWorking.CheckPhone(register.phone))) { var sql = @"INSERT INTO Users (Role,FirstName,LastName, Password, Phone, Gender, DOB)" + $"VALUES({register.role}, N'{register.firstName}', N'{register.lastName}', N'{register.password}', N'{register.phone}'" + $", N'{register.gender}', N'{register.DOB.ToString("yyyy-MM-dd")}')"; SqlCommand sqlCommand = new SqlCommand(sql, connection); sqlCommand.ExecuteNonQuery(); return(true); } return(false); }
// добавление, обновление данных о курьерах static public bool AddCourier(User user) { if (DbWorking.CheckCourier(user.phone)) { var sql = $"UPDATE Courier SET Name = N'{user.firstName}', Zone = N'{user.zone}' WHERE Phone = N'{user.phone}'"; SqlCommand sqlCommand = new SqlCommand(sql, connection); sqlCommand.ExecuteNonQuery(); return(false); } else { var sql = $"INSERT INTO Courier VALUES(N'{user.firstName}', N'{user.phone}', N'{user.zone}')"; SqlCommand sqlCommand = new SqlCommand(sql, connection); sqlCommand.ExecuteNonQuery(); return(true); } }
void Button1_Clicked(object sender, EventArgs args) { Vibration.Vibrate(TimeSpan.FromMilliseconds(3)); if (DbWorking.CheckUser(Entry1.Text, Entry2.Text)) { DbWorking.UpdateToIO(1, Entry1.Text); if (DbWorking.isCheckMenu() == 0) { Application.Current.MainPage = new UserMenu(0); } else { Application.Current.MainPage = new AdminMenu(0); } } else { DisplayActionSheet("Кондитер", "Ок", null, "Вы ввели неверный логин или пароль! Повторите попытку", null, null); } }
public static void CheckIOAndroid() { DbWorking.AddDeviceID(); int check = DbWorking.CheckIO(); if (check == 1) { int isMenu = DbWorking.isCheckMenu(); if (isMenu == 0) { Application.Current.MainPage = new UserMenu(0); } else { Application.Current.MainPage = new AdminMenu(0); } } else { Application.Current.MainPage = new GuestMenu(0); } }