private void button8_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox1.Text) == true || string.IsNullOrWhiteSpace(textBox2.Text) == true || string.IsNullOrWhiteSpace(textBox3.Text) == true || string.IsNullOrWhiteSpace(maskedTextBox1.Text) == true || string.IsNullOrWhiteSpace(textBox6.Text) == true)
            {
                MessageBox.Show("No se permiten campos vacios");
            }

            else
            {
                string Query = "select *from Contactos where Rtn= " + textBox1.Text + "";

                contactos cl = new contactos();
                if (cl.Buscar(Query) == true)
                {
                    MessageBox.Show("Rtn ya existe");
                }
                else
                {
                    string cadenasql = "insert  into Contactos  values ('" + textBox2.Text + "', '" + textBox3.Text + "','" + maskedTextBox1.Text + "', " + 16 + ", " + int.Parse(textBox6.Text) + ", " + int.Parse(textBox1.Text) + ", " + 1 + ")";
                    contactos.insetarCon(cadenasql);
                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                    textBox5.Clear();
                    textBox6.Clear();
                    textBox1.Clear();
                    maskedTextBox1.Clear();
                    this.Hide();
                    clientes clifrm = new clientes();
                    clifrm.Show();
                }
            }
        }
        private void button8_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtrtnid.Text) == true || string.IsNullOrWhiteSpace(txtnom.Text) == true || string.IsNullOrWhiteSpace(txtdirec.Text) == true || string.IsNullOrWhiteSpace(comboBox1.Text) == true)
            {
                MessageBox.Show("No se permiten campos vacios");
            }

            else
            {
                string Query = "select *from CLIENTE where [RTN/ID]= " + txtrtnid.Text + "";

                contactos cl = new contactos();
                if (cl.Buscar(Query) == true)
                {
                    MessageBox.Show("Rtn ya existe");
                }
                else
                {
                    string idtype = "select IDType from IDTypes where Descripcion = '" + comboBox1.Text + "'";
                    int    idbd   = 0;
                    idbd = clients.idtypecheck(idtype);

                    string cadenasql = "insert  into CLIENTE values (" + txtrtnid.Text + ", '" + txtnom.Text + "', '" + txtdirec.Text + "', " + 16 + ", " + idbd + ");";
                    clients.insetarclien(cadenasql);
                    txtdirec.Clear();
                    txtnom.Clear();
                    txtrtnid.Clear();
                    comboBox1.Text = " ";
                    this.Hide();
                    clientes clifrm = new clientes();
                    clifrm.Show();
                }
            }
        }
Exemplo n.º 3
0
        private void button8_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(registro.Text) == true || string.IsNullOrWhiteSpace(desc.Text) == true || string.IsNullOrWhiteSpace(diag.Text) == true || string.IsNullOrEmpty(comboBox1.Text) || string.IsNullOrEmpty(comboBox2.Text) || string.IsNullOrEmpty(comboBox3.Text))
            {
                MessageBox.Show("No se permiten campos vacios");
            }

            else
            {
                string Query = "select * from DISPOSITIVO where NumRegistro = " + registro.Text + "";

                contactos cl = new contactos();

                if (cl.Buscar(Query) == true)
                {
                    MessageBox.Show("Registro ya existe");
                }
                else
                {
                    string idtype = "select IDModelo from Modelo where Descripcion = '" + comboBox2.Text + "'";
                    int    idbd   = 0;
                    idbd = clients.idtypecheck(idtype);

                    string idtype1 = "select IDTipoDispositivo from TipoDispositivo where Descripcion = '" + comboBox3.Text + "'";
                    int    idbd1   = 0;
                    idbd1 = clients.idtypecheck(idtype1);

                    modeloTest.Text = idbd.ToString();
                    TipoTest.Text   = idbd1.ToString();

                    string cadenasql = "INSERT INTO DISPOSITIVO(IDMODELO, DESCRIPCION, DIAGNOSTICO, IDCliente, fechaIngreso, Estado, NumRegistro, TipoDispositivo) VALUES (" + idbd + ", '" + desc.Text + "', '" + diag.Text + "', " + idcliente.Text + ", '" + fecha.Text + "', " + 10 + ", " + registro.Text + ", " + idbd1 + ");";
                    Mantenimiento.insertar(cadenasql);


                    /**************/
                    foreach (DataGridViewRow row in dgvMostrarItem.Rows)
                    {
                        string constring = @"Data Source=(localdb)\MyInstance;Initial Catalog=IT4;Integrated Security=True";
                        using (SqlConnection con = new SqlConnection(constring))
                        {
                            if (Convert.ToBoolean(row.Cells[0].Value) == true)
                            {
                                using (SqlCommand cmd = new SqlCommand("INSERT INTO [Dispositivo/Accesorio] VALUES(@DispoID, @Acc)", con))
                                {
                                    cmd.Parameters.AddWithValue("@DispoID", iddis.Text);
                                    cmd.Parameters.AddWithValue("@Acc", row.Cells[2].Value);

                                    con.Open();
                                    cmd.ExecuteNonQuery();
                                    con.Close();
                                }
                            }
                        }
                    }
                    /**************/
                    this.Hide();
                }
            }
        }
        private void button8_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(nom.Text) == true || string.IsNullOrWhiteSpace(tel.Text) == true || string.IsNullOrWhiteSpace(comboBox1.Text) == true || string.IsNullOrWhiteSpace(user.Text) == true || string.IsNullOrWhiteSpace(clave.Text) == true)
            {
                MessageBox.Show("No se permiten campos vacios");
            }

            else
            {
                string Query = "select *from USUARIO where USUARIO= '" + user.Text + "'";

                contactos cl = new contactos();
                if (cl.Buscar(Query) == true)
                {
                    MessageBox.Show("USUARIO ya existe");
                }

                else
                {
                    users  us         = new users();
                    string login_pass = clave.Text;
                    MD5    md5        = MD5.Create();
                    byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(login_pass);
                    byte[] hash       = md5.ComputeHash(inputBytes);
                    login_pass = BitConverter.ToString(hash).Replace("-", "");

                    if (comboBox1.Text == "Administrador")
                    {
                        string cadenasql = "insert  into USUARIO values ('" + nom.Text + "', '" + tel.Text + "', '" + user.Text + "', '" + login_pass + "'," + 8 + ", " + 0 + "," + 6 + ");";
                        users.insertarUser(cadenasql);
                    }
                    else
                    {
                        string cadenasql = "insert  into USUARIO values ('" + nom.Text + "', '" + tel.Text + "', '" + user.Text + "', '" + login_pass + "'," + 8 + ", " + 0 + "," + 7 + ");";
                        users.insertarUser(cadenasql);
                    }

                    //string cadenasql = "insert  into USUARIO values ('" + nom.Text + "', '" + tel.Text + "', '" + user.Text + "', '" + clave.Text + "'," + 5 + ", " + 0 + "," + comboBox1.Text + ");";


                    //users.insertarUser(cadenasql);
                    nom.Clear();
                    tel.Clear();
                    user.Clear();
                    comboBox1.Text = " ";
                    this.Hide();
                    usuarios user1 = new usuarios();
                    user1.Show();
                }
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox2.Text) == true)
            {
                MessageBox.Show("No se permiten espacios en blanco");
                textBox2.Clear();
            }

            else
            {
                try
                {
                    string Query = "select *from IDTypes where Descripcion= '" + textBox2.Text + "'";

                    contactos cl = new contactos();
                    if (cl.Buscar(Query) == true)
                    {
                        MessageBox.Show("IDType ya existe");
                    }
                    else
                    {
                        string cadenasql = "insert  into IDTypes  values ('" + textBox2.Text + "', " + 16 + ")";
                        contactos.insertar(cadenasql);

                        textBox2.Clear();
                        textBox1.Text = Mantenimiento.codigoIDTypes().ToString();
                        ParametrosAdmon form = new ParametrosAdmon();

                        form.tabControl1.SelectedIndex = 3;
                        form.Show();
                        this.Hide();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }