コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // TODO: Validar que sea entero
            decimal?pubId = (decimal?)publicacionId;

            if (MetodosGlobales.esInteger(textBox1))
            {
                decimal?oferta = Convert.ToDecimal(textBox1.Text);

                if (MetodosGlobales.esInteger(textBox1))
                {
                    if (maxOferta < oferta)
                    {
                        persistir();
                    }
                    else
                    {
                        MessageBox.Show("Su oferta es menor a la maximo valor ofertado previamente");
                    }
                }
                else
                {
                    MessageBox.Show("El monto no es entero");
                    return;
                }
            }
        }
コード例 #2
0
ファイル: Alta.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void button1_Click(object sender, EventArgs e)
        {
            /* VALIDO */
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox9.Text == "" || textBox10.Text == "" || textBox11.Text == "" || textBox12.Text == "")
            {
                MessageBox.Show("Ingrese todos los datos necesarios");
                return;
            }

            if (empresaTableAdapter1.ExisteEmpresa(textBox1.Text, textBox11.Text) > 0)
            {
                MessageBox.Show("Ya existe una empresa con esa razón social y CUIT");
                return;
            }

            if (empresaTableAdapter1.ExisteCUIT(textBox11.Text) > 0)
            {
                MessageBox.Show("Ya existe una empresa con ese CUIT");
                return;
            }

            if (!MetodosGlobales.esInteger(textBox3) || !MetodosGlobales.esInteger(textBox5) || !MetodosGlobales.esInteger(textBox6))
            {
                return;
            }
            // Si está todo bien, le pego a la base de datos
            persistir();
        }
コード例 #3
0
ファイル: editar.cs プロジェクト: aalabarce/gdd-tp2014-1c
        public bool validateBorrador()
        {
            //Valido que no dejen campos vacios
            if (txtDescripcion.Text == "" || txtStock.Text == "" || txtPrecio.Text == "")
            {
                MessageBox.Show("Debe completar todos los campos");
                return(false);
            }

            if (!MetodosGlobales.esNumericConDosDecimales(txtPrecio))
            {
                return(false);
            }

            //valido que la publicacion tenga al menos un rubro.
            if (chkRubros.CheckedItems.Count == 0)
            {
                MessageBox.Show("La publicación debe estar asociada al menos a un rubro.");
                return(false);
            }

            if (Convert.ToDouble(txtPrecio.Text) <= 0)
            {
                MessageBox.Show("El producto no puede valer $0 o menos.");
                return(false);
            }

            return(true);
        }
コード例 #4
0
ファイル: Alta.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void persistir()
        {
            DataRow empresa = gD1C2014DataSet1.EMPRESA.NewRow();

            // if (esInteger(textBox1))
            empresa["EMP_RAZON_SOCIAL"]   = textBox1.Text;
            empresa["EMP_MAIL"]           = textBox2.Text;
            empresa["EMP_TELEFONO"]       = textBox3.Text;
            empresa["EMP_CALLE"]          = textBox4.Text;
            empresa["EMP_CALLE_NRO"]      = textBox5.Text;
            empresa["EMP_PISO"]           = textBox6.Text;
            empresa["EMP_DPTO"]           = textBox7.Text;
            empresa["EMP_LOCALIDAD"]      = textBox8.Text;
            empresa["EMP_COD_POSTAL"]     = textBox9.Text;
            empresa["EMP_CIUDAD"]         = textBox10.Text;
            empresa["EMP_CUIT"]           = textBox11.Text;
            empresa["EMP_NOM_CONTACTO"]   = textBox12.Text;
            empresa["EMP_FECHA_CREACION"] = DateTime.Now;
            empresa["EMP_BAJA"]           = 0;



            // Si creo la empresa a manopla (como admin) creo tambien un usuario genérico
            if (usuarioId == -1)
            {
                DataRow usuarioGenerico = gD1C2014DataSet1.USUARIO.NewRow();
                usuarioGenerico["USU_USERNAME"]       = textBox11.Text;
                usuarioGenerico["USU_PASSWORD"]       = MetodosGlobales.sha256("1234");
                usuarioGenerico["USU_INTENTOS_LOGIN"] = 0;
                usuarioGenerico["USU_TIPO"]           = "E";
                usuarioGenerico["USU_BAJA"]           = 0;

                gD1C2014DataSet1.USUARIO.Rows.Add(usuarioGenerico);
                usuarioTableAdapter1.Update(gD1C2014DataSet1.USUARIO);
                empresa["EMP_USU_ID"] = usuarioGenerico["USU_ID"];
                usuarioId             = Convert.ToInt32(usuarioGenerico["USU_ID"]);
            }
            else
            {
                empresa["EMP_USU_ID"] = usuarioId;
            }
            gD1C2014DataSet1.EMPRESA.Rows.Add(empresa);

            empresaTableAdapter1.Update(gD1C2014DataSet1.EMPRESA);

            // Agrego el USUARIO_ROL
            DataRow usuario_rol = gD1C2014DataSet1.USUARIO_ROL.NewRow();

            usuario_rol["USU_ROL_USUARIO_ID"] = usuarioId;
            usuario_rol["USU_ROL_ROL_ID"]     = 2;

            gD1C2014DataSet1.USUARIO_ROL.Rows.Add(usuario_rol);
            usuariO_ROLTableAdapter1.Update(gD1C2014DataSet1.USUARIO_ROL);

            string mensaje = "La empresa " + textBox1.Text + " ha sido dada de alta";

            MessageBox.Show(mensaje);
            this.Close();
        }
コード例 #5
0
ファイル: Login.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void button1_Click(object sender, EventArgs e)
        {
            exito = false;
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("Ingrese todos los datos necesarios");
                return;
            }
            usuario = textBox1.Text;
            string password = textBox2.Text;

            // LE AGREGO LA VERIFICACION DE SHA 256
            string contraseña = MetodosGlobales.sha256(password);

            if (usuarioTableAdapter1.validarUsuario(usuario) == 1) //Le mando a usuarioTableAdaapter el mensaje "Existe Usuario", que me devuelve 0 o 1
            {
                if (usuarioTableAdapter1.habilitadoUsuario(usuario) == 1)
                {
                    if (Convert.ToInt32(usuarioTableAdapter1.passValido(usuario, contraseña)) == 1)
                    {
                        usuarioTableAdapter1.resetearIntentosFallidos(usuario);
                        usuario_id = usuarioTableAdapter1.get_id_by_username(usuario);

                        if (contraseña == MetodosGlobales.sha256("1234"))
                        {
                            new FrbaCommerce.Login.CambioContraseña((int)usuario_id, 0).Show();
                        }
                        else
                        {
                            if (usuariO_ROLTableAdapter1.cantidadRoles(usuario) > 1)
                            {
                                new FrbaCommerce.Login.MasDeUno(this).Show();
                                this.Hide();
                            }
                            else
                            {
                                this.rol = usuariO_ROLTableAdapter1.rolPorDefecto(usuario);
                                this.Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Usuario o contraseña inválido, intente nuevamente");
                        usuarioTableAdapter1.agregaIntentoFallido(usuario);
                    }
                }
                else
                {
                    MessageBox.Show("Usuario inhabilitado, comuníquese con Administración para resolver el problema");
                }
            }
            else
            {
                MessageBox.Show("El usuario no existe");
            }
        }
コード例 #6
0
ファイル: BuscarVi.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void button1_Click_1(object sender, EventArgs e)
        {
            //VALIDO LOS TIPOS DE LOS CAMPOS
            if (textBox1.Text != "" && !MetodosGlobales.esInteger(textBox1))
            {
                return;
            }
            if (textBox3.Text != "" && !MetodosGlobales.esNumericConDosDecimales(textBox3))
            {
                return;
            }
            if (textBox4.Text != "" && !MetodosGlobales.esNumericConDosDecimales(textBox4))
            {
                return;
            }
            if (textBox5.Text != "" && !MetodosGlobales.esInteger(textBox5))
            {
                return;
            }



            //Filtro
            decimal?cod = null;
            string  des = null;
            decimal?pre = null;
            decimal?por = null;
            int?    dur = null;

            if (textBox1.Text != "")
            {
                cod = Convert.ToDecimal(textBox1.Text);
            }
            if (textBox2.Text != "")
            {
                des = textBox2.Text;
            }
            if (textBox3.Text != "")
            {
                pre = Convert.ToDecimal(textBox3.Text);
            }
            if (textBox4.Text != "")
            {
                por = Convert.ToDecimal(textBox4.Text);
            }
            if (textBox5.Text != "")
            {
                dur = Convert.ToInt32(textBox5.Text);
            }


            vISIBILIDADTableAdapter.Filtrar(gD1C2014DataSet.VISIBILIDAD, cod, des, pre, por, dur);
        }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Valido que no dejen campos vacios
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("Debe completar todos los campos");
                return;
            }


            //Valido que los tipos de datos sean correctos
            if (!MetodosGlobales.esInteger(textBox1) || !MetodosGlobales.esInteger(textBox5) || !MetodosGlobales.esNumericConDosDecimales(textBox3) || !MetodosGlobales.esInteger(textBox4))
            {
                return;
            }


            //Valido que el codigo no exista
            if (Convert.ToInt32(visibilidadTableAdapter1.existeCod(Convert.ToDecimal(textBox1.Text))) > 0)
            {
                MessageBox.Show("Ese codigo de visibilidad ya existe");
                return;
            }

            //Valido que el nombre no exista
            if (Convert.ToInt32(visibilidadTableAdapter1.existeNom(textBox2.Text)) > 0)
            {
                MessageBox.Show("Ese nombre de visibilidad ya existe");
                return;
            }

            //Valido que no exista la combinacion de $, % y duracion
            if (Convert.ToInt32(visibilidadTableAdapter1.existeCombinacion(Convert.ToInt32(textBox5.Text), Convert.ToDecimal(textBox3.Text), Convert.ToDecimal(textBox4.Text) / 100)) > 0)
            {
                MessageBox.Show("Esa combinacion de precio, porcentaje y duracion ya existe");
                return;
            }


            //Si hay errores, agrego a la base de datos
            darAlta();
        }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!MetodosGlobales.esInteger(textBox1))
            {
                return;
            }

            int?   codigo = null;
            string desc   = null;

            if (textBox1.Text != "")
            {
                codigo = Convert.ToInt32(textBox1.Text);
            }
            if (textBox2.Text != "")
            {
                desc = textBox2.Text;
            }

            rUBROTableAdapter.FiltroRubro(gD1C2014DataSet.RUBRO, desc, codigo);
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("El campo contraseña no puede estar vacio");
                return;
            }
            if (textBox1.Text == "1234")
            {
                MessageBox.Show("La nueva contraseña es invalida");
                return;
            }

            DataRow fila = gD1C2014DataSet1.USUARIO.NewRow();

            fila = gD1C2014DataSet1.USUARIO.FindByUSU_ID(usu_id);

            fila["USU_PASSWORD"] = MetodosGlobales.sha256(textBox1.Text);

            usuarioTableAdapter1.Update(gD1C2014DataSet1.USUARIO);

            MessageBox.Show("La contraseña ha sido cambiada correctamente");
            this.Close();
        }
コード例 #10
0
ファイル: Alta.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("Ingrese usuario y password");
                return;
            }

            if (textBox2.Text == "1234")
            {
                MessageBox.Show("Introduzca una contraseña valida");
                return;
            }

            if (usuarioTableAdapter1.existeUsuario(textBox1.Text) == 1)
            {
                MessageBox.Show("El nombre de usuario es inválido");
                return;
            }

            string      usuario    = textBox1.Text;
            string      password   = textBox2.Text;
            DataRowView rolElegido = (DataRowView)comboBox1.SelectedItem;

            string passSHA = MetodosGlobales.sha256(textBox2.Text);

            DataRow nuevoUsuario = gD1C2014DataSet1.USUARIO.NewRow();

            nuevoUsuario["USU_USERNAME"]       = textBox1.Text;
            nuevoUsuario["USU_PASSWORD"]       = passSHA;
            nuevoUsuario["USU_INTENTOS_LOGIN"] = 0;
            nuevoUsuario["USU_BAJA"]           = 0;


            if ((rolElegido["ROL_NOMBRE"].ToString()) == "Empresa")
            {
                nuevoUsuario["USU_TIPO"] = 'E';
            }
            else if ((rolElegido["ROL_NOMBRE"].ToString()) == "Cliente")
            {
                nuevoUsuario["USU_TIPO"] = 'C';
            }
            else
            {
                nuevoUsuario["USU_TIPO"] = DBNull.Value;
            }


            gD1C2014DataSet1.USUARIO.Rows.Add(nuevoUsuario);
            usuarioTableAdapter1.Update(gD1C2014DataSet1.USUARIO);
            int?    id          = usuarioTableAdapter1.get_id_by_username(textBox1.Text);
            DataRow nuevoUsuRol = gD1C2014DataSet1.USUARIO_ROL.NewRow();

            nuevoUsuRol["USU_ROL_USUARIO_ID"] = id;
            nuevoUsuRol["USU_ROL_ROL_ID"]     = rolElegido["ROL_ID"];


            if ((rolElegido["ROL_NOMBRE"].ToString()) == "Empresa")
            {
                new FrbaCommerce.Abm_Empresa.Alta(id).Show();
            }
            else if ((rolElegido["ROL_NOMBRE"].ToString()) == "Cliente")
            {
                new FrbaCommerce.Abm_Cliente.AltaCliente(id).Show();
            }

            this.Close();
        }
コード例 #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Valido que complete todos los campos menos piso y depto q son optativos
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox11.Text == "")
            {
                MessageBox.Show("Todos los campos son obligatorios, exceptuando Piso y Departamento");
                return;
            }

            //Valido el tipo de datos
            if (!MetodosGlobales.esInteger(textBox3) || !MetodosGlobales.esInteger(textBox5) || !MetodosGlobales.esInteger(textBox6))
            {
                return;
            }

            //Valido el tipo de dato del piso solo si es vive en depto
            if (textBox9.Text != "" && !MetodosGlobales.esInteger(textBox9))
            {
                return;
            }

            //Valido que el telefono sea unico
            if (clienteTableAdapter1.ExisteTel(Convert.ToInt32(textBox5.Text)) > 0)
            {
                MessageBox.Show("Número de teléfono invalido, intente nuevamente");
                return;
            }


            DataRow FilaAModificar = gD1C2014DataSet1.CLIENTE.NewRow();

            FilaAModificar = gD1C2014DataSet1.CLIENTE.FindByCLI_ID((int)cliente);

            //Valido que el documento sea unico
            if (Convert.ToString(FilaAModificar["CLI_DOC"]) != textBox3.Text)
            {
                MessageBox.Show("entre");
                if (Convert.ToInt32(clienteTableAdapter1.ExisteDoc(Convert.ToInt32(textBox3.Text), (comboBox1.SelectedIndex + 1).ToString())) > 0)
                {
                    MessageBox.Show("Número de documento o tipo de documento inválido, intente nuevamente");
                    return;
                }
            }

            //Guardo todos los datos
            FilaAModificar["CLI_NOMBRE"] = textBox1.Text;
            FilaAModificar["CLI_APE"]    = textBox2.Text;
            if (comboBox1.SelectedIndex != -1)
            {
                FilaAModificar["CLI_TIPO_DOC"] = (comboBox1.SelectedIndex + 1).ToString();
            }
            else
            {
                FilaAModificar["CLI_TIPO_DOC"] = 1;
            }
            FilaAModificar["CLI_DOC"]        = Convert.ToInt32(textBox3.Text);
            FilaAModificar["CLI_MAIL"]       = textBox4.Text;
            FilaAModificar["CLI_LOCALIDAD"]  = textBox11.Text;
            FilaAModificar["CLI_TELEFONO"]   = Convert.ToInt32(textBox5.Text);
            FilaAModificar["CLI_FECHA_NAC"]  = dateTimePicker1.Value;
            FilaAModificar["CLI_COD_POSTAL"] = textBox7.Text;
            FilaAModificar["CLI_CALLE"]      = textBox8.Text;
            if (textBox9.Text != "")
            {
                FilaAModificar["CLI_PISO"] = Convert.ToInt32(textBox9.Text);
            }
            else
            {
                FilaAModificar["CLI_PISO"] = DBNull.Value;
            }
            if (textBox10.Text != "")
            {
                FilaAModificar["CLI_DEPTO"] = textBox10.Text;
            }
            else
            {
                FilaAModificar["CLI_DEPTO"] = DBNull.Value;
            }
            FilaAModificar["CLI_CALLE_NRO"] = Convert.ToInt32(textBox6.Text);
            FilaAModificar["CLI_BAJA"]      = 0;

            clienteTableAdapter1.Update(gD1C2014DataSet1.CLIENTE);

            MessageBox.Show("El cliente " + textBox1.Text + " ha sido modificado");
            clienteTableAdapter1.Fill(gD1C2014DataSet1.CLIENTE);

            new FrbaCommerce.Abm_Cliente.Clientes(1).Show();
            this.Close();
        }
コード例 #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            int?usu_id;

            //Valido que complete todos los campos menos piso y depto q son optativos
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox11.Text == "")
            {
                MessageBox.Show("Todos los campos son obligatorios, exceptuando Piso y Departamento");
                return;
            }

            //Valido el tipo de datos
            if (!MetodosGlobales.esInteger(textBox3) || !MetodosGlobales.esInteger(textBox5) || !MetodosGlobales.esInteger(textBox6))
            {
                return;
            }

            //Valido el tipo de dato del piso solo si es vive en depto
            if (textBox9.Text != "" && !MetodosGlobales.esInteger(textBox9))
            {
                return;
            }

            //Valido que el telefono sea unico
            if (clienteTableAdapter1.ExisteTel(Convert.ToInt32(textBox5.Text)) > 0)
            {
                MessageBox.Show("Número de teléfono invalido, intente nuevamente");
                return;
            }

            //Valido que el documento sea unico
            if (Convert.ToInt32(clienteTableAdapter1.ExisteDoc(Convert.ToInt32(textBox3.Text), (comboBox1.SelectedIndex + 1).ToString())) > 0)
            {
                MessageBox.Show("Número de documento o tipo de documento inválido, intente nuevamente");
                return;
            }


            DataRow ClienteNuevo = gD1C2014DataSet1.CLIENTE.NewRow();
            DataRow UsuarioNuevo = gD1C2014DataSet1.USUARIO.NewRow();
            DataRow UsuRolNuevo  = gD1C2014DataSet1.USUARIO_ROL.NewRow();


            ClienteNuevo["CLI_NOMBRE"] = textBox1.Text;
            ClienteNuevo["CLI_APE"]    = textBox2.Text;
            if (comboBox1.SelectedIndex != -1)
            {
                ClienteNuevo["CLI_TIPO_DOC"] = (comboBox1.SelectedIndex + 1).ToString();
            }
            else
            {
                ClienteNuevo["CLI_TIPO_DOC"] = 1;
            }
            ClienteNuevo["CLI_DOC"]        = Convert.ToInt32(textBox3.Text);
            ClienteNuevo["CLI_MAIL"]       = textBox4.Text;
            ClienteNuevo["CLI_LOCALIDAD"]  = textBox11.Text;
            ClienteNuevo["CLI_TELEFONO"]   = Convert.ToInt32(textBox5.Text);
            ClienteNuevo["CLI_FECHA_NAC"]  = dateTimePicker1.Value;
            ClienteNuevo["CLI_COD_POSTAL"] = textBox7.Text;
            ClienteNuevo["CLI_CALLE"]      = textBox8.Text;
            if (textBox9.Text != "")
            {
                ClienteNuevo["CLI_PISO"] = Convert.ToInt32(textBox9.Text);
            }
            if (textBox10.Text != "")
            {
                ClienteNuevo["CLI_DEPTO"] = textBox10.Text;
            }
            ClienteNuevo["CLI_CALLE_NRO"] = Convert.ToInt32(textBox6.Text);
            ClienteNuevo["CLI_BAJA"]      = 0;


            if (parametro_id == -1)
            {
                UsuarioNuevo["USU_USERNAME"]       = textBox3.Text;
                UsuarioNuevo["USU_PASSWORD"]       = MetodosGlobales.sha256("1234");
                UsuarioNuevo["USU_INTENTOS_LOGIN"] = 0;
                UsuarioNuevo["USU_TIPO"]           = 'C';
                UsuarioNuevo["USU_BAJA"]           = 0;
                gD1C2014DataSet1.USUARIO.Rows.Add(UsuarioNuevo);
                usuarioTableAdapter1.Update(gD1C2014DataSet1.USUARIO);

                usu_id = usuarioTableAdapter1.get_id_by_username(textBox3.Text);

                UsuRolNuevo["USU_ROL_ROL_ID"]     = 1;
                UsuRolNuevo["USU_ROL_USUARIO_ID"] = usu_id;
                gD1C2014DataSet1.USUARIO_ROL.Rows.Add(UsuRolNuevo);
                usuariO_ROLTableAdapter1.Update(gD1C2014DataSet1.USUARIO_ROL);

                ClienteNuevo["CLI_USU_ID"] = usu_id;
            }
            else
            {
                UsuRolNuevo["USU_ROL_ROL_ID"]     = 1;
                UsuRolNuevo["USU_ROL_USUARIO_ID"] = parametro_id;
                gD1C2014DataSet1.USUARIO_ROL.Rows.Add(UsuRolNuevo);
                usuariO_ROLTableAdapter1.Update(gD1C2014DataSet1.USUARIO_ROL);

                ClienteNuevo["CLI_USU_ID"] = parametro_id;
            }

            gD1C2014DataSet1.CLIENTE.Rows.Add(ClienteNuevo);
            clienteTableAdapter1.Update(gD1C2014DataSet1.CLIENTE);

            MessageBox.Show("El cliente " + textBox1.Text + " ha sido dado de alta");
            clienteTableAdapter1.Fill(gD1C2014DataSet1.CLIENTE);

            this.Close();
        }
コード例 #13
0
ファイル: Facturar.cs プロジェクト: aalabarce/gdd-tp2014-1c
        private void btnPagar_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtCantidad.Text) <= 0)
            {
                MessageBox.Show("La cantidad de publicaciones a facturar debe ser mayor a 0");
                return;
            }

            if (Convert.ToInt32(txtCantidad.Text) > cantPublicaciones)
            {
                MessageBox.Show("Usted no tiene " + txtCantidad.Text + " publicaciones pendientes de facturación, el máximo es " + cantPublicaciones);
                return;
            }

            //si pago con tarjeta, valido los datos.
            if (cmbFormaPago.SelectedValue.ToString() == "1")
            {
                if (txtNumero.Text == "" || txtAnio.Text == "" || txtMes.Text == "" || txtCodSeguridad.Text == "")
                {
                    MessageBox.Show("Debe completar todos los datos de la tarjeta");
                    return;
                }
                if (!MetodosGlobales.esInteger(txtAnio))
                {
                    return;
                }
                if (!MetodosGlobales.esInteger(txtMes))
                {
                    return;
                }
                if (!MetodosGlobales.esInteger(txtCodSeguridad))
                {
                    return;
                }
            }

            //creo la factura.
            DataRow factura = gD1C2014DataSet.FACTURA.NewRow();

            factura["FAC_FECHA"]    = DateTime.Now;
            factura["FAC_USU_ID"]   = Global.usuario_id;
            factura["FAC_FORMA_ID"] = cmbFormaPago.SelectedValue;

            gD1C2014DataSet.FACTURA.Rows.Add(factura);

            facturaTableAdapter1.Update(gD1C2014DataSet.FACTURA);

            double total          = 0;
            int    cantFacturada  = 0;
            string codPubAnterior = "";

            string pubBonificadas = "";
            bool   debeBonificar  = false;

            //recorro las lineas, y voy creando items factura hasta llegar a la cant de publicaciones elegida por el usuario.
            foreach (GD1C2014DataSet.LINEAS_FACTURACIONRow linea in lineas)
            {
                if (codPubAnterior != linea["CODIGO_PUB"].ToString())
                {
                    cantFacturada++;
                    codPubAnterior = linea["CODIGO_PUB"].ToString();
                    int cantItemsVisUsuario = (int)this.iteM_FACTURATableAdapter1.getCantPublicacionesUsuVis(Global.usuario_id, (decimal)linea["CODIGO_PUB"]);
                    debeBonificar = cantItemsVisUsuario % 10 == 0; //si la publicacion es multiplo de 10 (de la misma visibilidad), bonifico

                    if (debeBonificar)
                    {
                        if (pubBonificadas.Length > 0)
                        {
                            pubBonificadas += ", ";
                        }
                        pubBonificadas += linea["CODIGO_PUB"].ToString();
                    }
                }
                if (cantFacturada <= Convert.ToInt32(txtCantidad.Text))
                {
                    DataRow itemFactura         = gD1C2014DataSet.ITEM_FACTURA.NewRow();
                    int     cantItemsVisUsuario = (int)this.iteM_FACTURATableAdapter1.getCantPublicacionesUsuVis(Global.usuario_id, (decimal)linea["CODIGO_PUB"]);
                    if (debeBonificar)
                    {
                        itemFactura["ITEM_MONTO"] = 0;
                    }
                    else
                    {
                        itemFactura["ITEM_MONTO"] = linea["PRECIO"];
                        total = total + Convert.ToDouble(linea["PRECIO"]);
                    }

                    itemFactura["ITEM_CANTIDAD"] = linea["CANTIDAD"];
                    itemFactura["ITEM_PUB_ID"]   = linea["CODIGO_PUB"];
                    itemFactura["ITEM_FAC_ID"]   = factura["FAC_ID"];

                    gD1C2014DataSet.ITEM_FACTURA.Rows.Add(itemFactura);

                    iteM_FACTURATableAdapter1.Update(gD1C2014DataSet.ITEM_FACTURA);
                }
            }

            if (pubBonificadas.Length > 0)
            {
                MessageBox.Show("Las publicaciones " + pubBonificadas + " han sido bonificadas, son gratuitas");
            }

            //actualizo la factura con el total pagado.
            factura["FAC_TOTAL"] = total;
            facturaTableAdapter1.Update(gD1C2014DataSet.FACTURA);

            //si pago con tarjeta, guardo los datos de la misma.
            if (cmbFormaPago.SelectedValue.ToString() == "1")
            {
                DataRow tarjeta = gD1C2014DataSet.TARJETA.NewRow();
                tarjeta["TAR_NUMERO"]           = txtNumero.Text;
                tarjeta["TAR_ANIO_VENC"]        = txtAnio.Text;
                tarjeta["TAR_MES_VENC"]         = txtMes.Text;
                tarjeta["TAR_CODIGO_SEGURIDAD"] = txtCodSeguridad.Text;
                tarjeta["TAR_FAC_ID"]           = factura["FAC_ID"];

                gD1C2014DataSet.TARJETA.Rows.Add(tarjeta);

                tarjetaTableAdapter1.Update(gD1C2014DataSet.TARJETA);
            }

            this.Close();
            new FrbaCommerce.Facturar_Publicaciones.verFactura(Convert.ToInt32(factura["FAC_ID"])).Show();
        }