public ActionResult Edit_TM06DKQT(ApplicationHeaderInfo pInfo, App_Detail_TM06DKQT_Info pDetail,
                                          List <AppDocumentInfo> pAppDocumentInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                pDetail.Id            = pInfo.Id;
                pDetail.APP_HEADER_ID = pInfo.Id;
                pDetail.LANGUAGE_CODE = pInfo.Languague_Code;
                Application_Header_BL objBL          = new Application_Header_BL();
                AppFeeFixBL           objFeeFixBL    = new AppFeeFixBL();
                AppDetail06DKQT_BL    objDetail      = new AppDetail06DKQT_BL();
                AppDocumentBL         objDoc         = new AppDocumentBL();
                AppClassDetailBL      objClassDetail = new AppClassDetailBL();
                bool _IsOk = false;
                if (pInfo == null || pDetail == null)
                {
                    return(Json(new { status = ErrorCode.Error }));
                }
                string  language    = AppsCommon.GetCurrentLang();
                var     CreatedBy   = SessionData.CurrentUser.Username;
                var     CreatedDate = SessionData.CurrentUser.CurrentDate;
                decimal pReturn     = ErrorCode.Success;
                List <AppFeeFixInfo> pFeeFixInfo = CommonFunction.Call_Fee.CallFee_C06(pDetail);
                pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount;
                using (var scope = new TransactionScope())
                {
                    //
                    pInfo.Languague_Code = language;
                    pInfo.Modify_By      = SessionData.CurrentUser.Username;
                    pInfo.Modify_Date    = SessionData.CurrentUser.CurrentDate;
                    pInfo.Send_Date      = DateTime.Now;
                    pInfo.DDSHCN         = "";
                    pInfo.MADDSHCN       = "";
                    pInfo.Master_Type    = "";
                    if (pDetail.pfileLogo != null)
                    {
                        pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                    }
                    //TRA RA ID CUA BANG KHI INSERT
                    int _re = objBL.AppHeaderUpdate(pInfo);

                    // detail
                    if (_re >= 0)
                    {
                        pDetail.Appcode       = pInfo.Appcode;
                        pDetail.LANGUAGE_CODE = language;
                        pDetail.APP_HEADER_ID = pInfo.Id;
                        pReturn = objDetail.App_Detail_06TMDKQT_Update(pDetail);
                    }

                    #region Phí cố định

                    // xóa đi
                    AppFeeFixBL _AppFeeFixBL = new AppFeeFixBL();
                    _AppFeeFixBL.AppFeeFixDelete(pInfo.Case_Code, language);

                    // insert lại fee

                    pReturn = objFeeFixBL.AppFeeFixInsertBath(pFeeFixInfo, pInfo.Case_Code);
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                        return(Json(new { status = -1 }));
                    }
                    #endregion

                    //tai lieu khac
                    #region Tài liệu khác
                    objDoc = new AppDocumentBL();
                    List <AppDocumentOthersInfo> Lst_Doc_Others                 = objDoc.DocumentOthers_GetByAppHeader(pInfo.Id, language);
                    List <AppDocumentOthersInfo> Lst_Doc_Others_Old             = Lst_Doc_Others.FindAll(m => m.FILETYPE == 1).ToList();
                    Dictionary <decimal, AppDocumentOthersInfo> _dic_doc_others = new Dictionary <decimal, AppDocumentOthersInfo>();
                    foreach (AppDocumentOthersInfo item in Lst_Doc_Others_Old)
                    {
                        _dic_doc_others[item.Id] = item;
                    }

                    // xóa đi trước insert lại sau
                    objDoc.AppDocumentOtherDeletedByApp_Type(pInfo.Id, language, 1);

                    if (pReturn >= 0 && pAppDocOtherInfo != null && pAppDocOtherInfo.Count > 0)
                    {
                        int check = 0;
                        foreach (var info in pAppDocOtherInfo)
                        {
                            if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                            {
                                string _url = (string)SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                info.Filename = _url;
                                check         = 1;
                            }
                            else if (_dic_doc_others.ContainsKey(info.Id))
                            {
                                info.Filename = _dic_doc_others[info.Id].Filename;
                                check         = 1;
                            }
                            info.App_Header_Id = pInfo.Id;
                            info.Language_Code = language;
                        }
                        if (check == 1)
                        {
                            pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocOtherInfo);
                        }
                    }
                    #endregion

                    #region Tai lieu dinh kem
                    if (pReturn >= 0 && pAppDocumentInfo != null)
                    {
                        if (pAppDocumentInfo.Count > 0)
                        {
                            // Get ra để map sau đó xóa đi để insert vào sau
                            AppDocumentBL          _AppDocumentBL           = new AppDocumentBL();
                            List <AppDocumentInfo> Lst_AppDoc               = _AppDocumentBL.AppDocument_Getby_AppHeader(pDetail.APP_HEADER_ID, language);
                            Dictionary <string, AppDocumentInfo> dic_appDoc = new Dictionary <string, AppDocumentInfo>();
                            foreach (AppDocumentInfo item in Lst_AppDoc)
                            {
                                dic_appDoc[item.Document_Id] = item;
                            }

                            // xóa đi trước
                            _AppDocumentBL.AppDocumentDelByApp(pDetail.APP_HEADER_ID, language);

                            foreach (var info in pAppDocumentInfo)
                            {
                                if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                                {
                                    string   _url      = (string)SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    string[] _arr      = _url.Split('/');
                                    string   _filename = WebApps.Resources.Resource.FileDinhKem;
                                    if (_arr.Length > 0)
                                    {
                                        _filename = _arr[_arr.Length - 1];
                                    }

                                    info.Filename     = _filename;
                                    info.Url_Hardcopy = _url;
                                    info.Status       = 0;
                                }
                                else
                                {
                                    if (dic_appDoc.ContainsKey(info.Document_Id))
                                    {
                                        info.Filename     = dic_appDoc[info.Document_Id].Filename;
                                        info.Url_Hardcopy = dic_appDoc[info.Document_Id].Url_Hardcopy;
                                        info.Status       = dic_appDoc[info.Document_Id].Status;
                                    }
                                }

                                info.App_Header_Id        = pInfo.Id;
                                info.Document_Filing_Date = CommonFuc.CurrentDate();
                                info.Language_Code        = language;
                            }
                            pReturn = objDoc.AppDocumentInsertBath(pAppDocumentInfo, pInfo.Id);
                        }
                    }
                    #endregion

                    #region  Thêm thông tin class
                    if (pReturn >= 0 && pAppClassInfo != null)
                    {
                        //Xoa cac class cu di
                        pReturn = objClassDetail.AppClassDetailDeleted(pInfo.Id, language);

                        pReturn = objClassDetail.AppClassDetailInsertBatch(pAppClassInfo, pInfo.Id, language);
                    }

                    //end
                    #endregion
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                        return(Json(new { status = -1 }));
                    }
                    else
                    {
                        scope.Complete();
                        _IsOk = true;
                    }
                }

                // tự động update todo

                return(Json(new { status = pInfo.Id }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }