Пример #1
0
 public ActionResult StokIslemleri()
 {
     if (Session["User"] != null && Session["Yetki"].ToString() == "Admin")
     {
         var Gonder = UrunRepo.StokListe();
         VMRAM.RamData  = UrunRepo.SinifKoduGet();
         VMRAM.RamData2 = UrunRepo.SinifTanimiGet();
         VMRAM.SecData  = UrunRepo.SectionGet();
         ViewBag.Class  = "text-warning";
         ViewBag.Text   = "Otomatik Stok ve Fiyat Yükleme Sistemi V.0.4 (Beta)";
         return(View(Gonder));
     }
     else
     {
         TempData["UyariTipi"] = "text-danger";
         TempData["Sonuc"]     = "Tarayıcıda Oturum Süreniz Dolmuş! Lütfen Tekrar Oturum Açın!";
         return(RedirectToAction("Logon", "Login"));
     }
 }
Пример #2
0
 public ActionResult StokIslemleri(HttpPostedFileBase Dosya)
 {
     if (Session["User"] != null && Session["Yetki"].ToString() == "Admin")
     {
         if ((Dosya != null) && (Dosya.ContentLength > 0) && !string.IsNullOrEmpty(Dosya.FileName))
         {
             try
             {
                 List <VMStokEkle> liste = new List <VMStokEkle>();
                 using (var package = new ExcelPackage(Dosya.InputStream))
                 {
                     var currentSheet = package.Workbook.Worksheets;
                     var workSheet    = currentSheet.First();
                     int noOfRow      = workSheet.Dimension.End.Row;
                     for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                     {
                         liste.Add(new VMStokEkle
                         {
                             MalzemeKodu = (workSheet.Cells[rowIterator, 5].Value ?? String.Empty).ToString(),
                             Stok        = int.Parse((workSheet.Cells[rowIterator, 6].Value ?? String.Empty).ToString() == string.Empty ? "0" : (workSheet.Cells[rowIterator, 6].Value ?? String.Empty).ToString()),
                             Fiyati      = double.Parse((workSheet.Cells[rowIterator, 7].Value ?? String.Empty).ToString() == string.Empty ? "0" : (workSheet.Cells[rowIterator, 7].Value ?? String.Empty).ToString())
                         });
                     }
                 }
                 bool sonuc = UrunRepo.StokEkleExcel(liste);
                 if (sonuc != false)
                 {
                     var Gonder = UrunRepo.StokListe();
                     VMRAM.RamData  = UrunRepo.SinifKoduGet();
                     VMRAM.RamData2 = UrunRepo.SinifTanimiGet();
                     VMRAM.SecData  = UrunRepo.SectionGet();
                     ViewBag.Class  = "text-success";
                     ViewBag.Text   = "İşlem Başarılı!";
                     return(View(Gonder));
                 }
                 else
                 {
                     var Gonder = UrunRepo.StokListe();
                     VMRAM.RamData  = UrunRepo.SinifKoduGet();
                     VMRAM.RamData2 = UrunRepo.SinifTanimiGet();
                     VMRAM.SecData  = UrunRepo.SectionGet();
                     ViewBag.Class  = "text-warning";
                     ViewBag.Text   = "İşlem Başarısız!";
                     return(View(Gonder));
                 }
             }
             catch
             {
                 var Gonder = UrunRepo.StokListe();
                 VMRAM.RamData  = UrunRepo.SinifKoduGet();
                 VMRAM.RamData2 = UrunRepo.SinifTanimiGet();
                 VMRAM.SecData  = UrunRepo.SectionGet();
                 ViewBag.Class  = "text-warning";
                 ViewBag.Text   = "Dosya Okunamadı!";
                 return(View(Gonder));
             }
         }
         else
         {
             var Gonder = UrunRepo.StokListe();
             VMRAM.RamData  = UrunRepo.SinifKoduGet();
             VMRAM.RamData2 = UrunRepo.SinifTanimiGet();
             VMRAM.SecData  = UrunRepo.SectionGet();
             ViewBag.Class  = "text-warning";
             ViewBag.Text   = "Geçerli Bir Excel Dosyası Değil!";
             return(View(Gonder));
         }
     }
     else
     {
         TempData["UyariTipi"] = "text-danger";
         TempData["Sonuc"]     = "Tarayıcıda Oturum Süreniz Dolmuş! Lütfen Tekrar Oturum Açın!";
         return(RedirectToAction("Logon", "Login"));
     }
 }