private void bt_editClient_Click(object sender, RoutedEventArgs e) { Classes.Client c = (Classes.Client)((Classes.Client.displayInfo)((System.Windows.Controls.Button)e.Source).DataContext).CurInstance; BoVeloManager.UI.Sales.Client.EditHumanWindow ECW = new UI.Sales.Client.EditHumanWindow(c); ECW.ShowDialog(); update_dg_clientList(); }
public List <Classes.Client> GetClients() { SqlConnection connection = new SqlConnection(); connection.ConnectionString = Util.GetConnectionString(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetClients"; List <Classes.Client> clients = new List <Classes.Client>(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Classes.Client client = new Classes.Client() { ClientID = int.Parse(reader["ClientID"].ToString()), FirstName = reader["FirstName"].ToString(), MiddleName = reader["MiddleName"].ToString(), LastName = reader["LastName"].ToString(), Email = reader["Email"].ToString(), Phone = reader["Phone"].ToString(), Address = reader["Address"].ToString() }; clients.Add(client); } return(clients); }
private void ConfirmeBtn_Click(object sender, RoutedEventArgs e) { if (MyTxBView != null) { if (MyTxBView.EmailTxb.Text.Length == 0) { MyTxBView.errormessage.Text = "Enter an email."; MyTxBView.EmailTxb.Focus(); } else if (!Regex.IsMatch(MyTxBView.EmailTxb.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MyTxBView.errormessage.Text = "Enter a valid email."; MyTxBView.EmailTxb.Select(0, MyTxBView.EmailTxb.Text.Length); MyTxBView.EmailTxb.Focus(); } else { string f_name = MyTxBView.FirstNameTxb.Text; string l_name = MyTxBView.LastNameTxb.Text; string email = MyTxBView.EmailTxb.Text; string password = MyTxBView.PasswordPbx.Password; if (MyTxBView.PasswordPbx.Password.Length == 0) { MyTxBView.errormessage.Text = "Enter password."; MyTxBView.EmailTxb.Focus(); } else if (MyTxBView.RePasswordPbx.Password.Length == 0) { MyTxBView.errormessage.Text = "Enter Confirm password."; MyTxBView.RePasswordPbx.Focus(); } else if (MyTxBView.PasswordPbx.Password != MyTxBView.RePasswordPbx.Password) { MyTxBView.errormessage.Text = "re-password must be the same as password."; MyTxBView.RePasswordPbx.Focus(); } else { MyTxBView.errormessage.Text = ""; //trail from here if (userType == "client") { Classes.Client MyClient = new Classes.Client(f_name, l_name, email, password); Mydatabase.addToDB(MyClient, userType); } else { Classes.ServicePersonal MyServicePersonal = new Classes.ServicePersonal(f_name, l_name, email, password); Mydatabase.addToDB(MyServicePersonal, userType); } MyTxBView.errormessage.Text = "You have Registered successfully."; ClearValues(); } } } }
public IActionResult OnGet() { string username = GetSessionValue("Username"); if (username == null || username == string.Empty) { return(new RedirectToPageResult("Index")); } int appointmentID = int.Parse(HttpContext.Session.GetString("UpdateAppointmentID")); System.Diagnostics.Debug.WriteLine($"UpdateAppointment: Updating appointment: {appointmentID}"); ResolutionsSystem rs = new ResolutionsSystem(); Classes.Appointment app = rs.GetAppointment(appointmentID); AppointmentID = app.AppointmentID; AppointmentDate = app.AppointmentDate; Classes.Client client = rs.GetClient(app.ClientID); ClientID = (int)client.ClientID; if (client.MiddleName == null) { ClientFullName = $"{client.FirstName} {client.LastName}"; } else { ClientFullName = $"{client.FirstName} {client.MiddleName} {client.LastName}"; } Classes.Counsellor counsellor = rs.GetCounsellor(app.CounsellorID); CounsellorID = counsellor.CounsellorID; CounsellorName = counsellor.Name; //Message = $"Updating appointment {appointmentID}\n" + // $"Date: {app.AppointmentDate}\n" + // $"Client Name: {clientName} ({client.ClientID})\n" + // $"Counsellor: {counsellor.Name} ({counsellor.CounsellorID})"; System.Diagnostics.Debug.WriteLine($"Updated appointment: {(int)AppointmentID}"); //PopulateFields(app); //counsellors dropdownlist //PopulateSelectList(); //ListOfCounsellors = rs.GetCounsellors(); //client dropdownlist //PopulateSelectListForClient(); //ListOfClients = rs.GetClients(); return(Page()); }
private Classes.Client GetClient() { Classes.Client newClient = new Classes.Client() { FirstName = this.FirstName, MiddleName = this.MiddleName, LastName = this.LastName, Phone = this.Phone, Email = this.Email, Address = this.Address }; return(newClient); }
public Classes.Client GetClientByID(int ClientID) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = Util.GetConnectionString(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetClientByID"; SqlParameter parameter = new SqlParameter() { ParameterName = "@ClientID", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, SqlValue = ClientID }; command.Parameters.Add(parameter); SqlDataReader reader = command.ExecuteReader(); Classes.Client client = new Classes.Client(); reader.Read(); if (reader.HasRows) { client = new Classes.Client() { ClientID = int.Parse(reader["ClientID"].ToString()), FirstName = reader["FirstName"].ToString(), MiddleName = reader["MiddleName"].ToString(), LastName = reader["LastName"].ToString(), Email = reader["Email"].ToString(), Phone = reader["Phone"].ToString(), Address = reader["Address"].ToString() }; } return(client); }
private void createButton_Click(object sender, EventArgs e) { FixAndFlux.Classes.Client client = new Classes.Client(); client.ClientFirstName = firstNameTextBox.Text; client.ClientName = nameTextBox.Text; client.Phone = phoneTextBox.Text; client.Email = emailTextBox.Text; bool result = client.Insert(client); if (result) { MessageBox.Show("Client inserted successfully!"); } else { MessageBox.Show("Client not inserted"); } this.Close(); }
public SqlCode DeleteClient(Classes.Client Client) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = Util.GetConnectionString(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; //command.CommandText = "SoftDeleteClient"; Soft delete = not removed from db? command.CommandText = "DeleteClient"; SqlParameter parameter = new SqlParameter { ParameterName = "@ClientID", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, SqlValue = (int)Client.ClientID }; command.Parameters.Add(parameter); int returnVal; SqlCode code; try { returnVal = command.ExecuteNonQuery(); code = SqlCode.Success; } catch (Exception e) { System.Diagnostics.Debug.WriteLine($"e: {e.Message}"); code = SqlCode.Failure; } connection.Close(); return(code); }
private void button7_Click(object sender, EventArgs e) { //enregistrer, modifier, ou supprimer un client string a = ""; try { client = new Classes.Client(txtCode.Text, txtNom.Text, txtQuartier.Text, Convert.ToInt32(txtTel.Text)); switch (operationcli) { case "Ajouter": a = client.addClient(); break; case "Modifier": a = client.UpadateClient(); break; case "Supprimer": a = client.DeleteClient(); break; default: MessageBox.Show("Veuillez Selectionner une Opération !!!"); break; } if (a == "1") { viderClient(); MessageBox.Show("Opérqtion effectuée !!!"); } else { MessageBox.Show(a); } } catch (Exception ex) { MessageBox.Show("Erreur: " + ex.Message); } }
public SqlCode UpdateClient(Classes.Client Client) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = Util.GetConnectionString(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "UpdateClient"; SqlParameter parameter = new SqlParameter { ParameterName = "@ClientID", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Input, SqlValue = (int)Client.ClientID }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@FirstName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.FirstName }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@MiddleName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.MiddleName }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@LastName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.LastName }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@Email", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.Email }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@Phone", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.Phone }; command.Parameters.Add(parameter); parameter = new SqlParameter { ParameterName = "@Address", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = Client.Address }; command.Parameters.Add(parameter); int returnVal; SqlCode code; try { returnVal = command.ExecuteNonQuery(); code = SqlCode.Success; } catch (Exception e) { System.Diagnostics.Debug.WriteLine($"e: {e.Message}"); code = SqlCode.Failure; } connection.Close(); return(code); }
public Classes.Client GetClientByName(string FirstName, string MiddleName, string LastName) { SqlConnection connection = new SqlConnection(); connection.ConnectionString = Util.GetConnectionString(); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "GetClientByName"; SqlParameter parameter = new SqlParameter() { ParameterName = "@FirstName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = FirstName }; command.Parameters.Add(parameter); parameter = new SqlParameter() { ParameterName = "@LastName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = LastName }; command.Parameters.Add(parameter); if (MiddleName != string.Empty) { parameter = new SqlParameter() { ParameterName = "@MiddleName", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, SqlValue = MiddleName }; command.Parameters.Add(parameter); } SqlDataReader reader = command.ExecuteReader(); reader.Read(); Classes.Client client = new Classes.Client(); if (reader.HasRows) { System.Diagnostics.Debug.WriteLine($"Reader[0]: {reader[0].ToString()}"); int clientID = int.Parse(reader["ClientID"].ToString()); System.Diagnostics.Debug.WriteLine($"ClientID: {clientID}"); System.Diagnostics.Debug.WriteLine($"MiddleName: {MiddleName}"); client = new Classes.Client() { ClientID = int.Parse(reader["ClientID"].ToString()), FirstName = reader["FirstName"].ToString(), MiddleName = reader["MiddleName"].ToString(), LastName = reader["LastName"].ToString(), Email = reader["Email"].ToString(), Phone = reader["Phone"].ToString(), Address = reader["Address"].ToString() }; } return(client); }
public AccesClients(string sChaineConnexion) : base(sChaineConnexion) { Table = "Clients"; _classesBase = new Classes.Client(); }