Esempio n. 1
0
        public ActionResult Save(MTinfounit mtInfoUnit)
        {
            string        lang       = Request.Form["lang"];
            string        langValue  = Request.Form["langValue"];
            List <string> array      = lang.Split(',').ToList <string>();
            List <string> arrayValue = langValue.Split(',').ToList <string>();
            string        name       = string.Empty;

            for (int x = 0; x < array.Count; x++)
            {
                name += string.Format("{0}:{1},", array[x], arrayValue[x]);
            }
            if (name.LastIndexOf(',') > 0)
            {
                name = name.Substring(0, name.Length - 1);
            }
            mtInfoUnit.name = name;
            MTinfounitService.GetInstance().Save(mtInfoUnit);
            return(Redirect("/mtinfounit/list/"));
        }
Esempio n. 2
0
        public ActionResult edit(string id)
        {
            int iid = 0;

            int.TryParse(id, out iid);
            MTinfounit mtinfoUnit = MTinfounitService.GetInstance().Get(iid);

            List <SelectListItem> typeItems = new List <SelectListItem>();

            foreach (var item in DeviceData.deviceTypeMap)
            {
                typeItems.Add(new SelectListItem()
                {
                    Text = item.Value.name, Value = item.Value.code.ToString()
                });
            }
            ViewData["mtTypeItems"]   = typeItems;
            ViewData["mtUnit"]        = ConvertToSelectListItem(MTUnit.AllUnits);
            ViewData["mtMonitorType"] = ConvertToSelectListItem(MTMonitorType.AllMonitorTypes);
            ViewData["mtDataType"]    = ConvertToSelectListItem(MTDataType.AllDataTypes);

            IList <Language>  langs  = LanguageService.GetInstance().GetList();
            IList <Hashtable> tables = new List <Hashtable>();
            Hashtable         table  = null;

            foreach (Language language in langs)
            {
                table              = new Hashtable();
                table["langcode"]  = language.codename;
                table["langName"]  = language.displayName;
                table["langValue"] = mtinfoUnit == null ? string.Empty :
                                     mtinfoUnit.getCodeName(language.codename);
                tables.Add(table);
            }
            ViewData["list"] = tables;

            return(View(mtinfoUnit));
        }