private Cliente CargarCliente()
        {
            string nombre    = txtnombre.Text;
            string apellido  = txtapellido.Text;
            string direccion = txtdireccion.Text;
            string mail      = txtmail.Text;
            string telefono  = txttelefono.Text;

            bool     estado   = checkBox1.Checked;
            DateTime fechanac = dateTimePicker1.Value;

            string msj = "";

            msj += ValidacionesHelper.ValidarFecha(fechanac);
            msj += ValidacionesHelper.ValidarInt(txtdni.Text, "Dni");
            msj += ValidacionesHelper.ValidarSTRING(nombre, "Nombre");
            msj += ValidacionesHelper.ValidarSTRING(apellido, "Apellido");
            msj += ValidacionesHelper.ValidarSTRING(direccion, "Direccion");
            msj += ValidacionesHelper.ValidarSTRING(mail, "Email");
            msj += ValidacionesHelper.ValidarSTRING(telefono, "Telefono");

            if (!string.IsNullOrWhiteSpace(msj))
            {
                throw new Exception(msj.ToString());
            }
            int     dni     = int.Parse(txtdni.Text);
            Cliente cliente = new Cliente(dni, nombre, apellido, direccion, estado, mail, telefono, fechanac, _clienteServicio.ProximoId());

            return(cliente);
        }
示例#2
0
        private void Agregar_Click(object sender, EventArgs e)
        {
            if (this.Codigo.TextLength < 1 || this.Crucero.TextLength < 1 || this.Viaje.TextLength < 1)
            {
                MessageBox.Show("Debe completar todos los campos");
            }
            else
            {
                try
                {
                    ValidacionesHelper.validarCampoSoloNumerico(this.Viaje);
                    if (this.dateTimePicker1.Value >= this.dateTimePicker2.Value)
                    {
                        MessageBox.Show("La fecha de fin debe ser mayor a la de inicio");
                    }
                    else
                    {
                        if (DBAdapter.checkIfExists("crucero_no_disponible", Crucero.Text, Convert.ToDateTime(dateTimePicker1.Value), Convert.ToDateTime(dateTimePicker2.Value)))
                        {
                            MessageBox.Show("El crucero no esta disponible en esas fechas");
                        }


                        else
                        {
                            DBAdapter.insertarDatosEnTabla("viaje", Viaje.Text, Codigo.Text, Convert.ToDateTime(dateTimePicker1.Value), Convert.ToDateTime(dateTimePicker2.Value), Crucero.Text);
                            MessageBox.Show("Viaje dado de alta");
                        }
                    }
                }
                catch
                {
                }
            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Codigo.TextLength < 1 || Precio.TextLength < 1 || string.IsNullOrEmpty(this.textBox1.Text) || string.IsNullOrEmpty(this.textBox2.Text))
            {
                MessageBox.Show("Debe completar todos los campos");
            }
            else
            {
                if (String.Equals(this.textBox1.Text, this.textBox2.Text))
                {
                    MessageBox.Show("El puerto de origen debe ser diferente al puerto de destino");
                }
                else
                {
                    ValidacionesHelper.validarCampoSoloNumerico(this.Codigo);
                    ValidacionesHelper.validarCampoSoloNumerico(this.Precio);
                    if (DBAdapter.checkIfExists("recorrido_finalizado", Codigo.Text, Convert.ToDateTime(System.Configuration.ConfigurationManager.AppSettings["fechaSistema"])))
                    {
                        MessageBox.Show("Ese recorrido ya fue realizado");
                    }
                    else
                    {
                        DataSet dsrecorrido = DBConnection.getInstance().executeQuery(QueryProvider.SELECT_RECORRIDOS_MAX_ID(this.Codigo.Text));
                        if (dsrecorrido.Tables[0].Rows.Count > 0)
                        {
                            DataSet ds = DBConnection.getInstance().executeQuery(QueryProvider.SELECT_PUERTO_POR_CIUDAD(Convert.ToString(dsrecorrido.Tables[0].Rows[0]["reco_destino_id"])));

                            if (this.textBox1.Text != Convert.ToString(ds.Tables[0].Rows[0]["puer_nombre"]))
                            {
                                MessageBox.Show("El recorrido existe y debe partir de " + Convert.ToString(ds.Tables[0].Rows[0]["puer_nombre"]));
                            }
                            else
                            {
                                DataRow origen  = DBAdapter.traerDataTable("ciudad_id", textBox1.Text).Rows[0];
                                DataRow destino = DBAdapter.traerDataTable("ciudad_id", textBox2.Text).Rows[0];

                                DBAdapter.insertarDatosEnTabla("recorrido", Codigo.Text, origen["ciud_id"], destino["ciud_id"], Precio.Text);
                                MessageBox.Show("El recorrido fue dado de alta");
                            }
                        }
                        else
                        {
                            DataRow origen  = DBAdapter.traerDataTable("ciudad_id", textBox1.Text).Rows[0];
                            DataRow destino = DBAdapter.traerDataTable("ciudad_id", textBox2.Text).Rows[0];

                            DBAdapter.insertarDatosEnTabla("recorrido", Codigo.Text, origen["ciud_id"], destino["ciud_id"], Precio.Text);
                            MessageBox.Show("El recorrido fue dado de alta");
                        }
                    }
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBConnection dbConnection = DBConnection.getInstance();
            DataSet      ds;

            if (String.Equals(this.comboBox1.Text, "Efectivo"))
            {
                DBAdapter.ejecutarProcedure("facturar", this.reserva, this.viaje, this.crucero, this.comboBox1.Text,
                                            Convert.ToInt32(this.numericUpDown1.Value), Convert.ToDateTime(System.Configuration.ConfigurationManager.AppSettings["fechaSistema"]));
                ds = dbConnection.executeQuery("SELECT MAX(comp_id) comp_id FROM [GD1C2019].[EYE_OF_THE_TRIGGER].[Compra]");
                MessageBox.Show("Compra efectuada. Nº de voucher: " + ds.Tables[0].Rows[0]["comp_id"].ToString());
                this.Close();
            }
            else
            {
                if (String.IsNullOrEmpty(this.comboBox1.Text) || String.IsNullOrEmpty(this.comboBox2.Text))
                {
                    MessageBox.Show("Debe completar todos los campos");
                }
                else
                {
                    try
                    {
                        ValidacionesHelper.validarCampoSoloNumerico(this.Tarjeta);
                        ValidacionesHelper.validarCampoSoloTexto(this.Nombre);
                        ValidacionesHelper.validarCampoSoloNumerico(this.Codigo);
                        if (String.IsNullOrWhiteSpace(this.Nombre.Text))
                        {
                            MessageBox.Show("Complete su nombre por favor");
                        }
                        else
                        {
                            DBAdapter.ejecutarProcedure("facturar", this.reserva, this.viaje, this.crucero, this.comboBox1.Text,
                                                        Convert.ToInt32(this.numericUpDown1.Value), Convert.ToDateTime(System.Configuration.ConfigurationManager.AppSettings["fechaSistema"]));
                            ds = dbConnection.executeQuery("SELECT MAX(comp_id) comp_id FROM [GD1C2019].[EYE_OF_THE_TRIGGER].[Compra]");
                            MessageBox.Show("Compra efectuada. Nº de voucher: " + ds.Tables[0].Rows[0]["comp_id"].ToString());
                            this.Close();
                        }
                    }
                    catch {
                    }
                }
            }

            this.Close();
        }
示例#5
0
        private Tarjeta EntradaDatosFormulario()
        {
            int     tipoTarjeta = (int)Tipo.Amex;
            Tarjeta t           = null;
            int     periodo     = AlgoritmoPeriodoSemanal();
            Cliente cliente     = (Cliente)cmbCliente.SelectedItem;
            int     idcliente   = cliente.Id;
            string  numero      = txtnumplas.Text;

            string msj = "";

            msj += ValidacionesHelper.ValidarDouble(txtlimite.Text, "Limite Compra");
            msj += ValidacionesHelper.ValidarSTRING(numero, "Numero de Plastico");

            if (!string.IsNullOrWhiteSpace(msj))
            {
                throw new Exception(msj.ToString());
            }

            double limite = double.Parse(txtlimite.Text);

            t = new Tarjeta(tipoTarjeta, idcliente, limite, numero, periodo);
            return(t);
        }
示例#6
0
        private Cuenta CargarCuenta()
        {
            string  descripcion = (string)cmbdesc.SelectedItem;
            Cliente cliente     = (Cliente)cmbclienteagregar.SelectedItem;
            int     idcli       = cliente.Id;

            bool estado = checkBox1.Checked;

            string msj = "";

            msj += ValidacionesHelper.ValidarFloat(txtsaldo.Text, "Saldo");
            msj += ValidacionesHelper.ValidarInt(txtnumerocuenta.Text, "Numero de Cuenta");
            msj += ValidacionesHelper.ValidarSTRING(descripcion, "Descripcion");

            if (!string.IsNullOrWhiteSpace(msj))
            {
                throw new Exception(msj.ToString());
            }
            float  saldo     = float.Parse(txtsaldo.Text);
            int    nrocuenta = int.Parse(txtnumerocuenta.Text);
            Cuenta cuenta    = new Cuenta(cuentaServ.ProximoId(), nrocuenta, descripcion, idcli, estado, saldo);

            return(cuenta);
        }
示例#7
0
        private void Agregar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.Apellido.Text) || string.IsNullOrWhiteSpace(this.Apellido.Text) ||
                string.IsNullOrEmpty(this.Nombre.Text) || string.IsNullOrWhiteSpace(this.Nombre.Text) ||
                string.IsNullOrEmpty(this.comboBoxTipoDoc.Text) || string.IsNullOrWhiteSpace(this.comboBoxTipoDoc.Text) ||
                string.IsNullOrEmpty(this.Documento.Text) || string.IsNullOrWhiteSpace(this.Documento.Text) ||
                string.IsNullOrEmpty(this.Calle.Text) || string.IsNullOrWhiteSpace(this.Calle.Text) ||
                string.IsNullOrEmpty(this.Nro.Text) || string.IsNullOrWhiteSpace(this.Nro.Text) ||
                string.IsNullOrEmpty(this.Ciudad.Text) || string.IsNullOrWhiteSpace(this.Ciudad.Text) ||
                string.IsNullOrEmpty(this.Pais.Text) || string.IsNullOrWhiteSpace(this.Pais.Text) ||
                string.IsNullOrEmpty(this.Telefono.Text) || string.IsNullOrWhiteSpace(this.Telefono.Text))
            {
                MessageBox.Show("Hay campos necesarios sin completar");
                Action <Control.ControlCollection> func = null;
                func = (controls) =>
                {
                    foreach (Control control in controls)
                    {
                        if (control is TextBox && (string.IsNullOrEmpty(control.Text) || string.IsNullOrWhiteSpace(control.Text)))
                        {
                            (control as TextBox).BackColor = Color.Red;
                        }
                    }
                };

                func(Controls);
                this.email.BackColor = Color.White;
                if (string.IsNullOrEmpty(this.comboBoxTipoDoc.Text) || string.IsNullOrWhiteSpace(this.comboBoxTipoDoc.Text))
                {
                    this.comboBoxTipoDoc.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Calle.Text) || string.IsNullOrWhiteSpace(this.Calle.Text))
                {
                    this.Calle.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Nro.Text) || string.IsNullOrWhiteSpace(this.Nro.Text))
                {
                    this.Nro.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Calle.Text) || string.IsNullOrWhiteSpace(this.Calle.Text))
                {
                    this.Calle.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Ciudad.Text) || string.IsNullOrWhiteSpace(this.Ciudad.Text))
                {
                    this.Ciudad.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Pais.Text) || string.IsNullOrWhiteSpace(this.Pais.Text))
                {
                    this.Pais.BackColor = Color.Red;
                }
                if (string.IsNullOrEmpty(this.Telefono.Text) || string.IsNullOrWhiteSpace(this.Telefono.Text))
                {
                    this.Telefono.BackColor = Color.Red;
                }
            }
            else
            {
                try
                {
                    if (!this.Apellido.Text.ToCharArray().Any(c => char.IsLetter(c)))
                    {
                        MessageBox.Show("El apellido admite solo letras");
                    }
                    if (!this.Nombre.Text.ToCharArray().Any(c => char.IsLetter(c)))
                    {
                        MessageBox.Show("El nombre admite solo letras");
                    }

                    ValidacionesHelper.validarCampoSoloTexto(this.Pais);
                    ValidacionesHelper.validarCampoSoloNumerico(this.Documento);
                    ValidacionesHelper.validarCampoSoloNumerico(this.Nro);
                    ValidacionesHelper.validarCampoSoloNumerico(this.Telefono);
                    if (!String.IsNullOrEmpty(this.email.Text))
                    {
                        this.validarMail(this.email.Text);
                    }
                    if (!String.IsNullOrEmpty(this.Piso.Text))
                    {
                        ValidacionesHelper.validarCampoSoloNumerico(this.Piso);
                    }
                    this.guardarCliente();
                }
                catch { }
            }
        }