private void btnAdd_Click(object sender, EventArgs e) { string name = txtCusName.Text; string surname = txtCusSurname.Text; string contact = txtCusContact.Text; string address = txtCusAddress.Text; string email = txtCusEmail.Text; string activeContract = "NO"; string contractExpiration = null; Validator v = new Validator(); bool valid = v.VailidateString(name); if (valid == true) { UIDGenerator ug = new UIDGenerator(); string CusID = ug.GenerateCustomerUID(serialClient); Client c = new Client(); c.InsertBLCustomer(CusID, name, surname, address, contact, email, activeContract); this.Close(); } else { MessageBox.Show("Please fill in all fields"); } }
public void RefreshPage() //---------------------------------------------------------------------Page Refresh here { //Retrieves product Data List <Product> productData = new List <Product>(); BindingSource bs = new BindingSource(); lstProducts.Items.Clear(); Product pd = new Product(); productData = pd.GetBLProduct(); bs.DataSource = productData; dgvProduct.DataSource = bs; dgvProduct.Columns[0].Visible = false; dgvProduct.Columns[2].Visible = false; dgvProduct.Columns[3].Visible = false; dgvProduct.AutoResizeColumns(); //Retrieves Configuration Data List <Configuration> confData = new List <Configuration>(); BindingSource bsConf = new BindingSource(); lstConfiguration.Items.Clear(); Configuration c = new Configuration(); confData = c.GetBLConfiguration(); bsConf.DataSource = confData; dgvConfiguration.DataSource = bsConf; dgvConfiguration.Columns[0].Visible = false; dgvConfiguration.Columns[2].Visible = false; //Retrieves Client Data List <Client> clientData = new List <Client>(); Client client = new Client(); clientData = client.GetCustomer(); dgvCustomers.DataSource = clientData; dgvCustomers.AutoResizeColumns(); dgvCustomers.Columns[0].Visible = false; dgvCustomers.Columns[3].Visible = false; dgvCustomers.Columns[4].Visible = false; dgvCustomers.Columns[5].Visible = false; dgvCustomers.Columns[6].Visible = false; dgvCustomers.Columns[7].Visible = false; //Retrieves ClientUID int clientSerial = dgvCustomers.RowCount + 1; UIDGenerator g = new UIDGenerator(); clientID = g.GenerateCustomerUID(clientSerial); }