Exemplo n.º 1
0
        public ActionResult Index(int id)
        {
            ViewBag.ParentID = id;
            TempData["ProductDetId"] = id;

            GHSViewModel GHS = new GHSViewModel();

            try
            {
                using (var db = new EF.CMCSQL03Entities())
                {
                    var pd = (from t in db.tblProductDetail
                              where t.ProductDetailID == id
                              select t).FirstOrDefault();

                    ViewBag.productcode = pd.ProductCode;
                    ViewBag.productname = pd.ProductName;
                    ViewBag.ProductDetailID = pd.ProductDetailID;

                    var ghs = (from t in db.tblGHS
                               where t.ProductDetailID == id
                               select t).FirstOrDefault();

                    GHS.GHSSignalWord = ghs.SignalWord;
                    GHS.GHSSymbol1 = ghs.Symbol1;
                    GHS.GHSSymbol2 = ghs.Symbol2;
                    GHS.GHSSymbol3 = ghs.Symbol3;
                    GHS.GHSSymbol4 = ghs.Symbol4;
                    GHS.GHSSymbol5 = ghs.Symbol5;
                    GHS.OtherLabelInfo = ghs.OtherLabelInfo;
                }

                return View("Index", GHS);
            }
            catch (Exception)
            {
                return View("Index", GHS);
            }
        }
Exemplo n.º 2
0
        public ActionResult Save(GHSViewModel obj)
        {
            using (var db = new EF.CMCSQL03Entities())
            {
                var q = db.tblGHS.Find(obj.ProductDetailID);

                if (q != null)
                {
                    q.SignalWord = obj.GHSSignalWord;
                    q.Symbol1 = obj.GHSSymbol1;
                    q.Symbol2 = obj.GHSSymbol2;
                    q.Symbol3 = obj.GHSSymbol3;
                    q.Symbol4 = obj.GHSSymbol4;
                    q.Symbol5 = obj.GHSSymbol5;
                    q.OtherLabelInfo = obj.OtherLabelInfo;

                    db.SaveChanges();
                }
                else
                {
                    var newrecord = new EF.tblGHS
                    {
                        ProductDetailID = Convert.ToInt32(obj.ProductDetailID),
                        SignalWord = obj.GHSSignalWord,
                        Symbol1 = obj.GHSSymbol1,
                        Symbol2 = obj.GHSSymbol2,
                        Symbol3 = obj.GHSSymbol3,
                        Symbol4 = obj.GHSSymbol4,
                        Symbol5 = obj.GHSSymbol5,
                        OtherLabelInfo = obj.OtherLabelInfo
                    };

                    db.tblGHS.Add(newrecord);
                    db.SaveChanges();
                }
            }

            return null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Displays readonly GHS information in Product detail.
        /// Returns blank view if model is empty.
        /// </summary>
        public ActionResult GHSDisplay(int? id)
        {
            ViewBag.ParentID = id;
            GHSViewModel GHS = new GHSViewModel();

            try
            {
                using (var db = new EF.CMCSQL03Entities())
                {
                    var pd = (from t in db.tblProductDetail
                              where t.ProductDetailID == id
                              select t).FirstOrDefault();

                    ViewBag.productcode = pd.ProductCode;
                    ViewBag.productname = pd.ProductName;
                    ViewBag.ProductDetailID = pd.ProductDetailID;

                    var ghs = (from t in db.tblGHS
                               where t.ProductDetailID == id
                               select t).FirstOrDefault();

                    GHS.GHSSignalWord = ghs.SignalWord;
                    GHS.GHSSymbol1 = ghs.Symbol1;
                    GHS.GHSSymbol2 = ghs.Symbol2;
                    GHS.GHSSymbol3 = ghs.Symbol3;
                    GHS.GHSSymbol4 = ghs.Symbol4;
                    GHS.GHSSymbol5 = ghs.Symbol5;
                    GHS.OtherLabelInfo = ghs.OtherLabelInfo;
                }

                return PartialView("~/Views/Products/_GHSInfo.cshtml", GHS);
            }
            catch (Exception)
            {
                return PartialView("~/Views/Products/_GHSInfo.cshtml", GHS);
            }
        }