コード例 #1
0
        private void metroButton11_Click(object sender, EventArgs e)
        {
            empleados nuevo = new empleados();

            opcion = "Agregar";
            nuevo.Show();
            FormProvider.MainMenu.Hide();
            actualizar();
        }
コード例 #2
0
        private void btnmode_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnectionStringBuilder builder1 = new SqlConnectionStringBuilder();
                builder1.DataSource     = "pruebastec.database.windows.net";
                builder1.UserID         = "alexis";
                builder1.Password       = "******";
                builder1.InitialCatalog = "elpollon";

                using (SqlConnection connection = new SqlConnection(builder1.ConnectionString))
                {
                    connection.Open();
                    StringBuilder sb = new StringBuilder();
                    sb.Append("select * from usuarios");
                    String         sql = sb.ToString();
                    SqlCommand     cmd = new SqlCommand(sql, connection);
                    SqlDataAdapter da  = new SqlDataAdapter(cmd);
                    DataSet        dt  = new DataSet();
                    da.Fill(dt, "clientes");

                    DataRow DR;

                    Console.WriteLine(dt.Tables[0].Select("Id is not null").Length);

                    if ((metroGrid4.SelectedCells[0].RowIndex + 1) > dt.Tables[0].Select("Id is not null").Length)
                    {
                        MessageBox.Show("Selecciona un campo valido");
                    }
                    else
                    {
                        empleados nuevo = new empleados();
                        opcion = "Editar";
                        id     = (metroGrid4.SelectedCells[0].RowIndex + 1).ToString();

                        nuevo.Show();
                        FormProvider.MainMenu.Hide();
                        actualizar();
                    }

                    connection.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No existe ese id");
            }
        }