private void btn_kaydet_Click(object sender, EventArgs e)
        {
            Kullanici k = new Kullanici();

            k.Ad             = txt_ad.Text;
            k.Soyad          = txt_soyad.Text;
            k.KullaniciAd    = txt_kullaniciad.Text;
            k.KullaniciSifre = txt_sifre.Text;


            if (db.TBLKullanici.Any(x => x.KullaniciAd == k.KullaniciAd))
            {
                MessageBox.Show("Girdiğiniz Kullanıcı Adı Kullanılmaktadır. Tekrar deneyin.");

                Temizle();
            }
            else
            {
                db.TBLKullanici.Add(k);
                db.SaveChanges();

                MessageBox.Show("Kayıt Oluşturuldu.");

                KullaniciListe();
                Temizle();
            }
        }
Exemple #2
0
        public IActionResult FaturaOlustur(FaturaModelView modelView)
        {
            db.musteris.Add(modelView.musteri);
            db.faturas.Add(modelView.fatura);
            db.SaveChanges();
            var musteriIdBulma = db.musteris.FirstOrDefault(x => x.ad == modelView.musteri.ad && x.soyad == modelView.musteri.soyad);
            var faturaIdBulma  = db.faturas.FirstOrDefault(x => x.faturaNo == modelView.fatura.faturaNo);

            for (int i = 0; i < 3; i++)
            {
                AlinanUrun alinanUrun = new AlinanUrun();
                alinanUrun.urunAdi           = modelView.alinanUruns[i].urunAdi;
                alinanUrun.musteri           = new Musteri();
                alinanUrun.musteri.musteriId = musteriIdBulma.musteriId;
                alinanUrun.fatura            = new Fatura();
                alinanUrun.fatura.faturaId   = faturaIdBulma.faturaId;
                alinanUrun.adet       = modelView.alinanUruns[i].adet;
                alinanUrun.birimFiyat = modelView.alinanUruns[i].birimFiyat;
                alinanUrun.toplam     = modelView.alinanUruns[i].toplam;
                db.alinanUruns.Add(alinanUrun);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult MyProfile(HttpPostedFileBase file, User model)
        {
            ProjeContext db = new ProjeContext();

            User user = db.User.Where(x => x.Username == HttpContext.User.Identity.Name).FirstOrDefault();



            user.Password = model.Password;


            if (file != null && file.ContentLength > 0)
            {
                var newFileName = Guid.NewGuid() + System.IO.Path.GetExtension(file.FileName);
                var serverPath  = Server.MapPath("/ProfilesPhotos");
                var path        = Path.Combine(serverPath, newFileName).Replace("\\", "/");
                file.SaveAs(path);
                var userProfilePhotoPath = $@"/ProfilesPhotos/{newFileName}";

                user.ProfilePhoto = userProfilePhotoPath;
            }

            db.SaveChanges();

            return(RedirectToAction("MyProfile"));
        }
        public ActionResult EditArticle(int?post_id, Post model, HttpPostedFileBase file)
        {
            if (post_id != 0)
            {
                ProjeContext db   = new ProjeContext();
                Post         post = db.Post.Where(x => x.PostId == post_id).FirstOrDefault();
                post.PostTitle  = model.PostTitle;
                post.PostText   = model.PostText;
                post.CategoryId = model.CategoryId;
                if (file != null && file.ContentLength > 0)
                {
                    var postPicturePath = Server.MapPath(post.PostImage);
                    if (System.IO.File.Exists(postPicturePath))
                    {
                        System.IO.File.Delete(postPicturePath);
                    }

                    var newFileName = Guid.NewGuid() + System.IO.Path.GetExtension(file.FileName);
                    var serverPath  = Server.MapPath("/PostsPhotos");
                    var path        = Path.Combine(serverPath, newFileName).Replace("\\", "/");
                    file.SaveAs(path);
                    var postPhotoPath = $@"/PostsPhotos/{newFileName}";
                    post.PostImage = postPhotoPath;
                }

                db.SaveChanges();
                return(RedirectToAction("ListArticles", "Home"));
            }
            return(View());
        }
        public ActionResult EditUsers(int?user_id, User model, HttpPostedFileBase file)
        {
            if (user_id != 0 && model != null)
            {
                ProjeContext db   = new ProjeContext();
                User         user = db.User.Where(x => x.UserId == user_id).FirstOrDefault();
                user.Username = model.Username;
                user.Password = model.Password;
                user.Role     = model.Role;
                if (file != null && file.ContentLength > 0)
                {
                    var profilePicturePath = Server.MapPath(user.ProfilePhoto);
                    if (System.IO.File.Exists(profilePicturePath))
                    {
                        System.IO.File.Delete(profilePicturePath);
                    }

                    var newFileName = Guid.NewGuid() + System.IO.Path.GetExtension(file.FileName);
                    var serverPath  = Server.MapPath("/ProfilesPhotos");
                    var path        = Path.Combine(serverPath, newFileName).Replace("\\", "/");
                    file.SaveAs(path);
                    var userProfilePhotoPath = $@"/ProfilesPhotos/{newFileName}";
                    user.ProfilePhoto = userProfilePhotoPath;
                }
                db.SaveChanges();
                return(RedirectToAction("ListUsers", "Home"));
            }

            return(RedirectToAction("NotFound", "Error"));
        }
        public ActionResult Register(User user, HttpPostedFileBase file)
        {
            ProjeContext db = new ProjeContext();

            Setting setting = db.Settings.Where(x => x.Id == 1).FirstOrDefault();

            var role = setting.NewUserDefaultRole;

            User rs = db.User.Where(x => x.Username.Contains(user.Username)).FirstOrDefault();

            if (rs == null)
            {
                if (file != null && file.ContentLength > 0)
                {
                    var newFileName = Guid.NewGuid() + System.IO.Path.GetExtension(file.FileName);
                    var serverPath  = Server.MapPath("/ProfilesPhotos");
                    var path        = Path.Combine(serverPath, newFileName).Replace("\\", "/");
                    file.SaveAs(path);
                    var userProfilePhotoPath = $@"/ProfilesPhotos/{newFileName}";
                    user.ProfilePhoto = userProfilePhotoPath;
                }
                user.Role = role;
                db.User.Add(user);
                db.SaveChanges();
                FormsAuthentication.SetAuthCookie(user.Username, false);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Result = "Bu kullanıcı adı daha önceden alınmış!";
                return(View());
            }
        }
        public ActionResult Login(User user)
        {
            ProjeContext db = new ProjeContext();
            var          u  = db.User.FirstOrDefault(x => x.Username == user.Username && x.Password == user.Password);

            if (u != null)
            {
                FormsAuthentication.SetAuthCookie(u.Username, true);
                u.IsActive = true;
                db.SaveChanges();
                if (u.Role == "Admin")
                {
                    return(RedirectToAction("Panel", "Home"));
                }
                else if (u.Role == "Company")
                {
                    return(RedirectToAction("CompanyPanel", "Home"));
                }

                else if (string.IsNullOrEmpty(u.Role))
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                ViewBag.LoginError = "Hatalı Kullanıcı Adı veya Şifre";
            }
            return(View());
        }
        public ActionResult AddMessage(UserMessage Model)
        {
            ProjeContext db = new ProjeContext();

            db.UserMessages.Add(Model);
            db.SaveChanges();
            return(RedirectToAction("ListMessages", "Home"));
        }
        public ActionResult DeleteMessage(int?messageId)
        {
            ProjeContext db      = new ProjeContext();
            Message      message = db.Messages.Where(x => x.Id == messageId).FirstOrDefault();

            db.Messages.Remove(message);
            db.SaveChanges();
            return(RedirectToAction("ListMessages"));
        }
Exemple #10
0
        public ActionResult EditAnnouncement(int announcement_id, Announcement model)
        {
            ProjeContext db           = new ProjeContext();
            Announcement announcement = db.Announcement.Where(x => x.AnnouncementId == announcement_id).FirstOrDefault();

            announcement.AnnouncementText = model.AnnouncementText;
            db.SaveChanges();
            return(RedirectToAction("ListsAnnouncement", "Home"));
        }
Exemple #11
0
        public ActionResult DeleteAnnouncementOK(int announcement_id)
        {
            ProjeContext db           = new ProjeContext();
            Announcement announcement = db.Announcement.Where(x => x.AnnouncementId == announcement_id).FirstOrDefault();

            db.Announcement.Remove(announcement);
            db.SaveChanges();
            return(RedirectToAction("ListsAnnouncement", "Home"));
        }
        //Ürün ekle sayfasının kapatınca giriş sayfasına dönüyor.
        private void btnUrunEkle_Click(object sender, EventArgs e)
        {
            // mainForm.Show();
            Product p = new Product();
            {
                p.Name            = txtUrunAdi.Text;
                p.Added_Date      = DateTime.Now;
                p.UnitPrice       = decimal.Parse(txtUrunFiyati.Text);
                p.UnitInStock     = short.Parse(txtStokMiktari.Text);
                p.QuantityPerUnit = txtBirimi.Text;
                p.CategoryID      = (int)cmbCategoryName.SelectedValue;
                p.isActive        = true;
                db.Products.Add(p);
                db.SaveChanges();

                FillDataGrid();
            }
        }
Exemple #13
0
        public ActionResult CommentAdd(Comment model, string User)
        {
            ProjeContext db = new ProjeContext();

            model.PublishDate = DateTime.Now;
            model.Username    = User;
            db.Comment.Add(model);
            db.SaveChanges();
            return(RedirectToAction("ListComments", "Home"));
        }
Exemple #14
0
        public ActionResult Logout()
        {
            ProjeContext db           = new ProjeContext();
            var          current_user = db.User.Where(x => x.Username.Contains(HttpContext.User.Identity.Name)).FirstOrDefault();

            current_user.IsActive = false;
            db.SaveChanges();
            FormsAuthentication.SignOut();
            return(RedirectToAction("Login"));
        }
Exemple #15
0
        private void btn_kaydet_Click(object sender, EventArgs e)
        {
            List <Kitap> kitaps = db.TBLKitap.Where(x => x.KitapAdi == txt_adi.Text && x.Yazar == txt_yazar.Text && x.BasımTarihi == dtp_basimtarihi.Value && x.BaskiNo == txt_baskino.Text && x.YayinEvi == txt_yayin.Text).ToList();

            if (kitaps.Count > 0)
            {
                foreach (Kitap item in kitaps)
                {
                    int stkkontrol = Convert.ToInt32(item.Stok) + 1;
                    Updated = db.TBLKitap.Find(item.ID);

                    Updated.KitapAdi    = txt_adi.Text;
                    Updated.Yazar       = txt_yazar.Text;
                    Updated.Tur         = (string)cb_tur.SelectedItem;
                    Updated.BasımTarihi = dtp_basimtarihi.Value.Date;
                    Updated.BaskiNo     = txt_baskino.Text;
                    Updated.YayinEvi    = txt_yayin.Text;
                    Updated.Stok        = stkkontrol;
                    Updated.Ucret       = Convert.ToDouble(txt_ucret.Text);

                    db.Entry(db.TBLKitap.Find(Updated.ID)).CurrentValues.SetValues(Updated);
                    db.SaveChanges();
                }
            }
            else
            {
                Kitap k = new Kitap();
                k.KitapAdi    = txt_adi.Text;
                k.Yazar       = txt_yazar.Text;
                k.Tur         = (string)cb_tur.SelectedItem;
                k.BasımTarihi = dtp_basimtarihi.Value.Date;
                k.BaskiNo     = txt_baskino.Text;
                k.YayinEvi    = txt_yayin.Text;
                k.Stok        = 1;
                k.Ucret       = Convert.ToInt64(txt_ucret.Text);
                db.TBLKitap.Add(k);
                db.SaveChanges();
            }

            Temizle();
            KitapListele();
        }
Exemple #16
0
 public ActionResult CreateCategory(Category category)
 {
     if (category != null)
     {
         ProjeContext db = new ProjeContext();
         db.Category.Add(category);
         db.SaveChanges();
         return(RedirectToAction("ListCategories", "Home"));
     }
     return(RedirectToAction("NotFound", "Error"));
 }
Exemple #17
0
 public ActionResult AnnouncementAdd(Announcement model)
 {
     if (model != null)
     {
         ProjeContext db = new ProjeContext();
         db.Announcement.Add(model);
         db.SaveChanges();
         return(RedirectToAction("ListsAnnouncement", "Home"));
     }
     return(View());
 }
Exemple #18
0
        public ActionResult MyProfileDeleteMessage(int?messageId)
        {
            ProjeContext db          = new ProjeContext();
            UserMessage  userMessage = db.UserMessages.Where(x => x.Id == messageId).FirstOrDefault();

            db.UserMessages.Remove(userMessage);
            db.SaveChanges();
            var data = db.User.Where(x => x.UserId == userMessage.UserId).FirstOrDefault();
            int?id   = data.UserId;

            return(RedirectToAction("MyProfileListMessages", new { id }));
        }
Exemple #19
0
 public ActionResult EditCategory(int?category_id, Category model)
 {
     if (category_id != 0 && model != null)
     {
         ProjeContext db       = new ProjeContext();
         Category     category = db.Category.Where(x => x.CategoryId == category_id).FirstOrDefault();
         category.CategoryName = model.CategoryName;
         db.SaveChanges();
         return(RedirectToAction("ListCategories", "Home"));
     }
     return(View());
 }
Exemple #20
0
 public ActionResult DeleteCategoryOK(int?category_id)
 {
     if (category_id != 0)
     {
         ProjeContext db       = new ProjeContext();
         Category     category = db.Category.Where(x => x.CategoryId == category_id).FirstOrDefault();
         db.Category.Remove(category);
         db.SaveChanges();
         return(RedirectToAction("ListCategories", "Home"));
     }
     return(View());
 }
Exemple #21
0
        public ActionResult ReadMore(int?post_id)
        {
            ProjeContext db   = new ProjeContext();
            Post         post = db.Post.Where(x => x.PostId == post_id).FirstOrDefault();

            post.TotalViews = post.TotalViews + 1;
            List <Comment> ct = db.Comment.Where(x => x.PostId == post_id).ToList();

            post.Comments = ct;
            db.SaveChanges();
            return(View(post));
        }
Exemple #22
0
 public ActionResult EditComment(int?commentId, Comment model)
 {
     if (commentId != null)
     {
         ProjeContext db      = new ProjeContext();
         Comment      comment = db.Comment.Where(x => x.CommentId == commentId).FirstOrDefault();
         comment.CommentText = model.CommentText;
         comment.PublishDate = DateTime.Now;
         db.SaveChanges();
         return(RedirectToAction("ListComments"));
     }
     return(RedirectToAction("NotFound"));
 }
Exemple #23
0
        private void btn_kiralamakaydet_Click(object sender, EventArgs e)
        {
            kiralanan.KitapId = (int)cb_kitap.SelectedValue;

            List <Kitap> kontrol = db.TBLKitap.Where(x => x.ID == kiralanan.KitapId).ToList();

            foreach (Kitap item in kontrol)
            {
                item.Stok = item.Stok - 1;
            }

            Ogrenci o = new Ogrenci();

            o.Tc = txt_kiralamatc.Text;


            List <Ogrenci> k = db.TBLOgrenci.Where(x => x.Tc == o.Tc).ToList();

            foreach (Ogrenci item in k)
            {
                kiralanan.OgrenciId = item.ID;
            }



            kiralanan.AlisTarihi    = dtp_alistarihi.Value;
            kiralanan.TeslimTarihi  = dtp_teslimtarihi.Value;
            kiralanan.VerilisTarihi = DateTime.Now;

            kiralanan.AktifMi = true;

            db.TBLKiralama.Add(kiralanan);
            db.SaveChanges();

            MessageBox.Show("Kayıt oluşturuldu.");

            KiraTemizle();
        }
Exemple #24
0
        private void btn_teslimal_Click(object sender, EventArgs e)
        {
            List <Kitap> kontrol = db.TBLKitap.Where(x => x.ID == teslim.KitapId).ToList();

            foreach (Kitap item in kontrol)
            {
                item.Stok = item.Stok + 1;
            }

            teslim.AktifMi = false;

            MessageBox.Show("Teslim Alındı.");

            db.SaveChanges();
            Listele();
        }
Exemple #25
0
        public ActionResult ReadMore(string txtTextArea, int post_id, string returnUrl)
        {
            if (!string.IsNullOrEmpty(txtTextArea))
            {
                ProjeContext db      = new ProjeContext();
                Comment      comment = new Comment();
                comment.CommentText = txtTextArea.ToString();
                comment.Username    = HttpContext.User.Identity.Name;
                comment.PostId      = post_id;
                comment.PublishDate = DateTime.Now;
                db.Comment.Add(comment);
                db.SaveChanges();
                return(Redirect(returnUrl));
            }

            return(View());
        }
Exemple #26
0
        public ActionResult Index(string cpname, string cpemail, string cpphone, string cpmessage)
        {
            ProjeContext db      = new ProjeContext();
            Message      message = new Message()
            {
                Name    = cpname,
                Email   = cpemail,
                Phone   = cpphone,
                Content = cpmessage
            };

            db.Messages.Add(message);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #27
0
 public ActionResult DeleteArticleOK(int?post_id)
 {
     if (post_id != 0)
     {
         ProjeContext db              = new ProjeContext();
         Post         post            = db.Post.Where(x => x.PostId == post_id).FirstOrDefault();
         var          postPicturePath = Server.MapPath(post.PostImage);
         if (System.IO.File.Exists(postPicturePath))
         {
             System.IO.File.Delete(postPicturePath);
         }
         db.Post.Remove(post);
         db.SaveChanges();
         return(RedirectToAction("ListArticles", "Home"));
     }
     return(View());
 }
        //Sign Up
        private void btnInsert_Click(object sender, EventArgs e)
        {
            AppUser user = new AppUser();

            user.Name       = txtName.Text;
            user.Lastname   = txtLastname.Text;
            user.UserName   = (txtName.Text + txtLastname.Text).ToLower();
            user.Password   = (txtName.Text + txtLastname.Text).ToLower();
            user.Birth_Date = dtPckrBirthDate.Value;
            user.Gender     = Convert.ToString(cmbGender.SelectedItem);
            user.Added_Date = DateTime.Now;
            user.isActive   = true;

            db.Users.Add(user);
            db.SaveChanges();
            MessageBox.Show("Kayıt başarılı.");
            MessageBox.Show("UserName :  "******" ve Password: " + user.Password);
        }
Exemple #29
0
        public ActionResult Setting(Setting Model)
        {
            ProjeContext db = new ProjeContext();

            Setting setting = db.Settings.Where(x => x.Id == 1).FirstOrDefault();

            setting.SiteTitle = Model.SiteTitle;

            setting.TagLine = Model.TagLine;

            setting.AnyoneCanRegister = Model.AnyoneCanRegister;

            setting.NewUserDefaultRole = Model.NewUserDefaultRole;

            db.SaveChanges();

            return(RedirectToAction("Setting", "Home"));
        }
Exemple #30
0
        public ActionResult DeleteUserOK(int?user_id)
        {
            if (user_id != 0)
            {
                ProjeContext db   = new ProjeContext();
                User         user = db.User.Where(x => x.UserId == user_id).FirstOrDefault();
                var          profilePicturePath = Server.MapPath(user.ProfilePhoto);
                if (System.IO.File.Exists(profilePicturePath))
                {
                    System.IO.File.Delete(profilePicturePath);
                }
                db.User.Remove(user);
                db.SaveChanges();
                return(RedirectToAction("ListUsers", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }