private void button1_Click(object sender, EventArgs e) { string user = textBox1.Text.ToString(); string password = textBox2.Text.ToString(); if (user == "" || password == "") { MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var context = new Parc_AutoDataContext(); //--------------criptare------------ Encryption enc = new Encryption(); password = enc.EncryptPassword(password); //---------------------------------- var admin1 = new Admin_user { Admin_name = nume, Username = user, Password = password }; context.Admin_users.InsertOnSubmit(admin1); context.SubmitChanges(); this.Close(); return; } }
private void btn_concediaza_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); if (dataGridView1.SelectedRows.Count > 0) { int id_angajat = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); var angajati = from db in context.Angajatis where db.AngajatID == id_angajat select db; foreach (var angajat in angajati) { context.Angajatis.DeleteOnSubmit(angajat); } context.SubmitChanges(); var query_listare_angajati = from db in context.Angajatis select db; dataGridView1.DataSource = query_listare_angajati.ToList(); return; } else { MessageBox.Show("nu ati selectat niciun angajat"); } }
private void btn_login_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); string user = textBox_username.Text; string pass = textBox_pass.Text; //------------------cripteaza---------------- Encryption enc = new Encryption(); pass = enc.EncryptPassword(pass); //-------------------------------------------- var query = from r in context.Admin_users where r.Username.Equals(user) && r.Password.Equals(pass) select r; if (query.Count() != 0) { Curent_user = user; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Nume sau Parola Gresite ! "); } }
private void btn_vinde_masina_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); string nume_angajat = textBox_nume_vanzator.Text.ToString(); string nume_client = textBox_nume_client.Text.ToString(); var id_angajat = from db in context.Angajatis where db.Nume.Equals(nume_angajat) select db.AngajatID; var contract = new Vanzari { Angajat_ID = id_angajat.First(), Client = nume_client, Vanzator = nume_angajat, VIN = vvv, Pret_vanzare = ppp, Data = DateTime.Now }; var car = from db in context.Masinis where db.VIN.Equals(vvv) select db; foreach (var masina in car) { context.Masinis.DeleteOnSubmit(masina); } context.Vanzaris.InsertOnSubmit(contract); context.SubmitChanges(); this.Close(); }
private void btn_ListMasini_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); var query_listare_masini = from db in context.Masinis select db; dataGridView1.DataSource = query_listare_masini.ToList(); }
private void button1_Click(object sender, EventArgs e) { string nume = textBox1.Text.ToString(); string password = textBox2.Text.ToString(); if (nume == "" || password == "") { MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var context = new Parc_AutoDataContext(); //--------------criptare------------ Encryption enc = new Encryption(); password = enc.EncryptPassword(password); //---------------------------------- var selected_admin = (from db in context.Admin_users where db.Admin_name.Equals(nume) select db).First(); if (selected_admin == null) { MessageBox.Show("Adminul nu exista in baza de date !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } if (CCurent_user == nume) { MessageBox.Show("Nu puteti sterge adminul curent !", "Confirmare", MessageBoxButtons.OK); this.Close(); return; } if (selected_admin.Password == password) { context.Admin_users.DeleteOnSubmit(selected_admin); context.SubmitChanges(); MessageBox.Show("Adminul a fost concediat !", "Confirmare", MessageBoxButtons.OK); this.Close(); return; } else { MessageBox.Show("Parola incorecta !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } } }
private void button1_Click(object sender, EventArgs e) { using (Form_Adauga_Angajat frm_adauga_angajat = new Form_Adauga_Angajat()) { frm_adauga_angajat.ShowDialog(); } var context = new Parc_AutoDataContext(); var query_listare_angajati = from db in context.Angajatis select db; dataGridView1.DataSource = query_listare_angajati.ToList(); }
public Form_add_avarie(string car, string vin, string id_masina) { InitializeComponent(); label_car.Text = car; label_vin.Text = vin; var context = new Parc_AutoDataContext(); var avariiQuery = from db in context.Issues select db; foreach (var av in avariiQuery) { comboBox1.Items.Add(new Item(av.Denumire.ToString(), av.ID_Issues.ToString())); } id_car = Int32.Parse(id_masina); }
private void button1_Click(object sender, EventArgs e) { string functie = textBox2.Text.ToString(); string sal = textBox3.Text.ToString(); float sal1 = 0; bool salariu = float.TryParse(sal, out sal1); var context = new Parc_AutoDataContext(); var angajat = (from db in context.Angajatis where db.Nume.Equals(nume) select db).First(); if (functie == "" && sal == "") { MessageBox.Show("Campuri Incomplete !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (functie != "" && sal == "") { angajat.Functie = functie; context.SubmitChanges(); this.Close(); return; } else if (functie == "" && sal != "") { angajat.Salariu_baza = sal1; context.SubmitChanges(); this.Close(); return; } else { angajat.Functie = functie; angajat.Salariu_baza = sal1; context.SubmitChanges(); this.Close(); return; } }
private void btn_add_avarie_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); var issue = (from db in context.Issues where db.Denumire.Equals(comboBox1.SelectedItem.ToString()) select db).First(); int id_is = Int32.Parse(issue.ID_Issues.ToString()); Cars_Issue prob = new Cars_Issue { ID_car = id_car, ID_Issue = issue.ID_Issues }; context.Cars_Issues.InsertOnSubmit(prob); context.SubmitChanges(); this.DialogResult = DialogResult.OK; this.Close(); }
public Form_afisare_optiuni(string id_car) { InitializeComponent(); var context = new Parc_AutoDataContext(); int id = Int32.Parse(id_car); var queri_optiuni = from db in context.Optiunis where db.ID_Masina.Equals(id) select db; dataGridView_optiuni.DataSource = queri_optiuni.ToList(); var queri_avarii = from avarii in context.Issues join mas in context.Cars_Issues on avarii.ID_Issues equals mas.ID_Issue join masina in context.Masinis on mas.ID_car equals masina.ID_Masina where masina.ID_Masina.Equals(id) select avarii; dataGridView_avarii.DataSource = queri_avarii.ToList(); }
public Form_Grafic() { DateTime day = DateTime.Today; DateTime d = day.AddDays(-30); InitializeComponent(); var context = new Parc_AutoDataContext(); var result = from s in context.Vanzaris.Take(30) where (s.Data >= d) group s by new { date = new DateTime(s.Data.Value.Year, s.Data.Value.Month, s.Data.Value.Day) } into g select new { read_date = g.Key.date, T1 = g.Sum(x => x.Pret_vanzare) }; foreach (var suma_zilnica in result) { // string[] s = suma_zilnica.read_date.ToString(); this.chart1.Series["Profituri Lunare"].Points.AddXY(suma_zilnica.read_date, suma_zilnica.T1); chart1.Series["Profituri Lunare"]["PixelPointWidth"] = "10"; } }
private void btn_modificaAngajat_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { string nume = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); using (Form_modifica_angajat frm_modify_ang = new Form_modifica_angajat(nume)) { frm_modify_ang.ShowDialog(); var context = new Parc_AutoDataContext(); var query_listare_angajati = from db in context.Angajatis select db; dataGridView1.DataSource = query_listare_angajati.ToList(); } } else { MessageBox.Show("nu ati selectat niciun angajat"); } }
private void button1_Click(object sender, EventArgs e) { string nume = textBox1.Text.ToString(); string functie = textBox2.Text.ToString(); string sal = textBox3.Text.ToString(); float sal1 = 0; bool salariu = float.TryParse(sal, out sal1); if (nume == "" || functie == "" || sal == "") { MessageBox.Show("Campuri incomplete !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var context = new Parc_AutoDataContext(); var angajat = new Angajati { Nume = nume, Functie = functie, Salariu_baza = sal1 }; context.Angajatis.InsertOnSubmit(angajat); context.SubmitChanges(); MessageBox.Show("Ati adaugat cu succes !", "Confirmare", MessageBoxButtons.OK); this.Close(); return; } }
private void button_start_cautare_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); int marca_check = comboBox_Marca.SelectedIndex; int model_check = comboBox_Model.SelectedIndex; int an1_check = comboBox_An1.SelectedIndex; int an2_check = comboBox_An2.SelectedIndex; string pret1_check = textBox_pret1.Text.ToString(); string pret2_check = textBox_pret2.Text.ToString(); if (marca_check > -1 && model_check <= -1 && an1_check <= -1 && an2_check <= -1 && pret1_check == "" && pret2_check == "") { //daca doar marca e selectata var masini = from db in context.Masinis where db.Marca.Equals(comboBox_Marca.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check > -1 && model_check > -1 && an1_check <= -1 && an2_check <= -1 && pret1_check == "" && pret2_check == "") { //daca marca si model selected var masini = from db in context.Masinis where db.Marca.Equals(comboBox_Marca.Text.ToString()) && (db.Model.Equals(comboBox_Model.Text.ToString())) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check > -1 && an2_check > -1 && pret1_check == "" && pret2_check == "") { //daca intervalul de ani e selectat int a1 = Int32.Parse(comboBox_An1.Text.ToString()); int a2 = Int32.Parse(comboBox_An2.Text.ToString()); if (a1 > a2) { MessageBox.Show("Intervalul de ani introdus gresit !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var masini = from db in context.Masinis where db.An_Fabricatie > Int32.Parse(comboBox_An1.Text.ToString()) && db.An_Fabricatie < Int32.Parse(comboBox_An2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check > -1 && an2_check <= -1 && pret1_check == "" && pret2_check == "") { //an1 e selectat; //selecteaza masinile mai mari de anul respectiv var masini = from db in context.Masinis where db.An_Fabricatie > Int32.Parse(comboBox_An1.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check <= -1 && an2_check > -1 && pret1_check == "" && pret2_check == "") { //an2 e selectat; //selecteaza masinile mai mici de anul respectiv var masini = from db in context.Masinis where db.An_Fabricatie < Int32.Parse(comboBox_An2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check <= -1 && an2_check <= -1 && pret1_check != "" && pret2_check != "") { // intervalul de pret e selectat int pr1 = Int32.Parse(textBox_pret1.Text.ToString()); int pr2 = Int32.Parse(textBox_pret2.Text.ToString()); if (pr1 > pr2) { MessageBox.Show("Intervalul de rpet introdus gresit !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var masini = from db in context.Masinis where db.Pret_Vanzare > Int32.Parse(textBox_pret1.Text.ToString()) && db.Pret_Vanzare < Int32.Parse(textBox_pret2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check <= -1 && an2_check <= -1 && pret1_check != "" && pret2_check == "") { //pret1 e selectat; //selecteaza masinile mai mari de pretul respectiv var masini = from db in context.Masinis where db.Pret_Vanzare > Int32.Parse(textBox_pret1.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check <= -1 && model_check <= -1 && an1_check <= -1 && an2_check <= -1 && pret1_check == "" && pret2_check != "") { //pret2 e selectat; //selecteaza masinile mai mici de pretul respectiv var masini = from db in context.Masinis where db.Pret_Vanzare < Int32.Parse(textBox_pret2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check > -1 && model_check > -1 && an1_check > -1 && an2_check > -1 && pret1_check == "" && pret2_check == "") { //marca model si ani var masini = from db in context.Masinis where db.Marca.Equals(comboBox_Marca.Text.ToString()) && (db.Model.Equals(comboBox_Model.Text.ToString())) && db.An_Fabricatie > Int32.Parse(comboBox_An1.Text.ToString()) && db.An_Fabricatie < Int32.Parse(comboBox_An2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else if (marca_check > -1 && model_check > -1 && an1_check > -1 && an2_check > -1 && pret1_check != "" && pret2_check != "") { //daca toate sunt selectate var masini = from db in context.Masinis where db.Marca.Equals(comboBox_Marca.Text.ToString()) && (db.Model.Equals(comboBox_Model.Text.ToString())) && db.An_Fabricatie > Int32.Parse(comboBox_An1.Text.ToString()) && db.An_Fabricatie <Int32.Parse(comboBox_An2.Text.ToString()) && db.An_Fabricatie> Int32.Parse(textBox_pret1.Text.ToString()) && db.An_Fabricatie < Int32.Parse(textBox_pret2.Text.ToString()) select db; Dgv = masini; this.Close(); return; } else { MessageBox.Show("Unul sau mai multe campuri nu au fost completate !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_raport_Click(object sender, EventArgs e) { DateTime day = DateTime.Today; DateTime d = day.AddDays(-30); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path += "\\RaportVanzari.xlsx"; if (File.Exists(path)) { File.Delete(path); } // Load Excel application Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); // Create empty workbook excel.Workbooks.Add(); // Create Worksheet from active sheet Microsoft.Office.Interop.Excel._Worksheet workSheet = excel.ActiveSheet; // I created Application and Worksheet objects before try/catch, // so that i can close them in finnaly block. // It's IMPORTANT to release these COM objects!! try { // ------------------------------------------------ // Creation of header cells // ------------------------------------------------ workSheet.Cells[1, "A"] = "VIN"; workSheet.Cells[1, "B"] = "Clinet"; workSheet.Cells[1, "C"] = "Vanzator"; workSheet.Cells[1, "D"] = "Pret Vanzare"; workSheet.Cells[1, "E"] = "Data"; var context = new Parc_AutoDataContext(); var result = from s in context.Vanzaris.Take(30) where (s.Data >= d) select new { VIN = s.VIN, Client = s.Client, Vanzator = s.Vanzator, Pret_Vanzare = s.Pret_vanzare, Data = s.Data }; int row = 2; // start row (in row 1 are header cells) foreach (var car in result) { workSheet.Cells[row, "A"] = car.VIN; workSheet.Cells[row, "B"] = car.Client; workSheet.Cells[row, "C"] = car.Vanzator; workSheet.Cells[row, "D"] = car.Pret_Vanzare; workSheet.Cells[row, "E"] = car.Data; row++; } // Apply some predefined styles for data to look nicely :) //workSheet.Range["A1"].AutoFormat(Microsoft.Office.Interop.Excel.XlRangeAutoFormat.xlRangeAutoFormatClassic1);// // Save this data as a file workSheet.SaveAs(path); // Display SUCCESS message MessageBox.Show(string.Format("The file '{0}' is saved successfully!", path)); } catch (Exception exception) { MessageBox.Show("Exception", "There was a PROBLEM saving Excel file!\n" + exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_addcar_Click(object sender, EventArgs e) { var context = new Parc_AutoDataContext(); float pret1 = 0; bool parsepret1 = float.TryParse(textBox_Pret_addmasina.Text.ToString(), out pret1); string sup = comboBox_Supplier.SelectedItem.ToString(); var supplier = from db in context.Suppliers where db.Company_Name.Equals(sup) select db.ID_Suppliers; float pret = 0; bool parsepret = float.TryParse(textBox_Pret_addmasina.Text.ToString(), out pret); int fabricatie = 0; bool parseOK = Int32.TryParse(comboBox_An_fabricatie.SelectedItem.ToString(), out fabricatie); if (comboBox_Marca.SelectedIndex > -1 && textBox_VIN.Text.ToString() != null && comboBox_Model.SelectedIndex > -1 && comboBox_An_fabricatie.SelectedIndex > -1 && parsepret1 != false) { MessageBox.Show("Campuri Complete !"); } else { this.Close(); MessageBox.Show("Campuri Incomplete !", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var masina = new Masini { ID_Suppliers = supplier.First(), Marca = comboBox_Marca.SelectedItem.ToString(), Model = comboBox_Model.SelectedItem.ToString(), VIN = textBox_VIN.Text.ToString(), An_Fabricatie = fabricatie, Pret_Vanzare = pret }; if (parsepret == true) { context.Masinis.InsertOnSubmit(masina); } context.SubmitChanges(); var masina_id = from db in context.Masinis where db.VIN.Equals(masina.VIN) select db.ID_Masina; string faruri; if (comboBox_faruri.SelectedIndex > -1) { faruri = comboBox_faruri.SelectedItem.ToString(); } else { faruri = null; } string clima; if (comboBox_climatizare.SelectedIndex > -1) { clima = comboBox_climatizare.SelectedItem.ToString(); } else { clima = null; } string Tapiterie1; if (comboBox_tapiterie.SelectedIndex > -1) { Tapiterie1 = comboBox_tapiterie.SelectedItem.ToString(); } else { Tapiterie1 = null; } string cul; if (comboBox_culoare.SelectedIndex > -1) { cul = comboBox_culoare.SelectedItem.ToString(); } else { cul = null; } Optiuni op_car = null; op_car = new Optiuni { ID_Masina = masina_id.First(), Climatizare = clima, Faruri = faruri, Tapiterie = Tapiterie1, Faruri_ceata = checkBox_faruri_ceata.Checked, Culoare = cul, Tractiune4x4 = checkBox_4x4.Checked, Avariat = checkBox_avarie.Checked, Comenzi_volan = checkBox_volan_multifunctional.Checked, Cruise_control = checkBox_adaptive_cruise.Checked, Navigatie = checkBox_navigatie.Checked, Scaune_incalzite = checkBox_scaune_incalzite.Checked, Senzori_parcare = checkBox_senzori_parcare.Checked }; context.Optiunis.InsertOnSubmit(op_car); context.SubmitChanges(); // MessageBox.Show(masina_id.First().ToString()); // Dgv = all; this.DialogResult = DialogResult.OK; this.Close(); }