private void button1_Click(object sender, EventArgs e) { CrossGeneralManager crossGeneralManager = new CrossGeneralManager(); if (Form1.GDMLType == "U") { crossGeneralManager.UpdateCode(TXTCode.Text, Form1.GUrunMarka, Form1.GId); MessageBox.Show("Kayıt Güncellendi."); } else if (Form1.GDMLType == "I") { var modelList = new List <CrossGeneralModel>(); modelList.Add(new CrossGeneralModel { Oem = TXTOem.Text, Marka = TXTOemMarka.Text, UrunKodu = TXTCode.Text, AracTipi = TXTCarType.Text, UrunMarka = TXTMarka.Text }); crossGeneralManager.AddData(modelList); MessageBox.Show("Yeni Kayıt Eklendi."); } this.Close(); }
private void veriAktar(string veriyolu, string extension) { if (String.IsNullOrEmpty(veriyolu)) { MessageBox.Show("Dosya Seçmediniz !!!"); return; } List <CrossGeneralModel> uruns = new List <CrossGeneralModel>(); FileStream streamTemp = File.Open(veriyolu, FileMode.Open, FileAccess.Read); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using (var package = new ExcelPackage(streamTemp)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet[0];//florists var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; for (int rowIterator = 1; rowIterator <= noOfRow; rowIterator++) { var urun = new CrossGeneralModel(); urun.AracTipi = workSheet.Cells[rowIterator, 1].Value != null ? workSheet.Cells[rowIterator, 1].Value.ToString() : string.Empty; urun.Marka = workSheet.Cells[rowIterator, 2].Value != null ? workSheet.Cells[rowIterator, 2].Value.ToString() : string.Empty; urun.Oem = workSheet.Cells[rowIterator, 3].Value != null ? workSheet.Cells[rowIterator, 3].Value.ToString() : string.Empty; urun.UrunKodu = workSheet.Cells[rowIterator, 4].Value != null ? workSheet.Cells[rowIterator, 4].Value.ToString() : string.Empty; urun.UrunMarka = workSheet.Cells[rowIterator, 5].Value != null ? workSheet.Cells[rowIterator, 5].Value.ToString() : string.Empty; if (!(String.IsNullOrEmpty(urun.AracTipi))) { uruns.Add(urun); } progressBar1.Value = (progressBar1.Value >= 100) ? 0 : progressBar1.Value; progressBar1.Value++; } GRPLoader.Text = "Veriler Okundu"; int i = 0; foreach (var item in uruns) { if (i == 0) { CrossGeneralManager crossGeneralManager = new CrossGeneralManager(); crossGeneralManager.AddData(uruns); } progressBar1.Value = (progressBar1.Value >= 100) ? 0 : progressBar1.Value; progressBar1.Value++; GRPLoader.Text = "Veriler Dbye Yazılıyor."; i++; } GRPLoader.Text = "Veriler Dbye Yazıldı"; GRPLoader.Visible = false; MessageBox.Show("Aktarım Tamamlandı"); } }
private void button1_Click(object sender, EventArgs e) { CrossGeneralManager crossGeneralManager = new CrossGeneralManager(); var modelList = new List <CrossGeneralModel>(); modelList.Add(new CrossGeneralModel { Oem = TXTOem.Text, Marka = TXTOemMarka.Text, UrunKodu = TXTCode.Text, AracTipi = TXTCarType.Text, UrunMarka = TXTMarka.Text }); crossGeneralManager.AddData(modelList); this.Close(); }