Example #1
0
        public void FillGrid()
        {
            List <ELBasket> basket = BLLBasket.GetBasket();

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB BASKET PULLED");
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("Ürün");
            dt.Columns.Add("Miktar");
            dt.Columns.Add("Fiyat");
            dt.Columns.Add("Numara");
            if (basket != null)
            {
                noteID.Visible            = true;
                TextBoxNoteID.Visible     = true;
                payementType.Visible      = true;
                acceptButtonImage.Visible = true;
                welc.Text    = "Hoşgeldin " + name + " !  Sepetin tam burada !!";
                welc.Visible = true;
                foreach (ELBasket item in basket)
                {
                    DataRow  dr  = dt.NewRow();
                    EProduct pro = (EProduct)BLLProduct.SelectProduct(item.productId);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCT DATA SELECTED");
                    }
                    dr["Ürün"]   = pro.ProductName;
                    dr["Miktar"] = item.productCount;
                    dr["Fiyat"]  = item.productCount * pro.Price;
                    dr["Numara"] = item.id;
                    dt.Rows.Add(dr);
                }
                BasketGrid.DataSource = dt;
                BasketGrid.DataBind();
            }
            else
            {
                welc.Text                 = "Sepetin şu an boş";
                welc.Visible              = true;
                noteID.Visible            = false;
                TextBoxNoteID.Visible     = false;
                payementType.Visible      = false;
                acceptButtonImage.Visible = false;
                BasketGrid.DataSource     = dt;
                BasketGrid.DataBind();
            }
        }
Example #2
0
        protected void BasketGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow row     = (GridViewRow)BasketGrid.Rows[e.RowIndex];
            string      tempkey = row.Cells[4].Text.ToString();
            int         key     = Convert.ToInt32(tempkey);

            BLLBasket.DeleteBasket(key);
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB BASKET DATA DELETED");
            }
            FillGrid();
        }
Example #3
0
        protected void acceptButtonImage_Click(object sender, ImageClickEventArgs e)
        {
            string  productsName = "";
            decimal totalPrice   = 0;
            string  note;
            bool    type     = true;
            int     ClientId = 0;

            for (int i = 0; i < BasketGrid.Rows.Count; i++)
            {
                GridViewRow row = (GridViewRow)BasketGrid.Rows[i];
                productsName += row.Cells[1].Text.ToString() + ",";
                totalPrice   += Convert.ToDecimal(row.Cells[3].Text);
            }
            note = TextBoxNoteID.Text.ToString();
            if (payementType.SelectedValue.ToString() == "kredi")
            {
                type = false;
            }
            else
            {
                type = true;
            }
            EClient usr = (EClient)Session["user"];

            ClientId = usr.id;

            BLLPurchase.CreatePurchase(totalPrice, productsName, note, type, ClientId);
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB PURCHASE CREATED");
            }

            for (int i = 0; i < BasketGrid.Rows.Count; i++)
            {
                GridViewRow row     = (GridViewRow)BasketGrid.Rows[i];
                string      tempkey = row.Cells[4].Text.ToString();
                int         key     = Convert.ToInt32(tempkey);
                BLLBasket.DeleteBasket(key);
                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(submittedFilePath, true))
                {
                    file.WriteLine("[" + DateTime.Now + "] DB BASKET DELETED");
                }
            }
            FillGrid();
            Response.Redirect("~/Purchase.aspx");
        }
 protected void GoButton_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 4; i++)
     {
         if (i == 0)
         {
             for (int j = 0; j < ProductGrid.Rows.Count; j++)
             {
                 GridViewRow row   = ProductGrid.Rows[j];
                 int         count = Convert.ToInt32(((TextBox)row.FindControl("TextBoxOrderCount")).Text.ToString());
                 if (count > 0)
                 {
                     EClient usr     = (EClient)Session["user"];
                     int     client  = usr.id;
                     int     product = Convert.ToInt32(((Label)row.FindControl("Label1")).Text.ToString());
                     BLLBasket.AddItem(client, product, count);
                     using (System.IO.StreamWriter file =
                                new System.IO.StreamWriter(submittedFilePath, true))
                     {
                         file.WriteLine("[" + DateTime.Now + "] DB BASKET DATA INSERTED");
                     }
                     feedback.Text    = "Ürününüz Sepete başarıyla eklendi !!!";
                     feedback.Visible = true;
                     ((TextBox)row.FindControl("TextBoxOrderCount")).Text = "0";
                 }
             }
         }
         else if (i == 1)
         {
             for (int j = 0; j < aperatifGrid.Rows.Count; j++)
             {
                 GridViewRow row   = aperatifGrid.Rows[j];
                 int         count = Convert.ToInt32(((TextBox)row.FindControl("aperatifCount")).Text.ToString());
                 if (count > 0)
                 {
                     EClient usr     = (EClient)Session["user"];
                     int     client  = usr.id;
                     int     product = Convert.ToInt32(((Label)row.FindControl("Label2")).Text.ToString());
                     BLLBasket.AddItem(client, product, count);
                     using (System.IO.StreamWriter file =
                                new System.IO.StreamWriter(submittedFilePath, true))
                     {
                         file.WriteLine("[" + DateTime.Now + "] DB BASKET DATA INSERTED");
                     }
                     feedback.Text    = "Ürününüz Sepete başarıyla eklendi !!!";
                     feedback.Visible = true;
                     ((TextBox)row.FindControl("aperatifCount")).Text = "0";
                 }
             }
         }
         else if (i == 2)
         {
             for (int j = 0; j < IcecekGrid.Rows.Count; j++)
             {
                 GridViewRow row   = IcecekGrid.Rows[j];
                 int         count = Convert.ToInt32(((TextBox)row.FindControl("IcecekCount")).Text.ToString());
                 if (count > 0)
                 {
                     EClient usr     = (EClient)Session["user"];
                     int     client  = usr.id;
                     int     product = Convert.ToInt32(((Label)row.FindControl("Label6")).Text.ToString());
                     BLLBasket.AddItem(client, product, count);
                     using (System.IO.StreamWriter file =
                                new System.IO.StreamWriter(submittedFilePath, true))
                     {
                         file.WriteLine("[" + DateTime.Now + "] DB BASKET DATA INSERTED");
                     }
                     feedback.Text    = "Ürününüz Sepete başarıyla eklendi !!!";
                     feedback.Visible = true;
                     ((TextBox)row.FindControl("IcecekCount")).Text = "0";
                 }
             }
         }
         else if (i == 3)
         {
             for (int j = 0; j < tatlıGrid.Rows.Count; j++)
             {
                 GridViewRow row   = tatlıGrid.Rows[j];
                 int         count = Convert.ToInt32(((TextBox)row.FindControl("tatlıCount")).Text.ToString());
                 if (count > 0)
                 {
                     EClient usr     = (EClient)Session["user"];
                     int     client  = usr.id;
                     int     product = Convert.ToInt32(((Label)row.FindControl("Label10")).Text.ToString());
                     BLLBasket.AddItem(client, product, count);
                     using (System.IO.StreamWriter file =
                                new System.IO.StreamWriter(submittedFilePath, true))
                     {
                         file.WriteLine("[" + DateTime.Now + "] DB BASKET DATA INSERTED");
                     }
                     feedback.Text    = "Ürününüz Sepete başarıyla eklendi !!!";
                     feedback.Visible = true;
                     ((TextBox)row.FindControl("tatlıCount")).Text = "0";
                 }
             }
         }
     }
 }