Beispiel #1
0
        public async Task <IHttpActionResult> Putpromotion(int id, promotion promotion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != promotion.id)
            {
                return(BadRequest());
            }

            db.Entry(promotion).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!promotionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        private void studentToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            this.Hide();
            promotion pr = new promotion(this);

            pr.Show();
        }
 public ActionResult Edit(promotion promotion, HttpPostedFileBase[] files, String[] usertypes, string value)
 {
     if (ModelState.IsValid)
     {
         if (files != null)
         {
             for (int i = 0; i < files.Length; i++)
             {
                 if (files[i] != null)
                 {
                     string path = "";
                     path = Path.Combine(Server.MapPath("/Content/ProductImage"),
                                         Path.GetFileName(files[i].FileName));
                     var picId = db.artlinks.OrderByDescending(x => x.LINENO).FirstOrDefault();
                     files[i].SaveAs(path);
                 }
             }
         }
         promotion.TYPEUSERS       = String.Join(",", usertypes);
         promotion.LASTCHANGE      = DateTime.Now;
         db.Entry(promotion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(promotion));
 }
Beispiel #4
0
        public ActionResult Edit(int id, promotion p)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }

            promotion p1 = new promotion();

            p1             = prom.GetById(id);
            p1.dateDebut   = p.dateDebut;
            p1.dateFin     = p.dateFin;
            p1.description = p.description;
            prom.Update(p1);
            prom.Commit();
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     discount        = 0;
     promo           = null;
     labeldisc2.Text = " ";
     labelDisc.Text  = "0";
     txtPromo.Text   = "";
 }
Beispiel #6
0
        private void txtPromo_TextChanged(object sender, EventArgs e)
        {
            var sekarang = DateTime.Now;
            var exist    = db.promotions
                           .FirstOrDefault(x => x.code == txtPromo.Text && x.start_time <sekarang && x.end_time> sekarang);

            if (exist != null)
            {
                decimal minimum      = exist.minimum_spent;
                int     minimumspend = Convert.ToInt32(minimum);
                if (Convert.ToInt32(labelSubtotal.Text) > minimumspend)
                {
                    promo = exist;
                    decimal disc   = exist.discount;
                    int     diskon = Convert.ToInt32(disc);
                    discount = diskon;
                    int hargasetelah = Convert.ToInt32(labelSubtotal.Text) * discount / 100;
                    labelDisc.Text  = hargasetelah.ToString();
                    labeldisc2.Text = "(" + discount.ToString() + "%)";
                    int subtotal = Convert.ToInt32(labelSubtotal.Text);

                    int pajak  = subtotal * 10 / 100;
                    int charge = subtotal * 5 / 100;
                    labelTax.Text     = pajak.ToString();
                    labelService.Text = charge.ToString();


                    int total = (subtotal - hargasetelah) + pajak + charge;
                    labelTotal.Text = total.ToString();
                }
                else
                {
                    promo           = null;
                    discount        = 0;
                    labeldisc2.Text = " ";
                    labelDisc.Text  = "0";
                    MessageBox.Show("Cannot use your code because its have minimum spend.", "Project", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPromo.Text = "";
                }
            }
            else
            {
                promo           = null;
                discount        = 0;
                labeldisc2.Text = " ";
                labelDisc.Text  = "0";
                int hargasetelah = Convert.ToInt32(labelSubtotal.Text);
                labeldisc2.Text = "(" + discount.ToString() + "%)";
                int pajak  = hargasetelah * 10 / 100;
                int charge = pajak * 5 / 100;
                labelTax.Text     = pajak.ToString();
                labelService.Text = charge.ToString();
                int subtotal = Convert.ToInt32(labelSubtotal.Text);
                int total    = subtotal + pajak + charge;
                labelTotal.Text = total.ToString();
            }
        }
Beispiel #7
0
        public async Task <IHttpActionResult> Getpromotion(int id)
        {
            promotion promotion = await db.promotions.FindAsync(id);

            if (promotion == null)
            {
                return(NotFound());
            }

            return(Ok(promotion));
        }
        // GET: /Promotion/Delete/5
        public ActionResult Delete(int?id)
        {
            promotion Promotion = db.promotions.Find(id);

            if (Promotion != null)
            {
                Promotion.STATUS          = 0;
                db.Entry(Promotion).State = EntityState.Modified;
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult EditPromotion(int id)
 {
     if (Session["Admin"] != null)
     {
         promotion pro = ctx.promotions.First(x => x.Id.Equals(id));
         return(View(pro));
     }
     else
     {
         return(RedirectToAction("/Index"));
     }
 }
Beispiel #10
0
        public async Task <IHttpActionResult> Postpromotion(promotion promotion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.promotions.Add(promotion);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = promotion.id }, promotion));
        }
        // GET: /Promotion/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            promotion Promotion = db.promotions.Find(id);

            if (Promotion == null)
            {
                return(HttpNotFound());
            }
            return(View(Promotion));
        }
 public ActionResult DeletePromotion(int id)
 {
     if (Session["Admin"] != null)
     {
         promotion pro = ctx.promotions.First(x => x.Id.Equals(id));
         ctx.promotions.Remove(pro);
         ctx.SaveChanges();
         return(RedirectToAction("viewPromotion"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Beispiel #13
0
        public async Task <IHttpActionResult> Deletepromotion(int id)
        {
            promotion promotion = await db.promotions.FindAsync(id);

            if (promotion == null)
            {
                return(NotFound());
            }

            db.promotions.Remove(promotion);
            await db.SaveChangesAsync();

            return(Ok(promotion));
        }
 public ActionResult EditPromotioninDb(promotion Promotion)
 {
     if (Session["Admin"] != null)
     {
         promotion pro = ctx.promotions.FirstOrDefault(x => x.Id == Promotion.Id);
         pro.subject     = Promotion.subject;
         pro.description = Promotion.description;
         ctx.SaveChanges();
         return(RedirectToAction("viewPromotion"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Beispiel #15
0
        //-------------------------------------------------------------------

        /**
         * Supprime une promotion
         */
        public bool DeletePromotion(int promotion_id)
        {
            try
            {
                // Récupère la promotion
                promotion temp = entities.promotion.Where(x => x.promotion_id == promotion_id).FirstOrDefault();

                // Supprime la promotion
                entities.promotion.Remove(temp);

                // Sauvegarde la suppression
                entities.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public ActionResult SavePromotion(promotion a)
        {
            ctx.promotions.Add(a);
            try
            {
                ctx.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i];
                file.SaveAs(Server.MapPath(@"~\promotion_" + a.Id + ".jpg"));
                break;
            }
            return(RedirectToAction("/Index"));
        }
Beispiel #17
0
        public ActionResult Create(promotion pro)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            prom.Add(pro);
            prom.Commit();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(promotion promotion, HttpPostedFileBase[] files, String[] usertypes, string value)
        {
            ViewBag.Error = "";
            try
            {
                if (ModelState.IsValid)
                {
                    if (files != null)
                    {
                        for (int i = 0; i < files.Length; i++)
                        {
                            if (files[i] != null)
                            {
                                string path = "";
                                path = Path.Combine(Server.MapPath("/Content/ProductImage"), Path.GetFileName(files[i].FileName));
                                var picId = db.artlinks.OrderByDescending(x => x.LINENO).FirstOrDefault();
                                files[i].SaveAs(path);
                            }
                        }
                    }
                    //var proId = db.promotions.OrderByDescending(x => x.PROMOTIONNO).FirstOrDefault();
                    //if (proId != null)
                    //{
                    //    promotion.PROMOTIONNO = proId.PROMOTIONNO + 1;
                    //}
                    //else
                    //{
                    //    promotion.PROMOTIONNO = 1;
                    //}

                    promotion.TYPEUSERS  = String.Join(",", usertypes);
                    promotion.CREATED    = DateTime.Now;
                    promotion.LASTCHANGE = DateTime.Now;
                    db.promotions.Add(promotion);
                    db.SaveChanges();

                    if (promotion.QUANTITY != 0)
                    {
                        for (int i = 0; i < promotion.QUANTITY; i++)
                        {
                            var tblPro = new promotionrule
                            {
                                PROMOTIONCODE    = "KM" + Guid.NewGuid().ToString().Substring(0, 6).ToUpper(),
                                PROMOTIONNO      = promotion.PROMOTIONNO,
                                ELIGIBILITYNO    = 1,
                                TYPENO           = promotion.TYPENO,
                                ADJUSTMENTVALUE  = decimal.Parse(promotion.VALUEPROMOTION),
                                ADJUSTMENTTYPENO = 1,
                                CREATED          = DateTime.Now,
                                LASTCHANGE       = DateTime.Now,
                                PRICEGROUPNO     = 1
                            };
                            db.promotionrules.Add(tblPro);
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        /* var tblPro = new promotionrule
                         * {
                         *   PROMOTIONCODE = promotion.PROMOTIONCODE.ToUpper(),
                         *   PROMOTIONNO = promotion.PROMOTIONNO,
                         *   ELIGIBILITYNO = 1,
                         *   TYPENO = promotion.TYPENO,
                         *   ADJUSTMENTVALUE = decimal.Parse(promotion.VALUEPROMOTION),
                         *   ADJUSTMENTTYPENO = 1,
                         *   CREATED = DateTime.Now,
                         *   LASTCHANGE = DateTime.Now,
                         *   PRICEGROUPNO = 1
                         * };
                         * db.promotionrules.Add(tblPro);
                         *
                         * db.SaveChanges();*/
                    }
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(View(promotion));
        }
Beispiel #19
0
 public ActionResult Create(promotion promo)
 {
     promServ.AddPromotion(promo);
     return(RedirectToAction("Index"));
 }
Beispiel #20
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (txtPromo.Text == "")
            {
                discount = 0;
                int harga    = Convert.ToInt32(labelTotal.Text);
                var paypopup = new PaymentConfirmForm();
                paypopup.table    = tableoke.ToString();
                paypopup.customer = customeroke;
                paypopup.total    = harga;
                paypopup.ShowDialog();

                if (paypopup.submit == true)
                {
                    var databaru = new payment
                    {
                        header_order_id = data.id,
                        payment_type    = paypopup.paymenttype,
                        amount_to_pay   = harga,
                        amount_paid     = paypopup.pay
                    };
                    db.payments.Add(databaru);
                    db.SaveChanges();
                }
                LoadData();
                dgvDetail.DataSource = null;
                promo              = null;
                discount           = 0;
                txtPromo.Text      = "";
                labelSubtotal.Text = "0";
                labelTax.Text      = "0";
                labeldisc2.Text    = " ";
                labelDisc.Text     = "0";
                labelService.Text  = "0";
                labelTotal.Text    = "0";
            }
            else
            {
                var sekarang = DateTime.Now;
                var exist    = db.promotions
                               .FirstOrDefault(x => x.code == txtPromo.Text && x.start_time <sekarang && x.end_time> sekarang);
                if (exist != null)
                {
                    decimal minimum      = exist.minimum_spent;
                    int     minimumspend = Convert.ToInt32(minimum);
                    if (Convert.ToInt32(labelSubtotal.Text) > minimumspend)
                    {
                        int harga    = Convert.ToInt32(labelTotal.Text);
                        var paypopup = new PaymentConfirmForm();
                        paypopup.table    = tableoke.ToString();
                        paypopup.customer = customeroke;
                        paypopup.total    = harga;
                        paypopup.ShowDialog();

                        if (paypopup.submit == true)
                        {
                            var databaru = new payment
                            {
                                header_order_id = data.id,
                                promotion_id    = promo.id,
                                payment_type    = paypopup.paymenttype,
                                amount_to_pay   = harga,
                                amount_paid     = paypopup.pay
                            };
                            db.payments.Add(databaru);
                            db.SaveChanges();
                        }
                        LoadData();
                        dgvDetail.DataSource = null;
                        promo              = null;
                        discount           = 0;
                        txtPromo.Text      = "";
                        labelSubtotal.Text = "0";
                        labelTax.Text      = "0";
                        labeldisc2.Text    = " ";
                        labelDisc.Text     = "0";
                        labelService.Text  = "0";
                        labelTotal.Text    = "0";
                    }
                    else
                    {
                        MessageBox.Show("You cannot use the promo code because its have minimum spend", "Project", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("You cannot use the promo code because its expired", "Project", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
        }
Beispiel #21
0
        //--------------------------------------------------------------------

        /**
         * Créer une promotion dans la base de données
         */
        public promotion AddPromotion(promotion promo)
        {
            entities.promotion.Add(promo);
            entities.SaveChanges();
            return(promo);
        }
Beispiel #22
0
        void calculate()
        {
            var sekarang = DateTime.Now;
            var exist    = db.promotions
                           .FirstOrDefault(x => x.code == txtPromo.Text && x.start_time <sekarang && x.end_time> sekarang);

            if (exist != null)
            {
                decimal minimum      = exist.minimum_spent;
                int     minimumspend = Convert.ToInt32(minimum);
                if (Convert.ToInt32(labelSubtotal.Text) > minimumspend)
                {
                    promo = exist;
                    decimal disc   = exist.discount;
                    int     diskon = Convert.ToInt32(disc);
                    discount = diskon;
                    int hargasetelah = Convert.ToInt32(labelSubtotal.Text) * discount / 100;
                    labelDisc.Text  = hargasetelah.ToString();
                    labeldisc2.Text = "(" + discount.ToString() + "%)";
                    int subtotal = Convert.ToInt32(labelSubtotal.Text);

                    int pajak  = subtotal * 10 / 100;
                    int charge = subtotal * 5 / 100;
                    labelTax.Text     = pajak.ToString();
                    labelService.Text = charge.ToString();


                    int total = (subtotal - hargasetelah) + pajak + charge;
                    labelTotal.Text = total.ToString();
                }
                else
                {
                    promo           = null;
                    discount        = 0;
                    labeldisc2.Text = " ";
                    labelDisc.Text  = "0";
                    int hargasetelah = Convert.ToInt32(labelSubtotal.Text);
                    labeldisc2.Text = "(" + discount.ToString() + "%)";
                    int pajak  = hargasetelah * 10 / 100;
                    int charge = pajak * 5 / 100;
                    labelTax.Text     = pajak.ToString();
                    labelService.Text = charge.ToString();
                    int subtotal = Convert.ToInt32(labelSubtotal.Text);
                    int total    = subtotal + pajak + charge;
                    labelTotal.Text = total.ToString();
                }
            }
            else
            {
                promo           = null;
                discount        = 0;
                labeldisc2.Text = " ";
                labelDisc.Text  = "0";
                int hargasetelah = Convert.ToInt32(labelSubtotal.Text);
                labeldisc2.Text = "(" + discount.ToString() + "%)";
                int pajak  = hargasetelah * 10 / 100;
                int charge = pajak * 5 / 100;
                labelTax.Text     = pajak.ToString();
                labelService.Text = charge.ToString();
                int subtotal = Convert.ToInt32(labelSubtotal.Text);
                int total    = subtotal + pajak + charge;
                labelTotal.Text = total.ToString();
            }
        }
Beispiel #23
0
 public void AddPromotion(promotion promo)
 {
     utwk.PromotionRepository.Add(promo);
     utwk.Commit();
 }