Esempio n. 1
0
        public string getPrevDetails(int?id)
        {
            IList <TRN_USER_PROMO_DET> trn_user_specimen_det = db.TRN_USER_PROMO_DET.Where(t => t.USER_PROMO_NO == id).ToList();

            /*JavaScriptSerializer TheSerializer = new JavaScriptSerializer();
             * return TheSerializer.Serialize(trn_user_specimen);*/
            string        ret         = "";
            List <string> toberemoved = new List <string>();

            foreach (string crntSession in Session)
            {
                if (crntSession.Contains("promotion"))
                {
                    toberemoved.Add(crntSession);
                }
            }

            foreach (string tmp in toberemoved)
            {
                Session.Remove(tmp);
            }
            foreach (TRN_USER_PROMO_DET tmp_det in trn_user_specimen_det)
            {
                SET_PROMO_ITEM specimen = db.SET_PROMO_ITEM.Single(t => t.PROMO_ITEM_NO == tmp_det.PROMO_ITEM_NO);
                //Session.Add("specimen" + tmp_det.SPECIMEN_NO, tmp_det.QTY);
                this.SaveSpecimenOnSession(int.Parse(tmp_det.PROMO_ITEM_NO.ToString()), int.Parse(tmp_det.QTY.ToString()), (tmp_det.IS_ACTIVE == 1) ? "Active" : "Inactive");
                if (specimen != null)
                {
                    ret += "<tr id=" + tmp_det.PROMO_ITEM_NO + " tmptag=" + tmp_det.USER_PROMO_DET_NO + "><td>" + specimen.PROMO_ITEM_CODE + "</td><td>" + specimen.PROMO_ITEM_NAME +
                           "</td><td>" + tmp_det.QTY + "</td><td>" + ((tmp_det.ACTIVE_SPEC) ? "Active" : "Inactive") + "</td><td><input class=\"btn btn-small btn-info\" onclick=\"setEdit($(this).closest('tr').children(':eq(0)').text(),$(this).closest('tr').children(':eq(2)').text())\" value=\"Edit\" type=\"button\">" +
                           "<input class=\"btn btn-small btn-danger\" onclick=\"removeSpecimen( $(this).closest(\'tr\').attr('id'));$(this).closest(\'tr\').remove();\" value=\"Remove\" type=\"button\"></td><td></td></tr>";
                }
            }
            return(ret);
        }
        public ActionResult DeleteConfirmed(decimal id)
        {
            SET_PROMO_ITEM set_promo_item = db.SET_PROMO_ITEM.Single(s => s.PROMO_ITEM_NO == id);

            db.SET_PROMO_ITEM.DeleteObject(set_promo_item);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /Promotionaltem/Details/5

        public ActionResult Details(decimal id = 0)
        {
            SET_PROMO_ITEM set_promo_item = db.SET_PROMO_ITEM.Single(s => s.PROMO_ITEM_NO == id);

            if (set_promo_item == null)
            {
                return(HttpNotFound());
            }
            return(View(set_promo_item));
        }
        //
        // GET: /Promotionaltem/Edit/5

        public ActionResult Edit(decimal id = 0)
        {
            SET_PROMO_ITEM set_promo_item = db.SET_PROMO_ITEM.Single(s => s.PROMO_ITEM_NO == id);

            if (set_promo_item == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PROMO_ITEM_TYPES = from p in db.SET_PROMO_ITEM_TYPE select p;
            return(View(set_promo_item));
        }
        public ActionResult Edit(SET_PROMO_ITEM set_promo_item)
        {
            if (ModelState.IsValid)
            {
                db.SET_PROMO_ITEM_UPDATE(set_promo_item.PROMO_ITEM_NO,
                                         decimal.Parse(Session["sess_USER_NO"].ToString()),
                                         decimal.Parse(Session["sess_LOGON_NO"].ToString()),
                                         set_promo_item.PROMO_ITEM_TYPE_NO,
                                         set_promo_item.PROMO_ITEM_NAME,
                                         set_promo_item.PROMO_ITEM_CODE,
                                         set_promo_item.PROMO_ITEM_DESC,
                                         set_promo_item.IS_ACTIVE,
                                         set_promo_item.ACTIVE_FROM,
                                         set_promo_item.ACTIVE_TO,
                                         set_promo_item.SL_NUM);

                return(RedirectToAction("Index"));
            }
            return(View(set_promo_item));
        }