private void frmUstalar_Load(object sender, EventArgs e)
 {
     this.Top = 0;
     this.Left = 0;
     cUsta u = new cUsta();
     u.UstaGetir(lvUstalar);
 }
        private void frmUstaSorgulama_Load(object sender, EventArgs e)
        {
            this.Top = 0;
            this.Left = 0;
            cUsta u = new cUsta();
            dgvCari.DataSource = u.UstalariGetir();


        }
 private void btnIslemBitti_Click(object sender, EventArgs e)
 {
     cUsta us = new cUsta();
     if (MessageBox.Show("İşlem bitirildi mi?", "UYARI?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
     {
         us.UstaGuncelleByMesgulKaldir(cGenel.UstaID);
         MessageBox.Show("Son İşlem bitmiştir.");
     }
 }
 private void frmServisIslemleriRaporlama_Load(object sender, EventArgs e)
 {
     this.Top = 0;
     this.Left = 0;
     cUsta u = new cUsta();
     //u.UstalarıGetirRaporlama(cbUstaAdaGore);
     cCari c = new cCari();
     //c.CarileriGetirRaporlama(cbCariAdaGore);
     cUrunler urun = new cUrunler();
     urun.UrunleriGetirRaporlama(cbUrunAdaGore);
     cServisIslemleri sı = new cServisIslemleri();
     sı.ServisGetirRaporlama(cbServisAdaGore);
     txtTarih1.Text = DateTime.Now.ToShortDateString();
     txtTarih2.Text = DateTime.Now.ToShortDateString();
 }
        private void btnGiris_Click(object sender, EventArgs e)
        {
            //frmDanisman frm = new frmDanisman();
            //frm.Show();
            //this.Hide();

            if (cbSecim.Text == "DANIŞMAN")
            {
                cDanisman d = new cDanisman();
                if (d.DanismanGirisi(txtKullaniciAdi.Text, txtSifre.Text))
                {
                    frmDanisman frm = new frmDanisman();
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Kullanıcı adınızı veya şifrenizi kontrol ediniz.", "*** UYARI ***");
                    txtKullaniciAdi.Focus();
                }
            }
            else if (cbSecim.Text == "USTA")
            {
                cUsta u = new cUsta();
                if (u.UstaGirisi(txtKullaniciAdi.Text, txtSifre.Text))
                {
                    frmUstaEkran frm = new frmUstaEkran();
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Kullanıcı adınızı veya şifrenizi kontrol ediniz.", "*** UYARI ***");
                    txtKullaniciAdi.Focus();
                }
            }
            else
                MessageBox.Show("Lütfen Seçim Yapınız.", "*** UYARI ***");
            
        }
 private void btnKaydet_Click(object sender, EventArgs e)
 {
     cUsta u = new cUsta();
     //if(txtUstaNo.Text.Trim() != "")
     //u.UstaNo= Convert.ToInt32(txtUstaNo.Text);
     u.UstaAd = txtAdi.Text;
     u.UstaSoyad = txtSoyadi.Text;
     u.TCNo = txtTCNO.Text;
     u.Telefon = txtTelefon.Text;
     u.Adres = txtAdres.Text;
     u.KullaniciAdi = txtKullaniciAdi.Text;
     u.Sifre = txtSifre.Text;
     if (txtAdi.Text.Trim() != "" && txtSoyadi.Text.Trim() != "" && txtTCNO.Text.Trim() != "" && txtKullaniciAdi.Text.Trim() != "" && txtSifre.Text.Trim() != "")
     {
         if (u.UstaKontrol(u))
         {
             MessageBox.Show("Usta zaten mevcut");
         }
         else
         {
             bool Sonuc = u.UstaEkle(u);
             if (Sonuc)
             {
                 MessageBox.Show("Yeni Usta Kayıt edildi.");
                 Temizle();
                 btnKaydet.Enabled = false;
                 txtAdi.Focus();
                 u.UstaGetir(lvUstalar);
                 txtKullaniciAdi.Enabled = false;
                 txtSifre.Enabled = false;
             }
             else MessageBox.Show("Usta Kayıt EDİLEMEDİ !!!");
         }
     }
     else
     {
         MessageBox.Show("Zorunlu alanlar boş geçilemez!");
     }
 }
        private void btnDegistir_Click(object sender, EventArgs e)
        {
            cUsta u = new cUsta();
            if (txtAdi.Text.Trim() != "" && txtSoyadi.Text.Trim() != "" && txtTCNO.Text.Trim() != "")
            {
                u.UstaNo = Convert.ToInt32(txtUstaNo.Text);
                u.UstaAd = txtAdi.Text;
                u.UstaSoyad = txtSoyadi.Text;
                u.TCNo = txtTCNO.Text;
                u.Adres = txtAdres.Text;
                u.Telefon = txtTelefon.Text;

                bool Sonuc = u.UstaGuncelle(u);
                if (Sonuc)
                {
                    MessageBox.Show("Usta Bilgileri Güncellendi.");
                    btnKaydet.Enabled = false;
                    btnDegistir.Enabled = true;
                    btnSil.Enabled = true;
                    u.UstaGetir(lvUstalar);
                    Temizle();
                    txtAdi.Focus();
                }
                else MessageBox.Show("Bilgiler Güncellenemedi !!!");
            }
            else
            {
                MessageBox.Show("Bilgiler Boş Geçilemez!!");
            }
        }
 private void txtAdaGore_TextChanged(object sender, EventArgs e)
 {
     cUsta u = new cUsta();
     u.UstaGetirByAdaGore(lvUstalar, txtAdaGore.Text);
 }
 private void btnSil_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Silmek İstiyor musunuz?", "SİLİNSİN Mİ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
     {
         cUsta u = new cUsta();
         u.UstaNo = Convert.ToInt32(txtUstaNo.Text);
         bool Sonuc = u.UstaSil(u.UstaNo);
         if (Sonuc)
         {
             Temizle();
             btnKaydet.Enabled = false;
             btnDegistir.Enabled = false;
             btnSil.Enabled = false;
             u.UstaGetir(lvUstalar);
             MessageBox.Show("Usta Bilgileri Silindi");
             txtAdi.Focus();
         }
         else MessageBox.Show("Usta bilgileri SİLİNEMEDİ !!", "UYARI");
     }
 }
        private void btnGonder_Click(object sender, EventArgs e)
        {
            
            cbServisIslemleri.Enabled = false;
            cbUrunler.Enabled = false;
            cServisUzayan su = new cServisUzayan();
            su.CariAd = txtCari.Text;
            su.Plaka = txtPlaka.Text;
            su.ServisAd = txtServisIslemleri.Text;
            su.UrunAd = txtUrunler.Text;
            if (txtCari.Text.Trim() != "" && txtPlaka.Text.Trim() != "" && txtServisIslemleri.Text.Trim() != "" && txtUrunler.Text.Trim() != "")
            {
                if (MessageBox.Show("İşlem gönderilsin mi?", "UYARI?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    client.SendBildirim();

                    if (su.IslemUzayanEkle(su))
                    {
                        MessageBox.Show("Mesajınız Danışmana İletilmiştir");
                    }
                    else
                        MessageBox.Show("Mesajınız Danışmana İletilemedi !!!!");
                    btnCariBul.Enabled = false;
                    cbServisIslemleri.Enabled = false;
                    cbUrunler.Enabled = false;
                    btnGonder.Enabled = false;
                    cUsta us = new cUsta();
                    us.UstaGuncelleByMesgulKaldir(cGenel.UstaID);
                    MessageBox.Show("Son İşlem bitmiştir.");
                }
            }
            else
                MessageBox.Show("Lütfen Boş Alanların Doluluğunu Kontrol Ediniz");

            txtServisIslemleri.Clear();
            txtUrunler.Clear();

        }
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            cUrunHareket uh = new cUrunHareket();
            uh.Adet = 1;
            uh.Belge = "";
            uh.BirimFiyat = Convert.ToDecimal(txtUrunBedeli.Text);
            uh.CariNo = Convert.ToInt32(txtCariNo.Text);
            uh.IslemTuru = "Stok Çıkış";
            uh.Tarih = Convert.ToDateTime(txtIslemTarihi.Text);
            uh.Tutar = Convert.ToDecimal(txtUrunBedeli.Text);
            uh.UrunNo = Convert.ToInt32(txtUrunNo.Text);
            uh.UstaNo = Convert.ToInt32(txtUstaNo.Text);

            cServisHareket sh = new cServisHareket();
            sh.CariNo = Convert.ToInt32(txtCariNo.Text);
            sh.Fiyat = Convert.ToDecimal(txtServisBedeli.Text);
            sh.ServisNo = Convert.ToInt32(txtServisNo.Text);
            sh.Tarih = Convert.ToDateTime(txtIslemTarihi.Text);
            sh.Tutar = Convert.ToDecimal(txtServisBedeli.Text);
            sh.UstaNo = Convert.ToInt32(txtUstaNo.Text);

            int urunhareketid = uh.UrunHareketEkle(uh);
            int servishareketid = sh.ServisHareketEkle(sh);

            if (urunhareketid > 0 && servishareketid > 0)
            {
                MessageBox.Show("Ürün Hareketleri ve Servis Hareketleri kayıtları edildi.");
                cUrunler u = new cUrunler();
                if (u.StokGuncelleFromUrunHareketEkle(uh.UrunNo, uh.Adet, uh.IslemTuru))
                {
                    MessageBox.Show("Stok bilgileri güncellendi.");
                    cCariHareket ch = new cCariHareket();
                    ch.TarihGiris = Convert.ToDateTime(txtIslemTarihi.Text);
                    ch.IslemTuru = "Stok Çıkış";
                    ch.CariNo = Convert.ToInt32(txtCariNo.Text);
                    ch.Belge = "";
                    ch.Alacak = 0;
                    ch.Borc = Convert.ToDecimal(txtToplam.Text);
                    ch.KasaHareketNo = 0;
                    ch.ServisHareketNo = servishareketid;
                    ch.UrunHareketNo = urunhareketid;
                    if (ch.CariHareketEkle(ch))
                    {
                        MessageBox.Show("Cari Hareketleri eklendi.");
                        cCari c = new cCari();
                        c.CariToplamlariGuncelleFromCariHareketEkle(ch.CariNo, ch.Borc, ch.Alacak);
                        MessageBox.Show("Cari Toplamlar güncellendi.");
                        cUsta us = new cUsta();
                        us.UstaGuncelleByMesgulYap(Convert.ToInt32(txtUstaNo.Text));
                        btnKaydet.Enabled = false;
                    }

                }

            }
        }