bool StokKontrol(UrunViewModel seciliUrun)
        {
            bool varmi = false, cevap = false;

            sepetList.ForEach(x =>
            {
                if (x.UrunID == seciliUrun.UrunID)
                {
                    varmi = true;
                    if (seciliUrun.Stok > x.Adet)
                    {
                        cevap = true;
                    }
                    else
                    {
                        cevap = false;
                    }
                }
            });
            if (!varmi)
            {
                if (seciliUrun.Stok > 0)
                {
                    cevap = true;
                }
                else
                {
                    cevap = false;
                }
            }
            return(cevap);
        }
Exemple #2
0
        public ActionResult UrunDuzenle(UrunViewModel uvm, HttpPostedFileBase file)
        {
            var filename = ImageNameGenerator.ProfilFotoIsmiUret(file);
            var path     = "null";

            uvm.Fotograf = filename;
            UrunYonetici uy = new UrunYonetici();
            BusinessLayerResult <Urun> res = new BusinessLayerResult <Urun>();

            if (file != null)
            {
                //filename = Path.GetFileName(file[0].FileName);
                path = Path.Combine(Server.MapPath("~/Content/Image/Urun"), filename);
                Image imgnew = ResizeImage.Resize(Image.FromStream(file.InputStream), 0, 473); //son eklediğim alan
                //file[0].SaveAs(path);
                imgnew.Save(path);
            }
            if (res.Errors.Count > 0)
            {
                res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                return(View(uvm));
            }
            if (ModelState.IsValid)
            {
                Urun             urnyeni = uy.Find(x => x.ilanId == uvm.IlanId);
                RenkYonetici     ry      = new RenkYonetici();
                SehirYonetici    sy      = new SehirYonetici();
                KategoriYonetici ky      = new KategoriYonetici();
                if (uvm.takasdegeri == "UYGUN")
                {
                    uvm.Takas = true;
                }
                else
                {
                    uvm.Takas = false;
                }
                //Burayı düzelt...
                urnyeni.ilanId         = uvm.IlanId;
                urnyeni.urunBaslik     = uvm.UrunBaslik;
                urnyeni.urunFiyati     = uvm.UrunFiyat;
                urnyeni.renkId         = ry.Find(x => x.renkAdi == uvm.UrunRenkAdi).renkId;
                urnyeni.urunKonum      = uvm.UrunKonum;
                urnyeni.ilPlaka        = sy.Find(x => x.ilAdi == uvm.SehirAlani).ilPlaka;
                urnyeni.kategoriId     = ky.Find(x => x.kategoriAdi == uvm.KategoriAdi).kategoriId;
                urnyeni.takasyapilirmi = uvm.Takas;
                urnyeni.durumu         = uvm.durumu;
                urnyeni.urunAciklama   = uvm.UrunAciklama;
                urnyeni.halasatilikmi  = true;
                urnyeni.kullaniciId    = App.Common.GetCurrentUsernameId();
                //urnyeni.satistarihsaat = DateTime.Now; //Ürün güncellendiği zaman yükleme tarihi aynı kalsın
                if (file != null)
                {
                    urnyeni.urunFotosu = filename;
                }

                uy.Update(urnyeni);
                return(RedirectToAction("Sattiklarim", "Profil"));
            }
            return(View(uvm));
        }
Exemple #3
0
        // GET: YoneticiPaneli
        public ActionResult Index()
        {
            var model = new UrunViewModel();

            model.user   = db.User.Where(g => g.Status == true).ToList();
            model.satici = db.Satıcı.Where(g => g.Status == true).ToList();
            return(View(model));
        }
Exemple #4
0
        public ActionResult Ekle()
        {
            var model = new UrunViewModel()
            {
                Categories = db.Categories.OrderBy(x => x.CategoryName).ToList()
            };

            return(View("UrunForm", model));
        }
        public ActionResult Index()
        {
            StockControlEntities db = new StockControlEntities();
            var model = new UrunViewModel();

            model.girenUrun = db.GirenUrun.Where(x => x.Status).ToList();
            model.cikanUrun = db.CikanUrun.Where(x => x.Status).ToList();
            return(View(model));
        }
Exemple #6
0
        public BusinessLayerResult <Urun> UrunKayit(UrunViewModel data, HttpPostedFileBase file)
        {
            Urun urn = Find(x => x.urunBaslik == data.UrunBaslik && x.urunAciklama == data.UrunAciklama);
            BusinessLayerResult <Urun> res = new BusinessLayerResult <Urun>();

            if (urn != null)
            {
                res.AddError(ErrorMessageCode.UrunKayitli, "Ürün kayıtlı.");
            }
            else if (!isValidContentType(file.ContentType))
            {
                res.AddError(ErrorMessageCode.DosyaFormat, "Sadece jpg, jpeg, png ve gif formatında yükleyebilirsiniz.");
            }
            else if (!isValidContentLength(file.ContentLength))
            {
                res.AddError(ErrorMessageCode.DosyaBoyut, "10MB'dan az bir görsel yükleyiniz.");
            }
            else
            {
                Random rastgele = new Random();
                long   sayi     = 0;
                while (true)
                {
                    sayi = rastgele.Next(11111111, 99999999);
                    if (Find(x => x.ilanId == sayi) == null)
                    {
                        break;
                    }
                }
                Kategori kat      = repo_kategori.Find(x => x.kategoriAdi == data.KategoriAdi);
                Sehir    shr      = repo_shr.Find(x => x.ilAdi == data.SehirAlani);
                Renk     rnk      = repo_rnk.Find(x => x.renkAdi == data.UrunRenkAdi);
                int      dbResult = Insert(new Urun()
                {
                    ilanId         = sayi,
                    urunBaslik     = data.UrunBaslik,
                    urunFiyati     = data.UrunFiyat,
                    renkId         = rnk.renkId,
                    urunKonum      = data.UrunKonum,
                    ilPlaka        = shr.ilPlaka,
                    kategoriId     = kat.kategoriId,
                    takasyapilirmi = data.Takas,
                    durumu         = data.durumu,
                    urunAciklama   = data.UrunAciklama,
                    halasatilikmi  = true,
                    kullaniciId    = App.Common.GetCurrentUsernameId(),
                    satistarihsaat = DateTime.Now,
                    urunFotosu     = data.Fotograf
                });
                if (dbResult > 0)
                {
                    res.Result = Find(x => x.urunBaslik == data.UrunBaslik && x.urunKonum == data.UrunKonum);
                }
            }
            return(res);
        }
        public ActionResult Index()
        {
            using (PersonelContext ctx = new PersonelContext())
            {
                UrunViewModel pvm = new UrunViewModel();
                pvm.Urunler = ctx.Urunler.ToList();

                return(View(pvm));
            }
        }
Exemple #8
0
        // GET: IslemPanosu
        public ActionResult Index()
        {
            StockControlEntities db = new StockControlEntities();
            var model = new UrunViewModel();

            model.material  = db.Material.ToList();
            model.girenUrun = db.GirenUrun.ToList();
            model.cikanUrun = db.CikanUrun.ToList();
            return(View(model));
        }
Exemple #9
0
        public ActionResult New()
        {
            var kategoriler = _ks.GetCategories().Data;
            var viewModel   = new UrunViewModel
            {
                Urun        = new UrunDTO(),
                Kategoriler = kategoriler
            };

            return(View("urunForm", viewModel));
        }
        public ActionResult URUNAYRINTI(int id)
        {
            var urun          = db.TBLURUNLER.Where(m => m.URUNID == id).ToList();
            var yorum         = db.TBLYORUM.Where(m => m.YORUNURUN == id).ToList();
            var urunViewModel = new UrunViewModel
            {
                urun     = urun,
                yorumlar = yorum
            };


            return(View("URUNAYRINTI", urunViewModel));
        }
Exemple #11
0
        public ActionResult UrunDuzenle(long?id)
        {
            if (Session["giris"] == null)
            {
                return(RedirectToAction("Giris", "Home"));
            }
            UrunYonetici     uy  = new UrunYonetici();
            SehirYonetici    sy  = new SehirYonetici();
            UrunViewModel    uvm = new UrunViewModel();
            KategoriYonetici ky  = new KategoriYonetici();
            RenkYonetici     ry  = new RenkYonetici();

            if (id.Value == 0)
            {
                return(RedirectToAction("Sattiklarim", "Profil"));
            }
            Urun     urn = uy.Find(x => x.urunId == id);
            Sehir    shr = sy.Find(x => x.ilPlaka == urn.ilPlaka);
            Kategori kat = ky.Find(x => x.kategoriId == urn.kategoriId);
            Renk     rnk = ry.Find(x => x.renkId == urn.renkId);

            if (urn.takasyapilirmi)
            {
                uvm.takasdegeri = "UYGUN";
            }
            else
            {
                uvm.takasdegeri = "UYGUN DEĞİL";
            }
            if (urn.durumu)
            {
                uvm.durumdegeri = "İKİNCİ EL";
            }
            else
            {
                uvm.durumdegeri = "SIFIR";
            }
            uvm.Takas        = urn.takasyapilirmi;
            uvm.durumu       = urn.durumu;
            uvm.UrunAciklama = urn.urunAciklama;
            uvm.UrunBaslik   = urn.urunBaslik;
            uvm.UrunFiyat    = urn.urunFiyati;
            uvm.UrunKonum    = urn.urunKonum;
            uvm.SehirAlani   = shr.ilAdi;
            uvm.Fotograf     = urn.urunFotosu;
            uvm.KategoriAdi  = kat.kategoriAdi;
            uvm.UrunRenkAdi  = rnk.renkAdi;
            uvm.IlanId       = urn.ilanId;
            return(View(uvm));
        }
Exemple #12
0
        public async Task <ActionResult> Ekle(UrunViewModel model)
        {
            if (model == null)
            {
                return(RedirectToAction("Ekle"));
            }
            var yeniUrun = new Urun()
            {
                AktifMi    = model.AktifMi,
                Fiyat      = model.Fiyat,
                KategoriId = model.KategoriId,
                UrunAdi    = model.UrunAdi
            };

            try
            {
                await new UrunRepo().Insert(yeniUrun);
                if (model.Dosyalar.Any())
                {
                    foreach (var dosya in model.Dosyalar)
                    {
                        string fileName = Path.GetFileNameWithoutExtension(dosya.FileName);
                        string extName  = Path.GetExtension(dosya.FileName);
                        fileName  = SiteSettings.UrlFormatConverter(fileName);
                        fileName += Guid.NewGuid().ToString().Replace("-", "");
                        var directoryPath = Server.MapPath("~/Uploads/products");
                        var filePath      = Server.MapPath("~/Uploads/products/") + fileName + extName;
                        if (!Directory.Exists(directoryPath))
                        {
                            Directory.CreateDirectory(directoryPath);
                        }
                        dosya.SaveAs(filePath);
                        ResimBoyutlandir(400, 300, filePath);
                        await new DosyaRepo().Insert(new Dosya()
                        {
                            DosyaYolu = @"/Uploads/products/" + fileName + extName,
                            AktifMi   = true,
                            UrunId    = yeniUrun.Id,
                            Uzanti    = extName.Substring(1)
                        });
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(RedirectToAction("Ekle"));
            }
        }
        bool StokKontrol(UrunViewModel seciliUrun, short adet = 1)
        {
            bool varmi = false, cevap = false;

            sepetList.ForEach(x =>
            {
                if (x.ProductID == seciliUrun.UrunId)
                {
                    varmi = true;
                    if (adet == 1)
                    {
                        if (seciliUrun.Stok > x.Quantity)
                        {
                            cevap = true;
                        }
                        else
                        {
                            cevap = false;
                        }
                    }
                    else if (adet > 1)
                    {
                        if (seciliUrun.Stok >= adet)
                        {
                            cevap = true;
                        }
                        else
                        {
                            cevap = false;
                        }
                    }
                }
            });

            if (!varmi)
            {
                if (seciliUrun.Stok > 0)
                {
                    cevap = true;
                }
                else
                {
                    cevap = false;
                }
            }
            return(cevap);
        }
Exemple #14
0
        public string GetStock(int MaterialId, int DepoId)
        {
            int did = DepoId;
            int mid = MaterialId;
            StockControlEntities db = new StockControlEntities();
            var model           = new UrunViewModel();
            var girenUrunToplam = db.GirenUrun
                                  .GroupBy(x => new { x.DepoId, x.MaterialId, x.Status })
                                  .Select(g => new
            {
                g.Key.MaterialId,
                g.Key.DepoId,
                g.Key.Status,
                total = g.Sum(t => t.Adet)
            }
                                          )
                                  .Where(x => x.MaterialId == mid && x.DepoId == did && x.Status).ToList();

            var cikanUrunToplam = db.CikanUrun
                                  .GroupBy(x => new { x.DepoId, x.MaterialId, x.Status })
                                  .Select(g => new
            {
                g.Key.MaterialId,
                g.Key.DepoId,
                g.Key.Status,
                total = g.Sum(t => t.Adet)
            }
                                          )
                                  .Where(x => x.MaterialId == mid && x.DepoId == did && x.Status).ToList();
            var kalanMiktar = 0;

            foreach (var inProduct in girenUrunToplam)
            {
                var outProduct = cikanUrunToplam.Where(p => p.MaterialId == inProduct.MaterialId && p.DepoId == inProduct.DepoId).FirstOrDefault();

                if (outProduct == null)
                {
                    kalanMiktar = inProduct.total;
                }
                else
                {
                    kalanMiktar = inProduct.total - outProduct.total;
                }
            }
            return(kalanMiktar.ToString());
        }
Exemple #15
0
        /// <summary>
        /// Partial Navbarda kullanılıyor. Dikkat edin.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult UrunleriGoster(Guid id)
        {
            var urunler = _us.GetProducts().Data;

            var data = (from d in urunler
                        where d.KategoriId == id
                        select d);
            List <UrunViewModel> urunViewModels = new List <UrunViewModel>();

            foreach (var item in data)
            {
                var viewModel = new UrunViewModel()
                {
                    Urun = item
                };
                urunViewModels.Add(viewModel);
            }
            return(View(urunViewModels));
        }
Exemple #16
0
        public ActionResult Edit(Guid id)
        {
            var urun = _us.Get(id).Data;

            var viewModel = new UrunViewModel()
            {
                Urun        = urun,
                Kategoriler = _ks.GetCategories().Data
            };


            if (urun == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View("urunForm", viewModel));
            }
        }
Exemple #17
0
        public ActionResult Save(UrunDTO urun)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new UrunViewModel
                {
                    Urun        = urun,
                    Kategoriler = _ks.GetCategories().Data
                };
                return(View("urunForm", viewModel));
            }

            #region  resim kaydetme ve yol verme

            if (urun.ResimDosyasi != null)
            {
                string fileName  = Path.GetFileNameWithoutExtension(urun.ResimDosyasi.FileName);
                string extension = Path.GetExtension(urun.ResimDosyasi.FileName);
                fileName       = urun.UrunAdi + fileName + DateTime.Now.ToString("ddmmyyyy") + extension;
                urun.ResimYolu = "/img/" + fileName;
                fileName       = Path.Combine(Server.MapPath("~/img/"), fileName);
                urun.ResimDosyasi.SaveAs(fileName);
            }
            #endregion

            if (urun.Id == Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                urun.EklemeTarihi = DateTime.Now.Date;
                _us.Add(urun);
            }
            else
            {
                _us.Update(urun);
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemple #18
0
        public void IslemPanosu()
        {
            StockControlEntities db = new StockControlEntities();
            var model = new UrunViewModel();

            model.material  = db.Material.ToList();
            model.girenUrun = db.GirenUrun.ToList();
            model.cikanUrun = db.CikanUrun.ToList();
            string       constr = ConfigurationManager.AppSettings["connectionString"];
            var          Client = new MongoClient(constr);
            ExcelPackage Ep     = new ExcelPackage();

            ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("Malzeme Grubu İşlemleri");

            Sheet.Cells["A1"].Value = "MAL GRUBU";
            Sheet.Cells["B1"].Value = "KULLANICI ADI";
            Sheet.Cells["C1"].Value = "DEPARTMAN";
            Sheet.Cells["D1"].Value = "OLUŞTURULMA TARİHİ";
            Sheet.Cells["E1"].Value = "DEĞİŞTİRİLME TARİHİ";
            int row = 2;

            foreach (var item in model.material)
            {
                Sheet.Cells[string.Format("A{0}", row)].Value = item.MaterialName;
                Sheet.Cells[string.Format("B{0}", row)].Value = item.User.Username;
                Sheet.Cells[string.Format("C{0}", row)].Value = item.User.Departman;
                Sheet.Cells[string.Format("D{0}", row)].Value = "" + item.OlusTarih.ToString("dd.MM.yyyy HH:mm:ss");
                Sheet.Cells[string.Format("E{0}", row)].Value = "" + item.DegisTarih?.ToString("dd.MM.yyyy HH:mm:ss") ?? "";
                row++;
            }
            Sheet.Cells["A:AZ"].AutoFitColumns();

            ExcelWorksheet Sheet2 = Ep.Workbook.Worksheets.Add("Ürün Girişi İşlemleri");

            Sheet2.Cells["A1"].Value = "İŞLEM KODU";
            Sheet2.Cells["B1"].Value = "MAL GRUBU";
            Sheet2.Cells["C1"].Value = "GİRİŞ TARİHİ";
            Sheet2.Cells["D1"].Value = "ADET";
            Sheet2.Cells["E1"].Value = "TUTAR";
            Sheet2.Cells["F1"].Value = "SATICI ADI";
            Sheet2.Cells["G1"].Value = "DEPO YERİ";
            Sheet2.Cells["H1"].Value = "KULLANICI ADI";
            Sheet2.Cells["I1"].Value = "DEPARTMAN";
            Sheet2.Cells["J1"].Value = "OLUŞTURULMA TARİHİ";
            Sheet2.Cells["K1"].Value = "DEĞİŞTİRİLME TARİHİ";
            int row2 = 2;

            foreach (var item2 in model.girenUrun)
            {
                Sheet2.Cells[string.Format("A{0}", row2)].Value = item2.IslemKodu;
                Sheet2.Cells[string.Format("B{0}", row2)].Value = item2.Material.MaterialName;
                Sheet2.Cells[string.Format("C{0}", row2)].Value = item2.GirisTarihi.Date.ToString("dd.MM.yyyy");
                Sheet2.Cells[string.Format("D{0}", row2)].Value = item2.Adet;
                if (item2.ParaBirimi == 1)
                {
                    Sheet2.Cells[string.Format("E{0}", row2)].Value = "" + item2.Tutar.ToString("0.00") + " TL";
                }
                else if (item2.ParaBirimi == 2)
                {
                    Sheet2.Cells[string.Format("E{0}", row2)].Value = "" + item2.Tutar.ToString("0.00") + " USD";
                }
                else
                {
                    Sheet2.Cells[string.Format("E{0}", row2)].Value = "" + item2.Tutar.ToString("0.00") + " EUR";
                }
                Sheet2.Cells[string.Format("F{0}", row2)].Value = item2.Satıcı.SaticiAdi;
                Sheet2.Cells[string.Format("G{0}", row2)].Value = item2.Depo.Yer;
                Sheet2.Cells[string.Format("H{0}", row2)].Value = item2.User.Username;
                Sheet2.Cells[string.Format("I{0}", row2)].Value = item2.User.Departman;
                Sheet2.Cells[string.Format("J{0}", row2)].Value = "" + item2.OlusTarih.ToString("dd.MM.yyyy HH:mm:ss");
                Sheet2.Cells[string.Format("K{0}", row2)].Value = "" + item2.DegisTarih?.ToString("dd.MM.yyyy HH:mm:ss") ?? "";
                row2++;
            }
            Sheet2.Cells["A:AZ"].AutoFitColumns();

            ExcelWorksheet Sheet3 = Ep.Workbook.Worksheets.Add("Ürün Çıkışı İşlemleri");

            Sheet3.Cells["A1"].Value = "İŞLEM KODU";
            Sheet3.Cells["B1"].Value = "MAL GRUBU";
            Sheet3.Cells["C1"].Value = "ÇIKIŞ TARİHİ";
            Sheet3.Cells["D1"].Value = "ADET";
            Sheet3.Cells["E1"].Value = "SEVK YERİ";
            Sheet3.Cells["F1"].Value = "ÜRÜN ÇIKIŞ YERİ";
            Sheet3.Cells["G1"].Value = "KULLANICI ADI";
            Sheet3.Cells["H1"].Value = "DEPARTMAN";
            Sheet3.Cells["I1"].Value = "OLUŞTURULMA TARİHİ";
            Sheet3.Cells["J1"].Value = "DEĞİŞTİRİLME TARİHİ";
            int row3 = 2;

            foreach (var item3 in model.cikanUrun)
            {
                Sheet3.Cells[string.Format("A{0}", row3)].Value = item3.IslemKodu;
                Sheet3.Cells[string.Format("B{0}", row3)].Value = item3.Material.MaterialName;
                Sheet3.Cells[string.Format("C{0}", row3)].Value = item3.CikisTarihi.Date.ToString("dd.MM.yyyy");
                Sheet3.Cells[string.Format("D{0}", row3)].Value = item3.Adet;
                Sheet3.Cells[string.Format("E{0}", row3)].Value = item3.SevkYeri;
                Sheet3.Cells[string.Format("F{0}", row3)].Value = item3.Depo.Yer;
                Sheet3.Cells[string.Format("G{0}", row3)].Value = item3.User.Username;
                Sheet3.Cells[string.Format("H{0}", row3)].Value = item3.User.Departman;
                Sheet3.Cells[string.Format("I{0}", row3)].Value = "" + item3.OlusTarih.ToString("dd.MM.yyyy HH:mm:ss");
                Sheet3.Cells[string.Format("J{0}", row3)].Value = "" + item3.DegisTarih?.ToString("dd.MM.yyyy HH:mm:ss") ?? "";
                row3++;
            }
            Sheet3.Cells["A:AZ"].AutoFitColumns();
            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment: filename=" + "Report.xlsx");
            Response.BinaryWrite(Ep.GetAsByteArray());
            Response.End();
        }
        // GET: Urun

        public ActionResult Index()
        {
            List <UrunViewModel> mymodel    = new List <UrunViewModel>();
            UrunServisClient     urunServis = new UrunServisClient();
            //// Bütün kategorileri çekmek için

            //List<Kategori> kategoriler = urunServis.SelectKategori("mNRsaGrsdpmrkpKeqqJfQbP0RM", 0, "tr");
            //foreach (var kategori in kategoriler)
            //{
            //    Console.WriteLine("Kategori Adı: " + kategori.Tanim);
            //}
            //// Tek bir kategoriyi çekmek için
            //List<Kategori> tekKategori = urunServis.SelectKategori("mNRsaGrsdpmrkpKeqqJfQbP0RM", 53, "tr");
            //Console.WriteLine("Kategori Adı: " + tekKategori[0].Tanim);
            // Filtre değerleri:
            // -1 : Filtre yok
            // 0 : false
            // 1 : true
            // Bu değerler 'Aktif','Firsat','indirimli' ve 'Vitrin' için geçerlidi

            UrunFiltre urunFiltre = new UrunFiltre {
                Aktif  = -1,
                Firsat = -1,

                Indirimli   = -1,
                Vitrin      = -1,
                KategoriID  = 0, // 0 gönderilirse filtre yapılmaz.
                MarkaID     = 0, // 0 gönderilirse filtre yapılmaz.
                UrunKartiID = 0, //0 gönderilirse filtre yapılmaz.
                //Barkod="1564654812", //barkod girilirse sadece o barkodlu ürün gelir.
                //ToplamStokAdediBas = 0,
                //ToplamStokAdediSon = 5000,
                TedarikciID = 0, // 0 gönderilirse filtre yapılmaz
            };
            UrunSayfalama urunSayfalama = new UrunSayfalama {
                BaslangicIndex = 0,     // Başlangıç değeri
                KayitSayisi    = 100,   // Bir sayfada görüntülenecek ürün sayısı
                SiralamaDegeri = "ID",  // Hangi sütuna göre sıralanacağı
                SiralamaYonu   = "ASC", // Artan "ASC", azalan "DESC"
            };

            List <UrunKarti> FiltrelenenUrunKartiListe = urunServis.SelectUrun("mNRsaGrsdpmrkpKeqqJfQbP0RM", urunFiltre, urunSayfalama);

            foreach (var item in FiltrelenenUrunKartiListe)
            {
                List <Varyasyon> varyasyonListe = item.Varyasyonlar;
                foreach (var itemVar in varyasyonListe)
                {
                    UrunViewModel urunListItem = new UrunViewModel();
                    urunListItem.ID        = item.ID;
                    urunListItem.StokKodu  = itemVar.StokKodu;
                    urunListItem.Kategori  = item.AnaKategori;
                    urunListItem.Marka     = item.Marka;
                    urunListItem.StokAdedi = itemVar.StokAdedi;
                    urunListItem.UrunAdi   = item.UrunAdi;

                    urunListItem.Fiyat  = itemVar.SatisFiyati;
                    urunListItem.varID  = itemVar.ID;
                    urunListItem.varAdi = itemVar.Ozellikler[0].Deger;
                    mymodel.Add(urunListItem);
                }
            }

            return(View(mymodel));
        }
Exemple #20
0
 public ActionResult Yukle(UrunViewModel model, List <HttpPostedFileBase> file)
 {
     if (model.takasdegeri == "0")
     {
         model.Takas = false;
     }
     if (model.takasdegeri == "1")
     {
         model.Takas = true;
     }
     if (model.durumdegeri == "0")
     {
         model.durumu = false;
     }
     if (model.durumdegeri == "1")
     {
         model.durumu = true;
     }
     if (ModelState.IsValid && file.Count > 0)
     {
         UrunYonetici uy       = new UrunYonetici();
         var          filename = ImageNameGenerator.UrunFotoIsmiUret(file[0]);
         //filename += Path.GetExtension(file[0].FileName);
         model.Fotograf = filename;
         var path = "null";
         BusinessLayerResult <Urun> res = new BusinessLayerResult <Urun>();
         res = uy.UrunKayit(model, file[0]);
         if (file[0] != null)
         {
             //filename = Path.GetFileName(file[0].FileName);
             path = Path.Combine(Server.MapPath("~/Content/Image/Urun"), filename);
             Image imgnew = ResizeImage.Resize(Image.FromStream(file[0].InputStream), 0, 473); //son eklediğim alan
             //file[0].SaveAs(path);
             imgnew.Save(path);
         }
         if (res.Errors.Count > 0)
         {
             res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
             return(View(model));
         }
         if (file != null && file.Count > 1)
         {
             for (int i = 1; i <= file.Count - 1; i++)
             {
                 if (file != null && file[i].ContentLength > 0)
                 {
                     filename = ImageNameGenerator.UrunFotoIsmiUret(file[i]);
                     //filename = Path.GetFileName(file[i].FileName);
                     model.Fotograf = filename;
                     path           = Path.Combine(Server.MapPath("~/Content/Image/Urun"), filename);
                     UrunYonetici uy1 = new UrunYonetici();
                     BusinessLayerResult <UrunFoto> res1 = uy1.UrunFotosuYukle(model.UrunBaslik, file[i]);
                     Image imgnew = ResizeImage.Resize(Image.FromStream(file[i].InputStream), 0, 473); //son eklediğim alan
                     imgnew.Save(path);
                 }
             }
         }
         Session["urun"] = res.Result;
         return(RedirectToAction("Index", "Home"));
     }
     return(View(model));
     //return RedirectToAction("Index","Home");
 }
        public void StokDurumu()
        {
            StockControlEntities db = new StockControlEntities();
            var model = new UrunViewModel();

            model.girenUrun = db.GirenUrun.Where(x => x.Status).ToList();
            model.cikanUrun = db.CikanUrun.Where(x => x.Status).ToList();
            string constr = ConfigurationManager.AppSettings["connectionString"];
            var    Client = new MongoClient(constr);

            ExcelPackage   Ep    = new ExcelPackage();
            ExcelWorksheet Sheet = Ep.Workbook.Worksheets.Add("Report");

            Sheet.Cells["A1"].Value = "MAL GRUBU";
            Sheet.Cells["B1"].Value = "DEPO YERİ";
            Sheet.Cells["C1"].Value = "ADET";
            int row             = 2;
            var girenUrunToplam = model.girenUrun
                                  .GroupBy(x => new { x.Depo.Yer, x.Material.MaterialName })
                                  .Select(g => new
            {
                g.Key.MaterialName,
                g.Key.Yer,
                total = g.Sum(t => t.Adet)
            });

            var cikanUrunToplam = model.cikanUrun
                                  .GroupBy(x => new { x.Depo.Yer, x.Material.MaterialName })
                                  .Select(g => new
            {
                g.Key.MaterialName,
                g.Key.Yer,
                total = g.Sum(t => t.Adet)
            });

            foreach (var inProduct in girenUrunToplam)
            {
                var outProduct = cikanUrunToplam.Where(p => p.MaterialName == inProduct.MaterialName && p.Yer == inProduct.Yer).FirstOrDefault();
                if (outProduct == null)
                {
                    Sheet.Cells[string.Format("A{0}", row)].Value = inProduct.MaterialName;
                    Sheet.Cells[string.Format("B{0}", row)].Value = inProduct.Yer;
                    Sheet.Cells[string.Format("C{0}", row)].Value = inProduct.total;
                }
                row++;
            }
            foreach (var inProduct2 in girenUrunToplam)
            {
                var outProduct2 = cikanUrunToplam.Where(p => p.MaterialName == inProduct2.MaterialName && p.Yer == inProduct2.Yer).FirstOrDefault();
                if (outProduct2 != null)
                {
                    Sheet.Cells[string.Format("A{0}", row)].Value = inProduct2.MaterialName;
                    Sheet.Cells[string.Format("B{0}", row)].Value = inProduct2.Yer;
                    Sheet.Cells[string.Format("C{0}", row)].Value = (inProduct2.total - outProduct2.total);
                }
                row++;
            }
            Sheet.Cells["A:AZ"].AutoFitColumns();
            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment: filename=" + "ReportS.xlsx");
            Response.BinaryWrite(Ep.GetAsByteArray());
            Response.End();
        }