Exemplo n.º 1
0
        public ActionResult Edit(string key)
        {
            string errMsg = "";

            ViewData["Master"] = new TR01AModel()
            {
                VOU_NO = "系統產生", DtTRN_DT = DateTime.Now, EntityState = EntityState.Added
            };
            ViewData["Detail"] = new List <TR01BModel>();
            if (!string.IsNullOrWhiteSpace(key))
            {
                var entityList = _Service.GetMany(x => x.VOU_NO == key);
                if (entityList.Count == 0)
                {
                    errMsg = "查無資料";
                }
                else
                {
                    var dataSet = TR01Business.FromEntity(entityList);
                    ViewData["Master"] = dataSet.Item1;
                    ViewData["Detail"] = dataSet.Item2;
                }
            }

            if (Request.IsAjaxRequest())
            {
                return(new JsonResult {
                    Data = new { View = ReadViewHelper.PartialView(this, "_Edit", key), ErrMsg = errMsg }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            return(PartialView("_Edit", key));
        }
Exemplo n.º 2
0
        private ActionResult ResultHandler(string errMsg, BA02AModel master, MVCxGridViewBatchUpdateValues <BA02BModel, int> updateValues)
        {
            if (errMsg == "")
            {
                TempData["SelectedItemKey"] = master.BA02A_ID;
                TempData["SaveSuccess"]     = true;
                return(RedirectToAction("RedirectIndex"));
            }
            else
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }

                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }

                var deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }
                ViewData["DeleteIDList"] = deleteIDStrList;
                errMsg                 = "存儲失敗<br/>" + errMsg;
                ViewData["ErrMsg"]     = errMsg = errMsg.Substring(0, errMsg.Length - 5);
                ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", master);

                return(PartialView("_DetailGrid", BA02Business.FromEntity(_Service.GetByMasterKey(master.BA02A_ID))));
            }
        }
Exemplo n.º 3
0
        /// <summary>Only master data change</summary>
        /// <param name="master"></param>
        /// <returns></returns>
        public ActionResult DetailGridCustomUpdate(TR01AViewModel master)
        {
            string errMsg = "";

            //Validation
            ValidateMaster(master);
            //Save
            if (ModelState.IsValid)
            {
                var TR01A = MasterToEntity(master);

                var result = _Service.UpdateM(TR01A);
                errMsg = result.Message;
                master = new TR01AViewModel(result.Data);
            }
            //Result
            if (errMsg.Length > 0 || !ModelState.IsValid)
            {
                errMsg += "Fail";
                ViewData["EditErrorMsg"] = errMsg;
                ViewData["MasterForm"]   = ReadViewHelper.PartialView(this, "_MasterForm", master);
                return(PartialView("_DetailGrid", GetTR01BList(master.TR01A_ID)));
            }
            else
            {
                SetTempData(master.TR01A_ID);
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 4
0
 public ActionResult DetailGrid(int?key)
 {
     if (key.HasValue)
     {
         var data = _Service.GetByKey(key.Value);
         ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", UserGroupBusiness.FromEntity(data));
         return(PartialView("_DetailGrid", _Service.GetGroupUser(key.Value)));
     }
     else
     {
         //ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", new ViewModel.UserGroup.UserGroupModel());
         return(PartialView("_DetailGrid", new List <Models.SystemUser>()));
     }
 }
Exemplo n.º 5
0
        public ActionResult DetailGridBatchUpdate(MVCxGridViewBatchUpdateValues <SystemUser, int> updateValues, List <int> permissions, UserGroupModel master)
        {
            //TODO
            //master 要轉成 Entity(UserGroup)

            var deleteKeys = updateValues.DeleteKeys;
            var insertList = updateValues.Insert;
            // SaveChanges(ref Models.UserGroup entity, List<int> permissions, List<int> insertUser, List<int> deleteUser, EntityState state)

            var data = _Service.GetByKey(master.ID);

            UserGroupBusiness.ToEntity(ref data, master);

            ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", UserGroupBusiness.FromEntity(data));
            ViewData["TreeList"]   = ReadViewHelper.PartialView(this, "_MasterForm", UserGroupBusiness.FromEntity(data));
            return(PartialView("_DetailGrid", _Service.GetGroupUser(master.ID)));
        }
Exemplo n.º 6
0
        private ActionResult ResultHandler(string errMsg, TR01AModel master, MVCxGridViewBatchUpdateValues <TR01BModel, int> updateValues)
        {
            if (errMsg == "")
            {
                ViewData["IsSuccess"] = "true";
                var result = TR01Business.FromEntity(_Service.GetMany(x => x.VOU_NO == master.VOU_NO));
                ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", result.Item1);
                return(PartialView("_DetailGrid", result.Item2));
            }
            else
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }
                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }
                var deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }
                if (master.EntityState == EntityState.Added)
                {
                    master.VOU_NO = "系統產生";
                }

                errMsg = "存儲失敗<br/>" + errMsg;
                ViewData["DeleteIDList"] = deleteIDStrList;
                ViewData["ErrMsg"]       = errMsg.Substring(0, errMsg.Length - 5);
                ViewData["MasterForm"]   = ReadViewHelper.PartialView(this, "_MasterForm", master);
                return(PartialView("_DetailGrid", new List <TR01BModel>()));
            }
        }
Exemplo n.º 7
0
        /// <summary>Both master and detail has change</summary>
        /// <param name="batchData">contain updata、insert、delete list</param>
        /// <param name="master"></param>
        /// <returns></returns>
        public ActionResult DetailGridBatchUpdate(MVCxGridViewBatchUpdateValues <TR01BViewModel, int> updateValues, TR01AViewModel master)
        {
            string errMsg     = "";
            int    errorCount = 0;
            int    TR01A_ID   = master.TR01A_ID;

            //Validation
            ValidateMaster(master);

            for (int i = 0; i < updateValues.Insert.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Insert[i]) == false)
                {
                    errorCount++;
                }
                //if (updateValues.Insert[i].REM_MM.Length > 10)
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Update[{i}].REM_MM", "REM_MM太長");//display error in cell
                //}
            }

            for (int i = 0; i < updateValues.Update.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Update[i]) == false)
                {
                    errorCount++;
                }
                //if (updateValues.Update[i].REM_MM.Length > 10)
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Update[{i}].REM_MM", "REM_MM太長");//display error in cell
                //}
            }

            //Save
            if (errorCount == 0 && ModelState.IsValid)
            {
                var TR01A = MasterToEntity(master);

                var addList = new List <TR01B>();
                foreach (var item in updateValues.Insert)
                {
                    var TR01B = new TR01B();
                    item.CREATE_USER = "******";
                    item.CREATE_DATE = DateTime.Now;
                    item.ToDomain(TR01B);
                    addList.Add(TR01B);
                }

                var updateList = new List <TR01B>();
                foreach (var item in updateValues.Update)
                {
                    var TR01B = new TR01B();
                    TR01B            = _Service.GetD(x => x.TR01B_ID == item.TR01B_ID);
                    item.CREATE_USER = TR01B.CREATE_USER;
                    item.CREATE_DATE = TR01B.CREATE_DATE;
                    item.UPDATE_USER = "******";
                    item.UPDATE_DATE = DateTime.Now;
                    item.ToDomain(TR01B);
                    updateList.Add(TR01B);
                }

                errMsg = _Service.UpdateMD(TR01A, addList, updateList, updateValues.DeleteKeys);
            }

            //Result
            if (errMsg.Length > 0 || !ModelState.IsValid)
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }

                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }

                string deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }
                ViewData["EditErrorMsg"] = "Failure" + "<br />" + errMsg;
                ViewData["DeleteIDList"] = deleteIDStrList;
                ViewData["MasterForm"]   = ReadViewHelper.PartialView(this, "_MasterForm", master);
                return(PartialView("_DetailGrid", GetTR01BList(TR01A_ID)));
            }
            else
            {
                SetTempData(master.TR01A_ID);
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 8
0
        /// <summary>Both master and detail has change</summary>
        /// <param name="batchData">contain updata、insert、delete list</param>
        /// <param name="master"></param>
        /// <returns></returns>
        public ActionResult DetailGridBatchUpdate(MVCxGridViewBatchUpdateValues <TR01BViewModel, int> updateValues, TR01AViewModel master, string DateBeg, string DateEnd, string Tax)
        {
            //Validation
            string errMsg = "";

            if (UserInfo.LanguageType == Language.Type.VN)
            {
                master.DtPUR_DT = DateTime.Parse(DateBeg);
                master.DtEXP_DT = DateTime.Parse(DateEnd);
                ModelState.Clear();
                TryValidateModel(master);
            }
            var isValid = TR01Business.Validation(master, updateValues, ModelState);

            ModelState.Remove("DtPUR_DT");
            ModelState.Remove("DtEXP_DT");
            if (!TR01Business.ValidateRemove(master, updateValues.Update))
            {
                isValid = false;
                errMsg  = "資料已被其他人異動過";
            }
            if (master.CFN_YN == "Y")
            {
                errMsg += "資料已確認  不可修改";
            }
            else if (master.CFN_YN == "P")
            {
                errMsg += "資料申請中  不可修改";
            }
            else
            {
                //Save
                if (isValid)
                {
                    var TR01A = TR01Business.BeforSave(master);
                    if (UserInfo.LanguageType == Language.Type.VN)
                    {
                        TR01A.PUR_DT = DateBeg.Replace("/", ""); //master.DtPUR_DT.Value.ToString("yyyyddMM");
                        TR01A.EXP_DT = DateEnd.Replace("/", ""); //master.DtEXP_DT.Value.ToString("yyyyddMM");
                        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Language.US);
                        TR01A.TAX_RT = double.Parse(Tax);        //越文沒有小數點特殊處理
                    }
                    else
                    {
                        TR01A.PUR_DT = master.DtPUR_DT.Value.ToString("yyyyMMdd");
                        TR01A.EXP_DT = master.DtEXP_DT.Value.ToString("yyyyMMdd");
                    }
                    var addList    = TR01Business.BeforSave(updateValues.Insert, EditType.AddNew);
                    var updateList = TR01Business.BeforSave(updateValues.Update, EditType.Update);
                    var result     = _Service.Update(TR01A, addList, updateList, updateValues.DeleteKeys);
                    errMsg = result.Message;
                    master = TR01Business.FromEntity(result.Data);
                }
            }



            //Error handling
            if (errMsg.Length > 0 || !isValid)
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }

                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }

                string deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }

                ViewData["DeleteIDList"] = deleteIDStrList;
                ViewData["ErrMsg"]       = Resources.Resource.FailureStr + "<br />" + errMsg;
            }

            ViewData["Key"] = master.TR01A_ID;
            var BA01BList = new Services.BA01.BA01Service().GetAllD(master.BA01A_ID).ToList();

            ViewBag.Data = BA01BList;
            //var BA01B = BA01BList.FirstOrDefault(x => x.BA01B_ID == master.BA01B_ID);
            //if (BA01B != null)
            //{
            //    master.TEL_NO = BA01B.TEL_NO;
            //    master.TEL_EX = BA01B.TEL_EX;
            //}
            ViewData["CFN_YN"] = master.CFN_YN;
            if (master.CFN_YN == "Y")
            {
                ViewData["IsConfirm"] = true;
            }
            else
            {
                ViewData["IsConfirm"] = false;
            }
            ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", master);
            return(PartialView("_DetailGrid", GetTR01BList(master.TR01A_ID)));
        }
Exemplo n.º 9
0
        /// <summary>Only master data change</summary>
        /// <param name="master">主檔資料</param>
        /// <param name="key">JS keyOnPage的 value</param>
        /// <param name="Deletekey">要刪除的key</param>
        /// <param name="Reload_TF">控制是否單純刷新資料</param>
        /// <returns></returns>
        public ActionResult DetailGridCustomUpdate(TR01AViewModel master, string key, string Deletekey, string Reload_TF, string Lock, string DateBeg, string DateEnd, string Tax)
        {
            var errMsg = "";

            if (Lock != null)
            {
                var entities = new PURSysEntities();
                var keyInt   = int.Parse(key);
                var data     = entities.TR01A.First(x => x.TR01A_ID == keyInt);
                if (Lock == "Y")
                {
                    data.CFN_YN = "N";
                }
                else
                {
                    data.CFN_YN = "Y";
                }
                entities.SaveChanges();
            }

            if (Reload_TF == "T")//load畫面 => 新增/查詢/取消
            {
                int.TryParse(key, out int keyValue);
                if (keyValue > 0)
                {
                    master = TR01Business.FromEntity(_Service.GetA(keyValue));
                }
                else
                {
                    //新增初始化
                    master.DtPUR_DT = DateTime.UtcNow.AddHours(07);
                    master.CPN_NM   = "劲亨金属表面处理工業有限公司   Công ty Jingheng";
                    master.TAX_RT   = CacheCommonDataModule.GetTaxRate().First().Value;
                }
                ModelState.Clear();
            }
            else // 修改(新增、修改) / 刪除
            {
                if (master.CFN_YN == "Y")
                {
                    errMsg += "資料已確認  不可修改";
                    int.TryParse(key, out int keyValue);
                    master = TR01Business.FromEntity(_Service.GetA(keyValue));
                }
                else if (master.CFN_YN == "P")
                {
                    errMsg += "資料申請中  不可修改";
                    int.TryParse(key, out int keyValue);
                    master = TR01Business.FromEntity(_Service.GetA(keyValue));
                }
                else
                {
                    if (int.TryParse(Deletekey, out int keyValue))// 刪除
                    {
                        if (keyValue > 0)
                        {
                            errMsg = "查無此筆刪除資料";
                            var count = _Service.GetA(x => x.TR01A_ID == keyValue).Count();
                            if (count == 1)
                            {
                                errMsg = _Service.Delete(keyValue);//刪除成功回傳空字串
                            }
                            if (errMsg.Length > 0)
                            {
                                ViewData["ErrMsg"] = "Delete Fail";
                                master             = TR01Business.FromEntity(_Service.GetA(keyValue));//取回刪除失敗的資料回畫面顯示
                            }
                        }
                        ModelState.Clear();
                    }
                    else// Save 新增、修改 data
                    {
                        //Help.ClearError(ModelState, "DtPUR_DT");
                        //Help.ClearError(ModelState, "DtEXP_DT");
                        if (UserInfo.LanguageType == Language.Type.VN)
                        {
                            master.DtPUR_DT = DateTime.Parse(DateBeg);
                            master.DtEXP_DT = DateTime.Parse(DateEnd);
                            ModelState.Clear();
                            TryValidateModel(master);
                        }

                        var isValid = TR01Business.Validation(master, ModelState);
                        if (!TR01Business.ValidateRemove(master, null))
                        {
                            isValid = false;
                            errMsg  = "資料已被其他人異動過";
                        }
                        if (isValid)// Save
                        {
                            var TR01A = TR01Business.BeforSave(master);
                            if (UserInfo.LanguageType == Language.Type.VN)
                            {
                                TR01A.PUR_DT = DateBeg.Replace("/", ""); //master.DtPUR_DT.Value.ToString("yyyyddMM");
                                TR01A.EXP_DT = DateEnd.Replace("/", ""); //master.DtEXP_DT.Value.ToString("yyyyddMM");
                                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Language.US);
                                TR01A.TAX_RT = double.Parse(Tax);
                            }
                            else
                            {
                                TR01A.PUR_DT = master.DtPUR_DT.Value.ToString("yyyyMMdd");
                                TR01A.EXP_DT = master.DtEXP_DT.Value.ToString("yyyyMMdd");
                            }
                            var result = _Service.Update(TR01A);
                            errMsg = result.Message;
                            master = TR01Business.FromEntity(result.Data);
                        }

                        if (errMsg.Length > 0 || !isValid)// Result
                        {
                            errMsg += Resources.Resource.FailureStr;
                        }
                    }
                }
            }
            ViewData["ErrMsg"] = errMsg;
            ViewData["Key"]    = master.TR01A_ID;


            var BA01BList = new Services.BA01.BA01Service().GetAllD(master.BA01A_ID).ToList();

            ViewBag.Data       = BA01BList;
            ViewData["CFN_YN"] = master.CFN_YN;
            if (master.CFN_YN == "Y")
            {
                ViewData["IsConfirm"] = true;
            }
            else
            {
                ViewData["IsConfirm"] = false;
            }

            ViewData["MasterForm"] = ReadViewHelper.PartialView(this, "_MasterForm", master);
            return(PartialView("_DetailGrid", GetTR01BList(master.TR01A_ID)));
        }
Exemplo n.º 10
0
        /// <summary>Both master and detail has change</summary>
        /// <param name="batchData">contain updata、insert、delete list</param>
        /// <param name="master"></param>
        /// <returns></returns>
        public ActionResult DetailGridBatchUpdate(MVCxGridViewBatchUpdateValues <BA02BViewModel, int> updateValues, BA02AViewModel master)
        {
            string errMsg     = "";
            int    errorCount = 0;
            int    BA02A_ID   = master.BA02A_ID;

            //Validation
            ValidateMaster(master);

            for (int i = 0; i < updateValues.Insert.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Insert[i]) == false)
                {
                    errorCount++;
                }
                if (updateValues.Insert[i].PUR_PR < 0)
                {
                    errorCount++;
                    ModelState.AddModelError($"Insert[{i}].PUR_PR", "金額不可為負");//display error in cell
                }
                //if (updateValues.Insert[i].REM_MM.Length > 10)
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Update[{i}].REM_MM", "REM_MM太長");//display error in cell
                //}
                //foreach (var err in DDMHelper.ValidateData("BA02B", updateValues.Insert[i], replace: replace))
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Insert[{i}].{err.Key}", err.Value);//display error in cell
                //}
            }

            for (int i = 0; i < updateValues.Update.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Update[i]) == false)
                {
                    errorCount++;
                }
                if (updateValues.Update[i].PUR_PR < 0)
                {
                    errorCount++;
                    ModelState.AddModelError($"Insert[{i}].PUR_PR", "金額不可為負");//display error in cell
                }
                //if (updateValues.Update[i].REM_MM.Length > 10)
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Update[{i}].REM_MM", "REM_MM太長");//display error in cell
                //}
                //foreach (var err in DDMHelper.ValidateData("BA02B", updateValues.Update[i], replace: replace))
                //{
                //    errorCount++;
                //    ModelState.AddModelError($"Update[{i}].{err.Key}", err.Value);//display error in cell
                //}
            }

            //Save
            if (errorCount == 0 && ModelState.IsValid)
            {
                var BA02A = MasterToEntity(master);

                var addList = new List <BA02B>();
                foreach (var item in updateValues.Insert)
                {
                    var BA02B = new BA02B();
                    item.REM_MM      = master.REM_MM;
                    item.CREATE_USER = UserInfo.Id;
                    item.CREATE_DATE = DateTime.Now;
                    item.ToDomain(BA02B);
                    addList.Add(BA02B);
                }

                var updateList = new List <BA02B>();
                foreach (var item in updateValues.Update)
                {
                    var BA02B = new BA02B();
                    BA02B            = _Service.GetD(x => x.BA02B_ID == item.BA02B_ID);
                    item.CREATE_USER = BA02B.CREATE_USER;
                    item.CREATE_DATE = BA02B.CREATE_DATE;
                    item.UPDATE_USER = UserInfo.Id;
                    item.UPDATE_DATE = DateTime.Now;
                    item.ToDomain(BA02B);
                    updateList.Add(BA02B);
                }

                errMsg = _Service.UpdateMD(BA02A, addList, updateList, updateValues.DeleteKeys);
            }

            //Result
            if (errMsg.Length > 0 || !ModelState.IsValid)
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }

                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }

                string deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }
                ViewData["EditErrorMsg"] = "Failure" + "<br />" + errMsg;
                ViewData["DeleteIDList"] = deleteIDStrList;
                ViewData["MasterForm"]   = ReadViewHelper.PartialView(this, "_MasterForm", master);
                return(PartialView("_DetailGrid", GetBA02BList(BA02A_ID)));
            }
            else
            {
                CacheHelper.Invalidate("BA02A");
                SetTempData(master.BA02A_ID);
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 11
0
        /// <summary>Both master and detail has change</summary>
        /// <param name="batchData">contain updata、insert、delete list</param>
        /// <param name="master"></param>
        /// <returns></returns>
        public ActionResult DetailGridBatchUpdate(MVCxGridViewBatchUpdateValues <BA01BViewModel, int> updateValues, BA01AViewModel master)
        {
            int errorCount = 0;

            //Validation
            ValidateMaster(master);

            for (int i = 0; i < updateValues.Insert.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Insert[i]) == false)
                {
                    errorCount++;
                }
            }

            for (int i = 0; i < updateValues.Update.Count; i++)
            {
                if (updateValues.IsValid(updateValues.Update[i]) == false)
                {
                    errorCount++;
                }
            }
            string errMsg = "";

            //Save
            if (errorCount == 0 && ModelState.IsValid)
            {
                var BA01A = MasterToEntity(master);

                var addList = new List <BA01B>();
                foreach (var item in updateValues.Insert)
                {
                    var BA01B = new BA01B();
                    item.CREATE_USER = UserInfo.Id;
                    item.CREATE_DATE = DateTime.Now;
                    item.ToDomain(BA01B);
                    addList.Add(BA01B);
                }

                var updateList = new List <BA01B>();
                foreach (var item in updateValues.Update)
                {
                    var BA01B = new BA01B();
                    BA01B            = _Service.GetD(x => x.BA01B_ID == item.BA01B_ID);
                    item.BA01A_ID    = BA01B.BA01A_ID;
                    item.CREATE_USER = BA01B.CREATE_USER;
                    item.CREATE_DATE = BA01B.CREATE_DATE;
                    item.UPDATE_USER = UserInfo.Id;
                    item.UPDATE_DATE = DateTime.Now;
                    item.ToDomain(BA01B);
                    updateList.Add(BA01B);
                }

                errMsg = _Service.UpdateMD(BA01A, addList, updateList, updateValues.DeleteKeys);
            }

            //Result
            if (errorCount > 0 || errMsg.Length > 0 || !ModelState.IsValid)
            {
                for (int i = 0; i < updateValues.Insert.Count; i++)
                {
                    ModelState.AddModelError($"Insert[{i}].IsValid", "Error");
                }

                for (int i = 0; i < updateValues.Update.Count; i++)
                {
                    ModelState.AddModelError($"Update[{i}].IsValid", "Error");
                }

                string deleteIDStrList = "";
                for (int i = 0; i < updateValues.DeleteKeys.Count; i++)
                {
                    updateValues.SetErrorText(updateValues.DeleteKeys[i], "Unable to delete!");
                    deleteIDStrList += updateValues.DeleteKeys[i] + ",";
                }
                ViewData["EditErrorMsg"] = Resources.Resource.FailureStr + "<br />" + errMsg;
                ViewData["DeleteIDList"] = deleteIDStrList;
                ViewData["MasterForm"]   = ReadViewHelper.PartialView(this, "_MasterForm", master);

                return(PartialView("_DetailGrid", GetBA01BList(master.BA01A_ID)));
            }
            else
            {
                CacheHelper.Invalidate("BA01A");
                SetTempData(master.BA01A_ID);
                return(RedirectToAction("Index"));
            }
        }