Exemplo n.º 1
0
 private void btnSatışYap_Click(object sender, EventArgs e)
 {
     if (Ayarlar.dil == "English")
     {
         MessageBoxManager.Unregister();
         MessageBoxManager.Yes = "Yes";
         MessageBoxManager.No  = "No";
         MessageBoxManager.OK  = "Tamam";
         MessageBoxManager.Register();
         MaxPuan();
         ÜyePuanı();
         if (Bizim >= enBuyuk && Bizim != 0)
         {
             if (durum == "OK")
             {
                 DialogResult secenek = MessageBox.Show("Are you sure you want to pay 5% discount to our loyal customer ?", "Warming", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (secenek == DialogResult.No)
                 {
                     SatısYap();
                     BorcEkle();
                     UcretGuncelle();
                     MağazadanÜrünüSil();
                     PuanEkle();
                     MessageBox.Show("Product Sale Was Maded", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else if (secenek == DialogResult.Yes)
                 {
                     Yaz();
                     SatışYap satisYap = new SatışYap();
                     satisYap.MdiParent       = ActiveForm;
                     satisYap.FormBorderStyle = FormBorderStyle.None;
                     satisYap.StartPosition   = FormStartPosition.CenterParent;
                     satisYap.Dock            = DockStyle.Fill;
                     satisYap.Show();
                     ListBox      satışBox = new ListBox();
                     FileStream   fs       = new FileStream(SatışUrl, FileMode.Open, FileAccess.Read);
                     StreamReader sw       = new StreamReader(fs);
                     string       yazi     = sw.ReadLine();
                     while (yazi != null)
                     {
                         satışBox.Items.Add(yazi);
                         yazi = sw.ReadLine();
                     }
                     if (satışBox.Items.Count != 0)
                     {
                         satisYap.cmbBoxMüşteriAdıSoyadı.Text      = satışBox.Items[0].ToString();
                         satisYap.cmbBoxÜrünNumarası.SelectedIndex = Int32.Parse(satışBox.Items[1].ToString());
                         int ücret = Int32.Parse(satışBox.Items[2].ToString());
                         int yüzde = (ücret * 5) / 100;
                         ücret = ücret - yüzde;
                         int eklenecek = 5 - (ücret % 5);
                         if ((ücret % 5) != 0)
                         {
                             ücret += eklenecek;
                         }
                         satisYap.txtBoxToplamÜcret.Text = ücret.ToString();
                     }
                     fs.Close();
                     durum = "NOT OK";
                 }
             }
             else if (durum == "NOT OK")
             {
                 SatısYap();
                 BorcEkle();
                 UcretGuncelle();
                 MağazadanÜrünüSil();
                 PuanEkle();
                 MessageBox.Show("Product Sale Was Maded", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 if (File.Exists(Application.StartupPath + "\\Satış.txt"))
                 {
                     File.Delete(Application.StartupPath + "\\Satış.txt");
                 }
                 Hide();
             }
         }
         else if (Bizim < enBuyuk || Bizim == 0)
         {
             SatısYap();
             BorcEkle();
             UcretGuncelle();
             MağazadanÜrünüSil();
             PuanEkle();
             MessageBox.Show("Product Sale Was Maded", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else if (Ayarlar.dil == "Türkçe")
     {
         MessageBoxManager.Unregister();
         MessageBoxManager.Yes = "Evet";
         MessageBoxManager.No  = "Hayır";
         MessageBoxManager.OK  = "Tamam";
         MessageBoxManager.Register();
         MaxPuan();
         ÜyePuanı();
         if (Bizim >= enBuyuk && Bizim != 0)
         {
             if (durum == "OK")
             {
                 DialogResult secenek = MessageBox.Show("Borcuna Sadık Müşterimize %5'lik İndirim Yapmak İstediğinize Emin Misiniz ?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (secenek == DialogResult.No)
                 {
                     SatısYap();
                     BorcEkle();
                     UcretGuncelle();
                     MağazadanÜrünüSil();
                     PuanEkle();
                     MessageBox.Show("Ürün Satışı Yapılmıştır.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else if (secenek == DialogResult.Yes)
                 {
                     Yaz();
                     SatışYap satisYap = new SatışYap();
                     satisYap.MdiParent       = ActiveForm;
                     satisYap.FormBorderStyle = FormBorderStyle.None;
                     satisYap.StartPosition   = FormStartPosition.CenterParent;
                     satisYap.Dock            = DockStyle.Fill;
                     satisYap.Show();
                     ListBox      satışBox = new ListBox();
                     FileStream   fs       = new FileStream(SatışUrl, FileMode.Open, FileAccess.Read);
                     StreamReader sw       = new StreamReader(fs);
                     string       yazi     = sw.ReadLine();
                     while (yazi != null)
                     {
                         satışBox.Items.Add(yazi);
                         yazi = sw.ReadLine();
                     }
                     if (satışBox.Items.Count != 0)
                     {
                         satisYap.cmbBoxMüşteriAdıSoyadı.Text      = satışBox.Items[0].ToString();
                         satisYap.cmbBoxÜrünNumarası.SelectedIndex = Int32.Parse(satışBox.Items[1].ToString());
                         int ücret = Int32.Parse(satışBox.Items[2].ToString());
                         int yüzde = (ücret * 5) / 100;
                         ücret = ücret - yüzde;
                         int eklenecek = 5 - (ücret % 5);
                         if ((ücret % 5) != 0)
                         {
                             ücret += eklenecek;
                         }
                         satisYap.txtBoxToplamÜcret.Text = ücret.ToString();
                     }
                     fs.Close();
                     durum = "NOT OK";
                 }
             }
             else if (durum == "NOT OK")
             {
                 SatısYap();
                 BorcEkle();
                 UcretGuncelle();
                 MağazadanÜrünüSil();
                 PuanEkle();
                 MessageBox.Show("Ürün Satışı Yapılmıştır.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 if (File.Exists(Application.StartupPath + "\\Satış.txt"))
                 {
                     File.Delete(Application.StartupPath + "\\Satış.txt");
                 }
                 Hide();
             }
         }
         else if (Bizim < enBuyuk || Bizim == 0)
         {
             SatısYap();
             BorcEkle();
             UcretGuncelle();
             MağazadanÜrünüSil();
             PuanEkle();
             MessageBox.Show("Ürün Satışı Yapılmıştır.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }