/// <summary>
        /// D05 save db
        /// </summary>
        /// <param name="dataModel"></param>
        /// <returns></returns>
        public MSGReturnModel saveD05(string debtType, string actionType, D05ViewModel dataModel)
        {
            MSGReturnModel result = new MSGReturnModel();

            try
            {
                if (debtType != dataModel.Group_Product_Code.Substring(0, 1))
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = "套用產品群代碼 第一個字必須是 " + debtType;
                    return(result);
                }

                if (actionType == "Add")
                {
                    if (db.Group_Product_Code_Mapping.Where(x => x.Product_Code == dataModel.Product_Code).Count() > 0)
                    {
                        result.RETURN_FLAG = false;
                        result.DESCRIPTION = "資料重複:" + dataModel.Product_Code + " 已存在";
                        return(result);
                    }

                    db.Group_Product_Code_Mapping.Add(
                        new Group_Product_Code_Mapping()
                    {
                        Group_Product_Code = dataModel.Group_Product_Code,
                        Product_Code       = dataModel.Product_Code,
                        Processing_Date    = DateTime.Parse(dataModel.Processing_Date)
                    });
                }
                else if (actionType == "Modify")
                {
                    Group_Product_Code_Mapping oldData = db.Group_Product_Code_Mapping.Find(dataModel.Product_Code);
                    oldData.Group_Product_Code = dataModel.Group_Product_Code;
                    oldData.Product_Code       = dataModel.Product_Code;
                    oldData.Processing_Date    = DateTime.Parse(dataModel.Processing_Date);
                }

                db.SaveChanges(); //Save
                result.RETURN_FLAG = true;
            }
            catch (DbUpdateException ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = Message_Type
                                     .save_Fail.GetDescription("D05",
                                                               $"message: {ex.Message}" +
                                                               $", inner message {ex.InnerException?.InnerException?.Message}");
            }

            return(result);
        }
        public JsonResult SaveD05(string debtType, string actionType, string groupProductCode, string productCode)
        {
            MSGReturnModel result = new MSGReturnModel();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Message_Type.parameter_Error.GetDescription("D05", result.DESCRIPTION);

            try
            {
                if (GroupProductCode.M.ToString().Equals(debtType))
                {
                    debtType = GroupProductCode.M.GetDescription();
                }
                else if (GroupProductCode.B.ToString().Equals(debtType))
                {
                    debtType = GroupProductCode.B.GetDescription();
                }

                D05ViewModel dataModel = new D05ViewModel();
                dataModel.Group_Product_Code = groupProductCode;
                dataModel.Product_Code       = productCode;
                dataModel.Processing_Date    = DateTime.Now.ToString("yyyy/MM/dd");

                MSGReturnModel resultSave = D0Repository.saveD05(debtType, actionType, dataModel);

                result.RETURN_FLAG = resultSave.RETURN_FLAG;
                result.DESCRIPTION = Message_Type.save_Success.GetDescription("D05");

                if (!result.RETURN_FLAG)
                {
                    result.DESCRIPTION = Message_Type.save_Fail.GetDescription("D05", resultSave.DESCRIPTION);
                }
            }
            catch (Exception ex)
            {
                result.RETURN_FLAG = false;
                result.DESCRIPTION = ex.Message;
            }

            return(Json(result));
        }