public ActionResult Delete(string ModeType, string Format, string SettingName, string FieldName, string BeforeValue)
 {
     if (string.IsNullOrEmpty(ModeType) ||
         string.IsNullOrEmpty(Format) ||
         string.IsNullOrEmpty(SettingName) ||
         string.IsNullOrEmpty(FieldName) ||
         string.IsNullOrEmpty(BeforeValue))
     {
         return(RedirectToAction("Index"));
     }
     using (tblCodeMappingRepository rep = new tblCodeMappingRepository())
     {
         rep.DeleteMapping(SettingName, Format, ModeType, FieldName, BeforeValue);
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult Save(CodeMapVM vm)
        {
            if (string.IsNullOrEmpty(vm.CustomerName))
            {
                vm.SaveResult += "請輸入 Customer Name!\r\n";
            }
            if (string.IsNullOrEmpty(vm.ModeType))
            {
                vm.SaveResult += "請選擇 Mode Type!\r\n";
            }
            if (string.IsNullOrEmpty(vm.Format))
            {
                vm.SaveResult += "請選擇 Format!\r\n";
            }
            if (string.IsNullOrEmpty(vm.SettingName))
            {
                vm.SaveResult += "請選擇 XML/EXCEL Name!\r\n";
            }
            if (string.IsNullOrEmpty(vm.FieldName))
            {
                vm.SaveResult += "請選擇 Tag/Column Name!\r\n";
            }

            if (!string.IsNullOrEmpty(vm.SaveResult))
            {
                if (vm.ViewStatus == "E")
                {
                    return(View("Edit", vm));
                }
                else
                {
                    return(View("New", vm));
                }
            }
            using (tblCodeMappingRepository rep = new tblCodeMappingRepository())
            {
                if (vm.ViewStatus == "E")  // 更新
                {
                    vm.SaveResult = rep.UpadteMapping(vm.SettingName, vm.Format, vm.ModeType, vm.FieldName, vm.BeforeValue, vm.NewBeforeValue, vm.AfterValue, userInfo.Account);
                }
                else
                {
                    vm.SaveResult = rep.InsertMapping(vm.SettingName, vm.Format, vm.ModeType, vm.FieldName, vm.NewBeforeValue, vm.AfterValue, userInfo.Account);
                }
                if (vm.SaveResult.Equals("ok"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    if (vm.ViewStatus == "E")
                    {
                        return(View("Edit", vm));
                    }
                    else
                    {
                        return(View("New", vm));
                    }
                }
            }
        }