private void butt_ok_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_num_med.Text)) { MessageBoxButtons but = MessageBoxButtons.OK; DialogResult res; res = MessageBox.Show("Introduceti un nume valid!", "Eroare la input", but); } else { Form_ediatare f = new Form_ediatare(); Farmacie_lab8 frm = new Farmacie_lab8(); string nume = txt_num_med.Text; con.Open(); OleDbCommand cmd = con.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "select * from Tabel where nume='" + nume + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(dt); frm.data.DataSource = dt; con.Close(); f.richTextBox1.Text = frm.data.Rows[0].Cells[0].Value.ToString(); this.Close(); f.Show(); } }
static void Main() { AppForm1 form1 = new AppForm1(); Farmacie_lab8 form2 = new Farmacie_lab8(); form1.Show(); form2.Show(); Application.Run(); Medicament m = new Medicament(); string x; do { Console.Clear(); Console.WriteLine("1.Afisare baza de date"); Console.WriteLine("2.Adaugare medicament"); Console.WriteLine("3.Editare detalii medicament"); Console.WriteLine("4.Stergere medicament"); Console.WriteLine("5.Cautare medicament"); Console.WriteLine("6.Iesire din program"); Console.WriteLine("Optiunea dvs:"); x = Console.ReadLine(); switch (x) { case "1": m.citire_bdd(); break; case "2": m.scrie_bdd(); break; case "3": m.editeaza_bdd(); break; case "4": m.sterge_bdd(); break; case "5": m.cauta_bbd(); break; case "6": return; default: Console.WriteLine("Comanda inexistenta"); break; } Console.ReadLine(); } while (true); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Madalin\Desktop\desk\piu\proiect\Farmacie\Farmacie\bin\Debug\Database2.mdb"); this.checkedList_bad = new System.Windows.Forms.CheckedListBox(); this.but_stg = new System.Windows.Forms.Button(); this.but_anulare = new System.Windows.Forms.Button(); this.SuspendLayout(); // // checkedList_bad // this.checkedList_bad.FormattingEnabled = true; this.checkedList_bad.Location = new System.Drawing.Point(81, 22); this.checkedList_bad.Name = "checkedList_bad"; this.checkedList_bad.Size = new System.Drawing.Size(293, 154); Farmacie_lab8 f = new Farmacie_lab8(); con.Open(); OleDbCommand cmd = con.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "select * from Tabel"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(dt); f.data.DataSource = dt; con.Close(); int i = 0; int limita = f.data.Rows.Count; string[] s = new string[100]; while (i < limita - 1) { s[i] = f.data.Rows[i].Cells[0].Value.ToString(); this.checkedList_bad.Items.Add(s[i]); i++; } this.checkedList_bad.TabIndex = 0; // // but_stg // this.but_stg.Location = new System.Drawing.Point(125, 209); this.but_stg.Name = "but_stg"; this.but_stg.Size = new System.Drawing.Size(75, 23); this.but_stg.TabIndex = 1; this.but_stg.Text = "Sterge"; this.but_stg.UseVisualStyleBackColor = true; this.but_stg.Click += new System.EventHandler(this.but_stg_Click); // // but_anulare // this.but_anulare.Location = new System.Drawing.Point(246, 209); this.but_anulare.Name = "but_anulare"; this.but_anulare.Size = new System.Drawing.Size(75, 23); this.but_anulare.TabIndex = 2; this.but_anulare.Text = "Anulare"; this.but_anulare.UseVisualStyleBackColor = true; this.but_anulare.Click += new System.EventHandler(this.but_anulare_Click); // // Form_stergere // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(492, 284); this.Controls.Add(this.but_anulare); this.Controls.Add(this.but_stg); this.Controls.Add(this.checkedList_bad); this.Name = "Form_stergere"; this.Text = "Form_stergere"; this.ResumeLayout(false); }