private void btnOdeme_Click(object sender, EventArgs e) { FormOdeme odeme = new FormOdeme(); odeme.Show(); }
//Muşterinin vermiş olduğu tüm sipariş bilgerini txt dosyasına yazdırma private void btnOdeme_Click(object sender, EventArgs e) { const int SUBITEM1_POS = 0; const int SUBITEM2_POS = 1; const int SUBITEM3_POS = 2; const int SUBITEM4_POS = 3; const int SUBITEM6_POS = 5; const int SUBITEM7_POS = 6; const int SUBITEM8_POS = 7; const int SUBITEM12_POS = 11; const int SUBITEM13_POS = 12; StreamWriter sw = File.AppendText("MusteriTakip.txt"); for (int i = 0; i < lwSepet.Items.Count; i++) { string currentSubItem1 = lwSepet.Items[i].SubItems[SUBITEM1_POS].Text; string currentSubItem2 = lwSepet.Items[i].SubItems[SUBITEM2_POS].Text; string currentSubItem3 = lwSepet.Items[i].SubItems[SUBITEM3_POS].Text; string currentSubItem4 = lwSepet.Items[i].SubItems[SUBITEM4_POS].Text; string currentSubItem6 = lwSepet.Items[i].SubItems[SUBITEM6_POS].Text; string currentSubItem7 = lwSepet.Items[i].SubItems[SUBITEM7_POS].Text; string currentSubItem8 = lwSepet.Items[i].SubItems[SUBITEM8_POS].Text; string currentSubItem12 = lwSepet.Items[i].SubItems[SUBITEM12_POS].Text; string currentSubItem13 = lwSepet.Items[i].SubItems[SUBITEM13_POS].Text; //Yazma işlemi için bir StreamWriter nesnesi oluşturduk. sw.WriteLine("Adı Soyadı :" + currentSubItem1 + " Ürün Adı :" + currentSubItem2 + " Ürün Adeti :" + currentSubItem3 + " Sipariş Tarihi :" + currentSubItem4 + " Mail Adresi :" + currentSubItem6 + " Kargo Adresi :" + currentSubItem7 + " Gsm :" + currentSubItem8 + " Kargo Ağırlığı :" + currentSubItem12 + " Toplam Fiyat :" + currentSubItem13); //Dosyaya ekleyeceğimiz iki satırlık yazıyı WriteLine() metodu ile yazacağız. } sw.Close(); // bütün ürünlerin tutarını tek değişkene atama işlemi decimal Toplam2 = 0; //int dizitemp=0;//dizi indis adeti için bir değişken for (int j = 0; j < lwSepet.Items.Count; j++) { string toplam = lwSepet.Items[j].SubItems[12].Text; decimal Toplam1 = Convert.ToDecimal(toplam); Toplam2 = Toplam2 + Toplam1; } U.TumToplam = Toplam2; //toplam fiyatı urun dizisine attık string metin1; string metin2; string metin3; // SepettekiUrunler.txt dosyasında daha önceki kayıtları siliyoruz. TextWriter tw = new StreamWriter("SepettekiUrunler.txt"); tw.Write(""); tw.Close(); // SepettekiUrunler.txt Dosyasına yeni kayıtları giriyoruz. for (int j = 0; j < lwSepet.Items.Count; j++) { metin1 = lwSepet.Items[j].SubItems[1].Text; metin2 = lwSepet.Items[j].SubItems[2].Text; metin3 = lwSepet.Items[j].SubItems[12].Text; StreamWriter SWSepet = File.AppendText("SepettekiUrunler.txt"); SWSepet.WriteLine("Ürün Adı : " + metin1 + " Ürün Adedi :" + metin2 + " Fiyat :" + metin3); SWSepet.Close(); } FormOdeme form = new FormOdeme(); form.Show(); }