public ActionResult DichDonDangKy(ApplicationHeaderInfo pInfo, App_Detail_TM06DKQT_Info pDetail, List <AppDocumentInfo> pAppDocumentInfo,
                                          List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppClassDetailInfo> pAppClassInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                Application_Header_BL objBL          = new Application_Header_BL();
                AppDetail06DKQT_BL    objDetailBL    = new AppDetail06DKQT_BL();
                AppClassDetailBL      objClassDetail = new AppClassDetailBL();
                AppDocumentBL         objDoc         = new AppDocumentBL();
                AppFeeFixBL           objFeeFixBL    = new AppFeeFixBL();
                if (pInfo == null || pDetail == null)
                {
                    return(Json(new { status = ErrorCode.Error }));
                }
                string language = "";
                if (pInfo.Languague_Code == Language.LangVI)
                {
                    language = Language.LangEN;
                }
                else
                {
                    language = Language.LangVI;
                }
                var     CreatedBy    = SessionData.CurrentUser.Username;
                var     CreatedDate  = SessionData.CurrentUser.CurrentDate;
                int     pReturn      = ErrorCode.Success;
                int     pAppHeaderID = 0;
                decimal pIDHeaderoot = pInfo.Id;
                string  prefCaseCode = "";
                foreach (AppFeeFixInfo item in pFeeFixInfo)
                {
                    if (item.Amount == 0)
                    {
                        // fix là 2 củ
                        item.Amount = 2000000;
                    }
                }

                using (var scope = new TransactionScope())
                {
                    //

                    pInfo.Languague_Code = language;
                    if (pInfo.Created_By == null || pInfo.Created_By == "0" || pInfo.Created_By == "")
                    {
                        pInfo.Created_By = CreatedBy;
                    }

                    //kiểm tra có rồi thì update, chưa có thì insert
                    if (pInfo.Id_Vi > 0)
                    {
                        pInfo.Modify_By   = CreatedBy;
                        pInfo.Modify_Date = CreatedDate;
                        pAppHeaderID      = objBL.AppHeaderUpdate(pInfo);
                    }
                    else
                    {
                        //TRA RA ID CUA BANG KHI INSERT
                        pInfo.Created_By   = CreatedBy;
                        pInfo.Created_Date = CreatedDate;
                        pAppHeaderID       = objBL.AppHeaderInsert(pInfo, ref prefCaseCode);
                    }


                    //Gán lại khi lấy dl
                    if (pAppHeaderID >= 0)
                    {
                        pReturn = objFeeFixBL.AppFeeFixInsertBath(pFeeFixInfo, prefCaseCode);
                    }
                    else
                    {
                        Transaction.Current.Rollback();
                    }
                    if (pReturn >= 0)
                    {
                        pDetail.Appcode       = pInfo.Appcode;
                        pDetail.LANGUAGE_CODE = language;
                        pDetail.APP_HEADER_ID = pAppHeaderID;
                        if (pDetail.pfileLogo != null)
                        {
                            pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                        }
                        pReturn = objDetailBL.App_Detail_06TMDKQT_Insert(pDetail);
                        //Thêm thông tin class
                        if (pReturn >= 0)
                        {
                            pReturn = objClassDetail.AppClassDetailInsertBatch(pAppClassInfo, pAppHeaderID, language);
                        }
                    }
                    //Tai lieu dinh kem
                    if (pReturn >= 0 && pAppDocumentInfo != null)
                    {
                        if (pAppDocumentInfo.Count > 0)
                        {
                            pReturn = objDoc.AppDocumentTranslate(language, pIDHeaderoot, pAppHeaderID);
                        }
                    }
                    //tai lieu khac
                    if (pReturn >= 0 && pAppDocOtherInfo != null)
                    {
                        if (pAppDocOtherInfo.Count > 0)
                        {
                            var listDocument = new List <AppDocumentOthersInfo>();
                            int check        = 0;
                            foreach (var info in pAppDocOtherInfo)
                            {
                                if (!string.IsNullOrEmpty(info.Documentname))
                                {
                                    check = 1;
                                    info.App_Header_Id = pInfo.Id;
                                    info.Language_Code = language;
                                    info.IdRef         = Convert.ToDecimal(info.keyFileUpload);
                                    listDocument.Add(info);
                                }
                            }
                            if (check == 1)
                            {
                                if (pInfo.Id_Vi > 0)
                                {
                                    pReturn = objDoc.AppDocumentOtherDeletedByApp(pInfo.Id_Vi, language);
                                }
                                pReturn = objDoc.AppDocumentOtherInsertBatch(listDocument);
                            }
                        }
                    }
                    //end
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        scope.Complete();
                    }
                }

                return(Json(new { status = pAppHeaderID }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }
        public ActionResult AppDonDangKyInsert(ApplicationHeaderInfo pInfo, App_Detail_TM06DKQT_Info pDetail, List <AppDocumentInfo> pAppDocumentInfo,
                                               List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                //List<AppFeeFixInfo> pFeeFixInfo
                Application_Header_BL objBL          = new Application_Header_BL();
                AppDetail06DKQT_BL    objDetailBL    = new AppDetail06DKQT_BL();
                AppClassDetailBL      objClassDetail = new AppClassDetailBL();
                AppDocumentBL         objDoc         = new AppDocumentBL();
                AppFeeFixBL           objFeeFixBL    = new AppFeeFixBL();
                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;
                int    pReturn      = ErrorCode.Success;
                int    pAppHeaderID = 0;
                string p_case_code  = "";


                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;
                    if (pInfo.Created_By == null || pInfo.Created_By == "0" || pInfo.Created_By == "")
                    {
                        pInfo.Created_By = CreatedBy;
                    }
                    pInfo.Created_Date = CreatedDate;
                    //TRA RA ID CUA BANG KHI INSERT
                    pAppHeaderID = objBL.AppHeaderInsert(pInfo, ref p_case_code);
                    //Gán lại khi lấy dl
                    if (pAppHeaderID >= 0)
                    {
                        pReturn = objFeeFixBL.AppFeeFixInsertBath(pFeeFixInfo, p_case_code);
                    }
                    else
                    {
                        Transaction.Current.Rollback();
                    }
                    if (pReturn >= 0)
                    {
                        pDetail.Appcode       = pInfo.Appcode;
                        pDetail.LANGUAGE_CODE = language;
                        pDetail.APP_HEADER_ID = pAppHeaderID;
                        if (pDetail.pfileLogo != null)
                        {
                            pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                        }
                        pReturn = objDetailBL.App_Detail_06TMDKQT_Insert(pDetail);
                        //Thêm thông tin class
                        if (pReturn >= 0)
                        {
                            pReturn = objClassDetail.AppClassDetailInsertBatch(pAppClassInfo, pAppHeaderID, language);
                        }
                    }
                    //Tai lieu dinh kem
                    if (pReturn >= 0 && pAppDocumentInfo != null)
                    {
                        if (pAppDocumentInfo.Count > 0)
                        {
                            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;
                                }
                                info.App_Header_Id        = pAppHeaderID;
                                info.Document_Filing_Date = CommonFuc.CurrentDate();
                                info.Language_Code        = language;
                            }
                            pReturn = objDoc.AppDocumentInsertBath(pAppDocumentInfo, pAppHeaderID);
                        }
                    }

                    //tai lieu khac
                    //tai lieu khac
                    if (pReturn >= 0 && pAppDocOtherInfo != null && pAppDocOtherInfo.Count > 0)
                    {
                        #region Tài liệu khác
                        int check = 0;
                        foreach (var info in pAppDocOtherInfo)
                        {
                            string _keyfileupload = "";
                            if (info.keyFileUpload != null)
                            {
                                _keyfileupload = info.keyFileUpload;
                            }
                            if (SessionData.CurrentUser.chashFile.ContainsKey(_keyfileupload))
                            {
                                var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                if (_updateitem.GetType() == typeof(string))
                                {
                                    string _url = (string)_updateitem;
                                    info.Filename = _url;
                                    check         = 1;
                                }
                            }
                            info.App_Header_Id = pAppHeaderID;
                            info.Language_Code = language;
                        }
                        if (check == 1)
                        {
                            pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocOtherInfo);
                        }
                        #endregion
                    }
                    //end
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        scope.Complete();
                    }
                }

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