private void Form2_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'hygDataSet.Zvijezda' table. You can move, or remove it, as needed. // this.zvijezdaTableAdapter.Fill(this.hygDataSet.Zvijezda); using (hygEntities context = new hygEntities()) { dataGridView1.DataSource = context.Zvijezdas.ToList <Zvijezda>(); } }
private void Form3_Load(object sender, EventArgs e) { using (hygEntities context = new hygEntities()) { listOfSTar = context.Zvijezdas.ToList <Zvijezda>(); } Zvijezda sol = listOfSTar[0]; Point solLocation = new Point(xMax / 2 - 25, yMax / 2 - 25); //center of the map SetStar(solLocation, float.Parse(sol.mag), sol.proper); Main1(); }
private void button1_Click(object sender, EventArgs e) { string filePath = addslash(txtFilePath.Text); try { StreamReader sr = new StreamReader(filePath); sr.ReadLine(); string linija; while ((linija = sr.ReadLine()) != null) { string[] linija1 = new string[36]; linija1 = linija.Split(','); if (linija1[6] != "") { using (hygEntities context = new hygEntities()) { context.Zvijezdas.Add(new Zvijezda { proper = linija1[6], dist = linija1[9], mag = linija1[13] }); context.SaveChanges(); } } } this.Hide(); Form2 f2 = new Form2(); f2.Closed += (s, args) => this.Close(); f2.Show(); } catch (Exception ex) { MessageBox.Show("Wrong file type or file path!"); Form1 f1 = new Form1(); this.Hide(); f1.Closed += (s, args) => this.Close(); f1.Show(); } }
private void button1_Click_2(object sender, EventArgs e) { DialogResult result = MessageBox.Show("You are about to delete the database.\nProceed?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); string querry = "DELETE FROM Zvijezda\n DBCC CHECKIDENT(Zvijezda, RESEED, 0)"; SqlCommand cmd = new SqlCommand(querry, sqlCon); cmd.ExecuteNonQuery(); using (hygEntities context = new hygEntities()) { dataGridView1.DataSource = context.Zvijezdas.ToList <Zvijezda>(); } } } }
private void button1_Click(object sender, EventArgs e) { using (hygEntities context = new hygEntities()) { string properData = dataGridView1.CurrentCell.Value.ToString(); int index = dataGridView1.CurrentCell.RowIndex; Zvijezda star = context.Zvijezdas.FirstOrDefault(s => (s.proper == properData) && (s.id - 1 == index)); try { star.proper = txtProper.Text; context.SaveChanges(); dataGridView1.DataSource = context.Zvijezdas.ToList <Zvijezda>(); } catch (Exception ex) { MessageBox.Show("Can only edit 'proper'!"); txtProper.Text = ""; } } }
public Form1() { InitializeComponent(); using (hygEntities context = new hygEntities()) { listOfStars = context.Zvijezdas.ToList <Zvijezda>(); } string countText; if (listOfStars.Count == 0) { countText = "N/A"; } else { countText = (listOfStars.Count - 1).ToString(); number.Text = countText; } label4.Text = "Number of stars to draw:\nMaximum stars: " + countText; }