private void BtnZimemetKaydet_Click(object sender, EventArgs e) { try { DateTime selectedDate = Convert.ToDateTime(calendarControl.SelectionStart.ToShortDateString()); if (string.IsNullOrEmpty(txtAdet.Text) || string.IsNullOrEmpty(cmbPersonel.Text)) { throw new ValidationException("Lütfen Bilgileri Kontrol Ediniz !"); } if ((short.Parse(txtAdet.Text) <= 0) || (int.Parse(txtAdet.Text) > Convert.ToInt16(dgwZimmetListesi.CurrentRow.Cells[2].Value))) { throw new ValidationException("Adet Değeri Sıfır veya Daha Düşük Değerler Olamaz !"); } if (selectedDate > DateTime.Now) { throw new ValidationException("Satın alma tarihi bugünden daha sonraki bir tarih olamaz!"); } Zimmetler zimmet = new Zimmetler { urunID = urunID, zimmetAdet = int.Parse(txtAdet.Text), personelID = Convert.ToInt32(cmbPersonel.SelectedValue), kullaniciID = FormKullaniciSecim._userIdSession, zimmetTarihi = selectedDate }; ZimmetController.ZimmetEkle(zimmet); MessageBox.Show("Zimmet Başarıyla Eklendi !", "Zimmet Eklendi !", MessageBoxButtons.OK, MessageBoxIcon.Information); ZimmetUrunListele(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Dikkat !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static void ZimmetGuncelle(Zimmetler zimmet) { using (var context = new DemirbasTakipEntitiess()) { context.sp_ZimmetGuncelle(zimmet.zimmetID, zimmet.zimmetTarihi, zimmet.zimmetAdet, zimmet.personelID, zimmet.kullaniciID); context.SaveChanges(); } }
public static void DepartmanYetkilendir(int personelId, int departmanId) { using (var context = new DataContext2()) { Zimmetler z = new Zimmetler(); z.PersonelId = personelId; z.DepartmanId = departmanId; context.Zimmetlers.Add(z); context.SaveChanges(); } }
public static void OdaYetkilendir(int kisiId, int OdaId) { using (var context = new DatabaseContext()) { Zimmetler z = new Zimmetler(); z.KisiId = kisiId; z.OdaId = OdaId; context.Zimmetlers.Add(z); context.SaveChanges(); } }
private void ZimmetGuncelle() { try { DateTime selectedDate = Convert.ToDateTime(calendarControl1.SelectionStart.ToShortDateString()); if (string.IsNullOrEmpty(txtAdet.Text) || string.IsNullOrEmpty(txtAdet.Text)) { throw new Exception("Zimmet Bilgileri Boş Geçilemez !"); } try { if ((Convert.ToInt32(txtAdet.Text) <= 0)) { MessageBox.Show("Adet Değeri Sıfır veya Daha Düşük Değerler Olamaz !"); txtAdet.Text = ""; txtAdet.Focus(); } } catch { MessageBox.Show("Geçerli bir değer girin"); txtAdet.Text = ""; txtAdet.Focus(); } if (selectedDate > DateTime.Now) { throw new Exception("Zimmet tarihi bugünden daha sonraki bir tarih olamaz!"); } DemirbasTakipEntitiess db = new DemirbasTakipEntitiess(); var urunler = db.sp_UrunListeleme(); foreach (var urun in urunler) { if (urun.urunID == _urunID) { _stokAdet = Convert.ToInt32(urun.stokMiktari); } } if ((Convert.ToInt32(txtAdet.Text) > _stokAdet + (Convert.ToInt32(txtAdet.Text)))) { MessageBox.Show("Stok Yetersiz!"); txtAdet.Text = ""; txtAdet.Focus(); } Zimmetler zimmet = new Zimmetler { zimmetID = _zimmetID, urunID = _urunID, zimmetAdet = int.Parse(txtAdet.Text), zimmetTarihi = selectedDate, personelID = Convert.ToInt32(cmbPersonelGuncelle.SelectedValue), kullaniciID = FormKullaniciSecim._userIdSession }; ZimmetController.ZimmetGuncelle(zimmet); MessageBox.Show("Zimmet Başarıyla Düzenlendi !", "İşlem Başarılı !", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Hata Meydana Geldi !", MessageBoxButtons.OK, MessageBoxIcon.Information); } }