Example #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     c = new conexion();
 }
Example #2
0
        private void AgregarBoton_Click(object sender, EventArgs e)
        {
            bool existe = false;

            c = new conexion();
            try
            {
                if (FolioText.Text == "" || LoteText.Text == "" || OperadorText.Text == "" || TiempoText.Text == "" || DensidadText.Text == "" || ResiduoText.Text == "" || ViscosidadText.Text == "" || CtdAguaText.Text == "")
                {
                    MessageBox.Show("Faltan campos por llenar");
                }
                else
                {
                    for (int i = 0; i < dataGridBaseDatos.RowCount; i++)
                    {
                        if (dataGridBaseDatos.Rows[i].Cells[1].Value.ToString() == FolioText.Text)
                        {
                            existe = true;
                            if (existe == true)
                            {
                                MessageBox.Show("El reporte ya esta dado de alta");
                                ClaveText.Text      = "";
                                FolioText.Text      = "";
                                TurnoCombo.Text     = "";
                                EsmalteCombo.Text   = "";
                                LoteText.Text       = "";
                                OperadorText.Text   = "";
                                MolinoCombo.Text    = "";
                                TiempoText.Text     = "";
                                DensidadText.Text   = "";
                                ResiduoText.Text    = "";
                                ViscosidadText.Text = "";
                                CtdAguaText.Text    = "";
                            }
                        }
                    }
                    if (existe == false)
                    {
                        if (FolioText.Text == "" || LoteText.Text == "" || OperadorText.Text == "" || TiempoText.Text == "" || DensidadText.Text == "" || ResiduoText.Text == "" || ViscosidadText.Text == "" || CtdAguaText.Text == "")
                        {
                            MessageBox.Show("Falatan campos por llenar");
                        }
                        else
                        {
                            string sq = "INSERT INTO  GENERAL.REPORTE(folio, turno, esmalte, lote, operador, molino, tiempo, densidad, residuos, viscosidad, cantidadAgua, fecha) VALUES (" + FolioText.Text + ",'" + TurnoCombo.SelectedItem + "','" + EsmalteCombo.SelectedItem + "'," + LoteText.Text + ",'" + OperadorText.Text + "'," + MolinoCombo.SelectedItem + ", '" + TiempoText.Text + "', " + DensidadText.Text + ", " + ResiduoText.Text + ", " + ViscosidadText.Text + ", " + CtdAguaText.Text + ",GETDATE())";
                            cmd = new SqlCommand(sq, c.regresaConexion());
                            MessageBox.Show("Reporte Insertado");
                            cmd.ExecuteNonQuery();
                            ClaveText.Text      = "";
                            FolioText.Text      = "";
                            TurnoCombo.Text     = "";
                            EsmalteCombo.Text   = "";
                            LoteText.Text       = "";
                            OperadorText.Text   = "";
                            MolinoCombo.Text    = "";
                            TiempoText.Text     = "";
                            DensidadText.Text   = "";
                            ResiduoText.Text    = "";
                            ViscosidadText.Text = "";
                            CtdAguaText.Text    = "";
                            cargarDatos(dataGridBaseDatos);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error de inserccion" + ex);
            }
            c.cerrarConexion();
        }