protected void rptSupplier_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "sil") { Product p = new Product(); int id = Convert.ToInt32(e.CommandArgument); p = GgDbProvider.Product.FirstOrDefault(i => i.Deleted == false && i.ObjectID == id); p.Deleted = true; GgDbProvider.SaveChanges(); } Response.Redirect("ShopLayout.aspx"); }
protected void Unnamed_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"]); Product p = new Product(); p = GgDbProvider.Product.FirstOrDefault(i => i.ObjectID == id); p.ProductName = txtProductName.Text.Trim(); p.Quantity = Convert.ToInt32(txtQuantity.Text.Trim()); p.Price = Convert.ToDecimal(txtQuantity.Text.Trim()); p.CategoryID = Convert.ToInt32(ddlCategory.SelectedValue); GgDbProvider.SaveChanges(); Response.Redirect("ShopLayout.aspx"); }
protected void rptComments_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Onayla") { int id = Convert.ToInt32(e.CommandArgument); Comment c = GgDbProvider.Comment.FirstOrDefault(i => i.Deleted != true && i.ObjectId == id); if (c != default(Comment)) { c.ApprovedDate = DateTime.Now; if (Session["Oturum"] != null) { User result = Session["Oturum"] as User; if (result != default(User) && result.RoleID == 1) { c.ApproverID = result.ObjectID; } else { Response.Redirect("Yetkisiz.aspx"); } } else { Response.Redirect("Login.aspx"); } c.IsApproved = true; GgDbProvider.SaveChanges(); rptComments.DataSource = GgDbProvider.Comment.Where(a => a.Deleted != true && a.IsApproved == false).OrderBy(i => i.CommentDate); rptComments.DataBind(); } } else if (e.CommandName == "Sil") { int id = Convert.ToInt32(e.CommandArgument); Comment c = GgDbProvider.Comment.FirstOrDefault(i => i.Deleted != true && i.ObjectId == id); if (c != default(Comment)) { c.Deleted = true; GgDbProvider.SaveChanges(); rptComments.DataSource = GgDbProvider.Comment.Where(a => a.Deleted != true && a.IsApproved == false).OrderBy(i => i.CommentDate); rptComments.DataBind(); } } }
protected void rptSiparislerim_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "iptal") { int id = Convert.ToInt32(e.CommandArgument); Order o = GgDbProvider.GetOrderByObjectId(id); if (o != default(Order)) { o.StatusId = 6; } o.LastOperationDate = DateTime.Now; } if (e.CommandName == "onay") { int id = Convert.ToInt32(e.CommandArgument); Order o = GgDbProvider.GetOrderByObjectId(id); if (o != default(Order)) { o.StatusId = 3; } o.LastOperationDate = DateTime.Now; } GgDbProvider.SaveChanges(); if (Session["Oturum"] != null) { User currentUser = Session["Oturum"] as User; if (currentUser != default(User)) { rptSiparislerim.DataSource = GgDbProvider.GetOrderByCustomerId(currentUser.ObjectID); rptSiparislerim.DataBind(); } } else { Session["URL"] = "gelensiparis"; Response.Redirect("Login.aspx"); } }
protected void btnOnayla_Click(object sender, EventArgs e) { int paymentTypeId = 0; List <GgDB.Product> urunler = new List <GgDB.Product>(); urunler = Session["urunler"] as List <GgDB.Product>; GgDB.Product p = new GgDB.Product(); string fiyat; string kilo; string ad; int i = 0; string body = txtAdres.Text.Trim(); body += " adresine istenilen sipariş şu şekildedir: \n \n"; while (i < urunler.Count) { p = urunler[i]; ad = p.ProductName; fiyat = p.Price.ToString(); kilo = p.Quantity.ToString(); body += " " + ad + " ürününden "; body += kilo + " kg "; body += "(" + fiyat + " TL" + "),\n"; ++i; } body += "\nEkli Notlar: " + txtNot.Text; body += "\nOrganic Online ekibi bol kazançlar diler."; string manavMail; manavMail = p.Supplier.User.E_mail; if (rb1.Checked) { paymentTypeId = 1; } if (rb2.Checked) { paymentTypeId = 2; } else if (rb3.Checked) { paymentTypeId = 3; } else { pBilgi.Visible = true; pBilgi.InnerText = "Lütfen ödeme tipini belirtiniz."; return; } //try //{ OrderCode code = new OrderCode(); GgDbProvider.AddToOrderCode(code); GgDbProvider.SaveChanges(); User customer = Session["Oturum"] as User; if (customer == default(User)) { Response.Redirect("Login.aspx"); } foreach (Product item in urunler) { GgDbProvider.AddOrder(customer.ObjectID, item.ObjectID, 1, paymentTypeId, item.Quantity, txtAdres.Text.Trim(), txtNot.Text.Trim(), code.ObjectId); } GgDbProvider.SaveChanges(); MailMessage mail = new MailMessage("*****@*****.**", manavMail); SmtpClient client = new SmtpClient(); client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ggdb1234"); client.Host = "smtp.gmail.com"; mail.Subject = "Ürün Siparişi"; mail.Body = body; client.Send(mail); txtAdres.Text = ""; txtNot.Text = ""; Session.Remove("Urunler"); Session.Remove("urunler"); Session.Remove("ToplamFiyat"); pBilgi.Visible = true; pBilgi.InnerText = code.ObjectId + " numaralı siparişiniz başarıyla gönderilmiştir. En yakın sürede adresinize ulaşacaktır."; rptUrunler.Visible = false; txtNot.Visible = false; txtAdres.Visible = false; btnOnayla.Visible = false; pnlPaymnet.Visible = false; //} //catch //{ // Response.Write("<script>alert('Sipariş gönderilirken bir hata oldu lütfen bir daha deneyiniz.');</script>"); // UrunleriGetir(urunler); //} }