コード例 #1
0
        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtCedula.Text))
            {
                ClientesCL clientesCL = new ClientesCL();
                clientesCL.EliminarCliente(this.txtCedula.Text);

                if (clientesCL.IsError)
                {
                    ErroresCl erroresCl = new ErroresCl();
                    string    text      = erroresCl.VentanaErrores(clientesCL.ErrorCode, "clientes");
                    MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    this.btnGuardar.Tag      = "1";
                    this.MenuAgregar.Enabled = true;
                    this.MenuEditar.Enabled  = true;
                    this.DesactivarCajas();
                }
                else
                {
                    MessageBox.Show("Cliente elimado con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.btnGuardar.Tag      = "1";
                    this.MenuAgregar.Enabled = true;
                    this.MenuEditar.Enabled  = true;
                    this.DesactivarCajas();
                }
            }
            else
            {
                MessageBox.Show("Cedula invalida para eliminar, debes elegir algun cliente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
コード例 #2
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.txtCedula.Text) || string.IsNullOrEmpty(this.txtNombre.Text))
     {
         MessageBox.Show("Faltan campos que llenar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         ClientesCL clientesCL = new ClientesCL();
         if (this.btnGuardar.Tag == "1")
         {
             clientesCL.InsertarCliente(this.txtCedula.Text, this.txtNombre.Text, this.txtTelefono.Text, this.txtCelular.Text, this.txtDireccion.Text, this.ckMoroso.Checked);
             if (clientesCL.IsError)
             {
                 ErroresCl erroresCl = new ErroresCl();
                 string    text      = erroresCl.VentanaErrores(clientesCL.ErrorCode, "clientes");
                 MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
             else
             {
                 MessageBox.Show("Cliente agregado: " + this.txtCedula.Text, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 this.MenuAgregar.Enabled = true;
                 this.MenuEditar.Enabled  = true;
                 this.DesactivarCajas();
             }
         }
         else
         {
             clientesCL.EditarCliente(this.txtCedula.Text, this.txtNombre.Text, this.txtTelefono.Text, this.txtCelular.Text, this.txtDireccion.Text, this.ckMoroso.Checked);
             if (clientesCL.IsError)
             {
                 ErroresCl erroresCl = new ErroresCl();
                 string    text      = erroresCl.VentanaErrores(clientesCL.ErrorCode, "clientes");
                 MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
             else
             {
                 MessageBox.Show("Cliente editado: " + this.txtCedula.Text, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 this.btnGuardar.Tag      = "1";
                 this.MenuAgregar.Enabled = true;
                 this.MenuEditar.Enabled  = true;
                 this.DesactivarCajas();
             }
         }
     }
 }