コード例 #1
0
ファイル: MemberDetails.cs プロジェクト: Fatihprlg/GymApp
 private void licenceBtn_Click(object sender, EventArgs e)
 {
     saveFileDialog1.FileName   = adTextBox.Text + " Lisans";
     saveFileDialog1.DefaultExt = "xlsx";
     saveFileDialog1.Filter     = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
     saveFileDialog1.ShowDialog();
     if (saveFileDialog1.FileName != null)
     {
         try
         {
             var   filePath = Assembly.GetExecutingAssembly().CodeBase + "/../../../Resources/bosLisans.xlsx";
             Excel license  = new Excel(filePath, 1);
             license.WriteCell(0, 1, bransComboBox.SelectedItem.ToString());
             license.WriteCell(1, 1, kulupAdi);
             license.WriteCell(2, 1, tCTextBox.Text);
             license.WriteCell(3, 1, adTextBox.Text);
             license.WriteCell(4, 1, soyadTextBox.Text);
             license.WriteCell(5, 1, dogum_YeriTextBox.Text);
             license.WriteCell(7, 1, cinsiyet_TextBox.Text);
             license.WriteCell(8, 1, baba_AdiTextBox.Text);
             license.WriteCell(9, 1, anne_AdiTextBox.Text);
             license.WriteCell(10, 1, dogum_YeriTextBox.Text);
             license.WriteCell(16, 1, adresTextBox.Text);
             license.WriteCell(11, 1, dogumTarihiDateTimePicker.Value.ToString("dd/MM/yyyy"));
             license.WriteCell(21, 1, numaraTextBox.Text);
             license.WriteCell(22, 1, eMailTextBox.Text);
             license.SaveAs(saveFileDialog1.FileName);
             license.Close();
             if (MessageBox.Show("Lisans kaydedildi. Açmak istiyor musunuz?", "İşlem Başarılı", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 try
                 {
                     string fileName = saveFileDialog1.FileName;
                     if (!fileName.Contains(".xlsx"))
                     {
                         fileName += ".xlsx";
                     }
                     var process = new System.Diagnostics.Process();
                     process.StartInfo = new System.Diagnostics.ProcessStartInfo()
                     {
                         UseShellExecute = true, FileName = fileName
                     };
                     process.Start();
                 }
                 catch (Exception)
                 {
                     throw;
                 }
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #2
0
ファイル: Accounting.cs プロジェクト: Fatihprlg/GymApp
 private void reportBtn_Click(object sender, EventArgs e)
 {
     saveFileDialog1.FileName   = "Rapor";
     saveFileDialog1.DefaultExt = "xlsx";
     saveFileDialog1.Filter     = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
     saveFileDialog1.ShowDialog();
     try
     {
         var   filePath     = Assembly.GetExecutingAssembly().CodeBase + "/../../../Resources/GelirGiderRapor.xlsx";
         int   j            = 0;
         Excel reportIncome = new Excel(filePath, 2);
         for (int i = 0; i < accountingList.Items.Count; i++)
         {
             if (float.Parse(accountingList.Items[i].SubItems[1].Text) > 0)
             {
                 reportIncome.WriteCell(j + 3, 1, accountingList.Items[i].SubItems[3].Text);
                 reportIncome.WriteCell(j + 3, 2, accountingList.Items[i].SubItems[1].Text);
                 j++;
             }
         }
         reportIncome.SaveAs(saveFileDialog1.FileName);
         reportIncome.Close();
         j = 0;
         Excel reportExpense = new Excel(saveFileDialog1.FileName, 3);
         for (int i = 0; i < accountingList.Items.Count; i++)
         {
             if (float.Parse(accountingList.Items[i].SubItems[1].Text) < 0)
             {
                 reportExpense.WriteCell(j + 3, 1, accountingList.Items[i].SubItems[3].Text);
                 reportExpense.WriteCell(j + 3, 2, accountingList.Items[i].SubItems[1].Text.Substring(1));
                 j++;
             }
         }
         reportExpense.Save();
         reportExpense.Close();
         if (MessageBox.Show("Rapor kaydedildi. Açmak istiyor musunuz?", "İşlem Başarılı", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             try
             {
                 string fileName = saveFileDialog1.FileName;
                 if (!fileName.Contains(".xlsx"))
                 {
                     fileName += ".xlsx";
                 }
                 var process = new System.Diagnostics.Process();
                 process.StartInfo = new System.Diagnostics.ProcessStartInfo()
                 {
                     UseShellExecute = true, FileName = fileName
                 };
                 process.Start();
             }
             catch (Exception ex1)
             {
                 MessageBox.Show(ex1.Message);
             }
         }
     }
     catch (Exception ex2)
     {
         MessageBox.Show(ex2.Message);
     }
 }
コード例 #3
0
ファイル: Receipt.cs プロジェクト: Fatihprlg/GymApp
 private void printBtn_Click(object sender, EventArgs e)
 {
     miktar = float.Parse(cardTextBox.Text) + float.Parse(transferTextBox.Text) + float.Parse(cashTextBox.Text);
     if (miktar <= toplam)
     {
         saveFileDialog1.FileName   = musteri + " " + aciklama + " Makbuz";
         saveFileDialog1.DefaultExt = "xlsx";
         saveFileDialog1.Filter     = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
         saveFileDialog1.ShowDialog();
         if (saveFileDialog1.FileName != null)
         {
             try
             {
                 var   filePath = Assembly.GetExecutingAssembly().CodeBase + "/../../../Resources/TAHSİLAT-MAKBUZU.xlsx";
                 Excel report   = new Excel(filePath, 1);
                 report.WriteCell(4, 6, "Tarih: " + DateTime.Now.ToString("dd/MM/yyyy"));
                 report.WriteCell(6, 7, Accounting.accID.ToString());
                 report.WriteCell(8, 2, musteri);
                 report.WriteCell(8, 5, aciklama);
                 report.WriteCell(9, 5, miktar.ToString() + "TL");
                 report.WriteCell(11, 3, cardTextBox.Text);
                 report.WriteCell(12, 3, transferTextBox.Text);
                 report.WriteCell(13, 3, cashTextBox.Text);
                 report.WriteCell(15, 3, miktar.ToString() + "TL");
                 report.WriteCell(16, 3, musteri);
                 report.WriteCell(16, 7, teslimAlan);
                 report.SaveAs(saveFileDialog1.FileName);
                 report.Close();
                 if (MessageBox.Show("Makbuz kaydedildi. Açmak istiyor musunuz?", "İşlem Başarılı", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 {
                     try
                     {
                         string fileName = saveFileDialog1.FileName;
                         if (!fileName.Contains(".xlsx"))
                         {
                             fileName += ".xlsx";
                         }
                         var process = new System.Diagnostics.Process();
                         process.StartInfo = new System.Diagnostics.ProcessStartInfo()
                         {
                             UseShellExecute = true, FileName = fileName
                         };
                         process.Start();
                     }
                     catch (Exception)
                     {
                         throw;
                     }
                 }
             }
             catch (Exception)
             {
                 throw;
             }
             connection.Open();
             SqlCommand updateAcc = new SqlCommand("update Accounting set Tahsil = @tahsil where Id = @id", connection);
             updateAcc.Parameters.AddWithValue("@tahsil", 1);
             updateAcc.Parameters.AddWithValue("@id", Accounting.accID);
             updateAcc.ExecuteNonQuery();
             connection.Close();
         }
     }
     else
     {
         wrongLbl.Visible = true;
     }
 }