Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtIDClient.Text != "")
                {
                    newClient.ID          = txtIDClient.Text.Trim();
                    newClient.Name        = txtNameClient.Text.Trim();
                    newClient.IdBand      = (int)cbBands.SelectedValue;
                    newClient.Email       = txtEmailClient.Text.Trim();
                    newClient.Address     = txtAddressClient.Text.Trim();
                    newClient.Phone       = txtPhoneClient.Text.Trim();
                    newClient.MobilePhone = txtCelClient.Text.Trim();
                    newClient.Credit      = Convert.ToDouble(txtCreditClient.Text.Trim().Replace("$", ""));

                    daoClient.insertClient(newClient);
                    CargarClientsGrid();

                    MessageBox.Show("Cliente guardado:\n" + newClient.Name,
                                    "Información",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("El campo Identificación no debe ir vacío", "Validación del sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.Message,
                                "Error al insertar",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }