//Método para Refrescar la información de la tabla private void RefreshDataGridView() { List <Supplier> supplier = BusinessSupplier.GetAllSuppliers().ToList(); this.dtgridSupplier.DataSource = supplier; DisabledFields(); }
//Método para insertar proveedor private void btInsert_Click(object sender, EventArgs e) { bool isValid = ValidateField(); if (isValid) { Supplier supplier = new Supplier() { SupplierName = this.txtInsertName.Text, SupplierCif = this.txtInsertCif.Text, SupplierEmail = this.txtInsertMail.Text, SupplierAdress = this.txtInsertAddress.Text, SupplierTelephone = this.txtInsertPhone.Text, SupplierId = Guid.NewGuid() }; var hasBeenInserted = BusinessSupplier.InsertSupplier(supplier); if (hasBeenInserted) { RefreshDataGridView(); MessageBox.Show("Proveedor insertado correctamente"); CleanInsertFields(); } else { MessageBox.Show("Error al insertar proveedor"); } } }
private void AddSuppliersToList(object sender, DataGridViewCellEventArgs e) { var rows = this.dataGridView1.CurrentRow; if (rows == null) { return; } var supplier = BusinessSupplier.GetSupplierById(new Guid(rows.Cells["SupplierId"].Value.ToString())); this._buys.AddSupplier(supplier); this.Hide(); }
//Método para borrar proveedor private void btDeleteSupplier_Click(object sender, EventArgs e) { var rows = this.dtgridSupplier.CurrentRow; if (rows != null) { var isDeleted = BusinessSupplier.DeleteSupplier(new Guid(rows.Cells["Id"].Value.ToString())); if (isDeleted) { RefreshDataGridView(); CleanFields(); MessageBox.Show("Proveedor borrado correctamente"); } else { MessageBox.Show("Error borrando proveedor"); } } else { MessageBox.Show("Debe seleccionar una fila que borrar"); } }
//Método para actualizar proveedor private void btUpdateSupplier_Click(object sender, EventArgs e) { Supplier supplier = new Supplier() { SupplierName = this.txtNameSupplier.Text, SupplierCif = this.txtCIF.Text, SupplierEmail = this.txtMailSupplier.Text, SupplierAdress = this.txtAddressSupplier.Text, SupplierTelephone = this.txtPhoneSupplier.Text, SupplierId = new Guid(this.lbId.Text) }; bool isUpdated = BusinessSupplier.UpdateSupplier(supplier); if (isUpdated) { RefreshDataGridView(); CleanFields(); MessageBox.Show("Proveedor actualizado correctamente"); } else { MessageBox.Show("Ha ocurrido un error actualizando los campos del proveedor"); } }
private void ViewSupplier_Load(object sender, EventArgs e) { this.dataGridView1.DataSource = BusinessSupplier.GetAllSuppliers().ToList(); }
private void SearchSupplier(object sender, EventArgs e) { this.dataGridView1.DataSource = BusinessSupplier.SearchSupplier(this.txtProductSearch.Text); }
//Método para buscar proveedor private void searchSupplier(object sender, EventArgs e) { this.dtgridSupplier.DataSource = BusinessSupplier.SearchSupplier(this.txtSearchSupplier.Text); }