private void silToolStripMenuItem_Click(object sender, EventArgs e) { var gRArac = new GenericRepository <Arac>(new OtoContext()); Arac arac = gRArac.GetById(saseNo); gRArac.Delete(arac); FillGrid(); }
private void dataGridView_KiralamaIstekler_CellClick(object sender, DataGridViewCellEventArgs e) { int index = e.RowIndex; DataGridViewRow selectedRow = dataGridView_KiralamaIstekler.Rows[index]; kiralamaId = Convert.ToInt32(selectedRow.Cells[0].Value); arac = (Arac)selectedRow.Cells[5].Value; }
public void FormDoldur(Arac arac) { textBoxAracPlaka.Text = arac.AracPlaka; textBoxMarkaModel.Text = arac.AracMarkaModel; if (arac.AracTip == false) { radioButtonFirmaAraci.Checked = true; radioButtonYabanci.Checked = false; } else if (arac.AracTip == true) { radioButtonFirmaAraci.Checked = false; radioButtonYabanci.Checked = true; } else { radioButtonFirmaAraci.Checked = false; radioButtonYabanci.Checked = false; } textBoxElDara.Text = arac.AracDaraAgirlik.ToString(); textBoxDaraAgirlik.Text = arac.AracDaraAgirlik.ToString(); }
private async void btnKiralamaIstek_Click(object sender, EventArgs e) { Arac seciliArac = new Arac(); if (seciliAracId == 0 || aracDurum == false) { MessageBox.Show("Araç Kiralanamaz"); } else { //Kiralama tablosuna insertle try { bool success = false; // Create a HttpClient using (var client = new HttpClient()) { // Setup basics client.BaseAddress = new Uri("http://localhost:25667/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // Create post body object seciliArac.Id = seciliAracId; Kiralama kiralama = new Kiralama() { Arac = seciliArac, Calisan = null, kiralamaTarihi = DateTime.Now, Musteri = gkullanici, odenecekTutar = 0 }; // Serialize C# object to Json Object var serializedProduct = JsonConvert.SerializeObject(kiralama); // Json object to System.Net.Http content type var content = new StringContent(serializedProduct, Encoding.UTF8, "application/json"); // Post Request to the URI var result = await client.PostAsync("api/Kiralama", content); // Check for result if (result.IsSuccessStatusCode) { success = true; } } // Set message depend on success info var message = success ? "İstek Yollandı" : "failed"; // Inform user MessageBox.Show("" + message); } catch (Exception ex) { // Inform user MessageBox.Show("Error happened: " + ex.Message); } //Arac Durumunu güncelle try { bool success = false; // Create a HttpClient using (var client = new HttpClient()) { // Setup basics client.BaseAddress = new Uri("http://localhost:25667/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); seciliArac.aracDurum = false; // Serialize C# object to Json Object var serializedProduct = JsonConvert.SerializeObject(seciliArac); // Json object to System.Net.Http content type var content = new StringContent(serializedProduct, Encoding.UTF8, "application/json"); // Post Request to the URI var result = await client.PutAsync("api/Arac/" + seciliAracId, content); // Check for result if (result.IsSuccessStatusCode) { success = true; } } // Set message depend on success info var message = success ? "Araç Durumu Güncellendi" : "failed"; // Inform user MessageBox.Show("" + message); } catch (Exception ex) { // Inform user MessageBox.Show("Error happened: " + ex.Message); } //Araları çek try { // Create a HttpClient using (var client = new HttpClient()) { // Setup basics client.BaseAddress = new Uri("http://localhost:25667/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Get Request from the URI using (var result = await client.GetAsync("api/Arac")) { // Check the Result if (result.IsSuccessStatusCode) { // Take the Result as a json string var value = result.Content.ReadAsStringAsync().Result; // Deserialize the string with a Json Converter to ResponseContent object and fill the datagrid dataGrid_Arac.DataSource = JsonConvert.DeserializeObject <ResponseContent <Arac> >(value).Data.ToList(); } } } } catch (Exception ex) { // Inform user if an error occurs MessageBox.Show("Error happened: " + ex.Message); } } }
private void BtnKaydet_Click(object sender, EventArgs e) { try { if (comboBoxArac.Enabled == true) { int id = int.Parse(comboBoxArac.SelectedValue.ToString()); var arac = db.Arac.Find(id); arac.AracPlaka = textBoxAracPlaka.Text; arac.AracMarkaModel = textBoxMarkaModel.Text; if (ıconPictureBoxElleGiris.IconChar == FontAwesome.Sharp.IconChar.CheckSquare) { arac.AracDaraAgirlik = double.Parse(textBoxElDara.Text.Replace(".", ",")); } else { arac.AracDaraAgirlik = double.Parse(textBoxDaraAgirlik.Text.Replace(".", ",")); } if (radioButtonFirmaAraci.Checked == true) { arac.AracTip = false; } else if (radioButtonYabanci.Checked == true) { arac.AracTip = true; } else { arac.AracTip = false; } arac.AracDorsePlaka = textBox1.Text; arac.Arsiv = false; db.Entry(arac).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Global.sonarac = arac; } else { var arackontrol = db.Arac.FirstOrDefault(x => x.AracPlaka == textBoxAracPlaka.Text); if (arackontrol == null) { var arac = new Arac(); arac.AracPlaka = textBoxAracPlaka.Text; arac.AracMarkaModel = textBoxMarkaModel.Text; if (ıconPictureBoxElleGiris.IconChar == FontAwesome.Sharp.IconChar.CheckSquare) { arac.AracDaraAgirlik = double.Parse(textBoxElDara.Text.Replace(".", ",")); } else { arac.AracDaraAgirlik = double.Parse(textBoxDaraAgirlik.Text.Replace(".", ",")); } if (radioButtonFirmaAraci.Checked == true) { arac.AracTip = false; } else if (radioButtonYabanci.Checked == true) { arac.AracTip = true; } else { arac.AracTip = false; } arac.AracDorsePlaka = textBox1.Text; arac.Arsiv = false; db.Arac.Add(arac); db.SaveChanges(); Global.sonarac = arac; } else { mesaj.Mesaj("Bu Plaka Zaten Kayıtlı ", FontAwesome.Sharp.IconChar.ExclamationTriangle, System.Drawing.Color.Yellow); return; } } mesaj.Mesaj("İşlem Başarılı", FontAwesome.Sharp.IconChar.Check, System.Drawing.Color.DarkGreen); FormTemizle(); } catch (Exception ex) { mesaj.Mesaj(ex.Message, FontAwesome.Sharp.IconChar.Times, System.Drawing.Color.DarkRed); } }