private void FillCustomerGrid() { try { DataTable CustomerDataTable = new DataTable(); CustomerDataTable = CustomerServiceBL.CustomerDetails.Ins.GetAllCustomerData(); if (CustomerDataTable.Rows.Count > 0) { Session["CustomerGrid"] = CustomerDataTable; CustomerGridView.DataSource = CustomerDataTable; CustomerGridView.DataBind(); } } catch (Exception ex) { throw ex; } finally { } }
protected void SearchCustomerButton_Click(object sender, EventArgs e) { String accType, name, address; obj = new BAL_Bank(); accType = AccountTypeTextBox.Text.ToString().Trim(); name = NameTextBox.Text.ToString().Trim(); address = AddressTextBox.Text.ToString().Trim(); try { datatable = obj.SearchCustomers(accType, name, address); CustomerGridView.DataSource = datatable; CustomerGridView.DataBind(); } catch (Exception) { ErrorLabel.Text = "Somthing went wrong"; } }
private void FillCustomerGridfromSession() { try { DataTable CustomerDetailsDatatable = new DataTable(); if (Session["CustomerGrid"] != "" && Session["CustomerGrid"] != null) { CustomerDetailsDatatable = (DataTable)Session["CustomerGrid"]; } if (CustomerDetailsDatatable.Rows.Count > 0) { CustomerGridView.DataSource = CustomerDetailsDatatable; CustomerGridView.DataBind(); } } catch (Exception ex) { throw ex; } finally { } }
protected void btnSave_Click(object sender, EventArgs e) { SqlDataSourceCustomer.InsertParameters["Customer_Name"].DefaultValue = Customer_Name.Text; SqlDataSourceCustomer.InsertParameters["Address"].DefaultValue = Address.Text; SqlDataSourceCustomer.InsertParameters["City"].DefaultValue = City.Text; SqlDataSourceCustomer.InsertParameters["State"].DefaultValue = State.Text; SqlDataSourceCustomer.InsertParameters["Zipcode"].DefaultValue = Zipcode.Text; SqlDataSourceCustomer.InsertParameters["Email"].DefaultValue = Email.Text; SqlDataSourceCustomer.InsertParameters["Phone"].DefaultValue = Phone.Text; SqlDataSourceCustomer.InsertParameters["Fax"].DefaultValue = Fax.Text; SqlDataSourceCustomer.Insert(); CustomerGridView.DataBind(); panelAddCustomer.Visible = false; panelSaveCustomer.Visible = true; Fax.Text = string.Empty; Phone.Text = string.Empty; Email.Text = string.Empty; Zipcode.Text = string.Empty; State.Text = string.Empty; City.Text = string.Empty; Address.Text = string.Empty; Customer_Name.Text = string.Empty; }
private void CustomerManageForm_Shown(object sender, EventArgs e) { CustomerGridView.ClearSelection(); CustomerGridView.RowEnter += CustomerGridView_RowEnter; }
public void LoadCustomers() { CustomerGridView.DataSource = _CustomerRepository.GetAllCustomers(); CustomerGridView.DataBind(); }
protected void rechercherButton_Click(object sender, EventArgs e) { SqlConnection northWindSqlConnection = null; SqlDataReader customerSqlDataReader = null; CustomerGridView.Visible = true; try { // Définir les paramètres de la connexion northWindSqlConnection = new SqlConnection(Properties.Settings.Default.NorthWindConnectionString); // Identifier la procédure stockée "Stored Procedure" SqlCommand customerSqlCommand; customerSqlCommand = new SqlCommand(); customerSqlCommand.Connection = northWindSqlConnection; customerSqlCommand.CommandType = CommandType.Text; customerSqlCommand.CommandText = "SELECT CompanyName, ContactName, ContactTitle, Country, Phone FROM Customers WHERE Country = @countryVar"; // Définir le paramètre de la procédure stockée SqlParameter customerIDSqlParameter = new SqlParameter(); customerIDSqlParameter.Direction = ParameterDirection.Input; customerIDSqlParameter.ParameterName = "@countryVar"; customerIDSqlParameter.SqlDbType = SqlDbType.NVarChar; customerIDSqlParameter.Value = payerTextBox.Text; customerSqlCommand.Parameters.Add(customerIDSqlParameter); // Ouvrir la connexion northWindSqlConnection.Open(); customerSqlDataReader = customerSqlCommand.ExecuteReader(); // Afficher l'information sur la page Web (utilisant un GridView) DataTable customerDataTable = new DataTable(); customerDataTable.Load(customerSqlDataReader); // Automatiquement ferme le DataReader CustomerGridView.DataSource = customerDataTable; CustomerGridView.DataBind(); // TOUJOURS COMPLEX BINDING ASP:Controles if (CustomerGridView.Rows.Count <= 1) { NombreClientLabel.Text = "il y a " + CustomerGridView.Rows.Count + " client dans le payer: " + payerTextBox.Text; } else { NombreClientLabel.Text = "il y a " + CustomerGridView.Rows.Count + " clients dans le payer: " + payerTextBox.Text; } } catch (Exception customerException) { this.Response.Write(customerException.ToString()); } finally { // Fermer la connexion if (customerSqlDataReader != null) { if (!customerSqlDataReader.IsClosed) { customerSqlDataReader.Close(); } } if (northWindSqlConnection != null) { if (northWindSqlConnection.State == ConnectionState.Open) { northWindSqlConnection.Close(); } } } }