Example #1
0
        public decimal Insert(A01_Info pInfo)
        {
            try
            {
                OracleParameter paramReturn = new OracleParameter("p_return", OracleDbType.Decimal, ParameterDirection.Output);
                OracleHelper.ExecuteNonQuery(Configuration.connectionString, CommandType.StoredProcedure, "pkg_a01.Proc_App_Detail_A01_Insert",
                                             new OracleParameter("p_id", OracleDbType.Decimal, pInfo.Id, ParameterDirection.Input),
                                             new OracleParameter("p_case_code", OracleDbType.Varchar2, pInfo.Case_Code, ParameterDirection.Input),
                                             new OracleParameter("p_app_header_id", OracleDbType.Decimal, pInfo.App_Header_Id, ParameterDirection.Input),
                                             new OracleParameter("p_language_code", OracleDbType.Varchar2, pInfo.Language_Code, ParameterDirection.Input),
                                             new OracleParameter("p_appno", OracleDbType.Varchar2, pInfo.Appno, ParameterDirection.Input),
                                             new OracleParameter("p_patent_type", OracleDbType.Varchar2, pInfo.Patent_Type, ParameterDirection.Input),
                                             new OracleParameter("p_patent_name", OracleDbType.Varchar2, pInfo.Patent_Name, ParameterDirection.Input),
                                             new OracleParameter("p_source_pct", OracleDbType.Varchar2, pInfo.Source_PCT, ParameterDirection.Input),
                                             new OracleParameter("p_pct_number", OracleDbType.Varchar2, pInfo.PCT_Number, ParameterDirection.Input),
                                             new OracleParameter("p_pct_filling_date_qt", OracleDbType.Date, pInfo.PCT_Filling_Date_Qt, ParameterDirection.Input),
                                             new OracleParameter("p_pct_number_qt", OracleDbType.Varchar2, pInfo.PCT_Number_Qt, ParameterDirection.Input),
                                             new OracleParameter("p_pct_date", OracleDbType.Date, pInfo.PCT_Date, ParameterDirection.Input),
                                             new OracleParameter("p_pct_vn_date", OracleDbType.Date, pInfo.PCT_VN_Date, ParameterDirection.Input),
                                             new OracleParameter("p_pct_suadoi", OracleDbType.Decimal, pInfo.PCT_Suadoi, ParameterDirection.Input),
                                             new OracleParameter("p_pct_suadoi_name", OracleDbType.Varchar2, pInfo.PCT_Suadoi_Name, ParameterDirection.Input),
                                             new OracleParameter("p_pct_suadoi_address", OracleDbType.Varchar2, pInfo.PCT_Suadoi_Address, ParameterDirection.Input),
                                             new OracleParameter("p_pct_suadoi_others", OracleDbType.Varchar2, pInfo.PCT_Suadoi_Others, ParameterDirection.Input),
                                             new OracleParameter("p_pct_suadoi_content", OracleDbType.Varchar2, pInfo.PCT_Suadoi_Content, ParameterDirection.Input),
                                             new OracleParameter("p_source_dqsc", OracleDbType.Varchar2, pInfo.Source_DQSC, ParameterDirection.Input),
                                             new OracleParameter("p_dqsc_origin_app_no", OracleDbType.Varchar2, pInfo.DQSC_Origin_App_No, ParameterDirection.Input),
                                             new OracleParameter("p_dqsc_filling_date", OracleDbType.Date, pInfo.DQSC_Filling_Date, ParameterDirection.Input),
                                             new OracleParameter("p_dqsc_valid_before", OracleDbType.Decimal, pInfo.DQSC_Valid_Before, ParameterDirection.Input),
                                             new OracleParameter("p_dqsc_valid_after", OracleDbType.Decimal, pInfo.DQSC_Valid_After, ParameterDirection.Input),
                                             new OracleParameter("p_source_gphi", OracleDbType.Varchar2, pInfo.Source_GPHI, ParameterDirection.Input),
                                             new OracleParameter("p_gphi_origin_app_no", OracleDbType.Varchar2, pInfo.GPHI_Origin_App_No, ParameterDirection.Input),
                                             new OracleParameter("p_gphi_filling_date", OracleDbType.Date, pInfo.GPHI_Filling_Date, ParameterDirection.Input),
                                             new OracleParameter("p_gphi_valid_before", OracleDbType.Decimal, pInfo.GPHI_Valid_Before, ParameterDirection.Input),
                                             new OracleParameter("p_gphi_valid_after", OracleDbType.Decimal, pInfo.GPHI_Valid_After, ParameterDirection.Input),

                                             new OracleParameter("p_Point", OracleDbType.Decimal, pInfo.Point, ParameterDirection.Input),
                                             new OracleParameter("p_ThamDinhNoiDung", OracleDbType.Varchar2, pInfo.ThamDinhNoiDung, ParameterDirection.Input),
                                             new OracleParameter("p_ChuyenDoiDon", OracleDbType.Varchar2, pInfo.ChuyenDoiDon, ParameterDirection.Input),

                                             new OracleParameter("p_class_type", OracleDbType.Varchar2, pInfo.Class_Type, ParameterDirection.Input),
                                             new OracleParameter("p_class_content", OracleDbType.Varchar2, pInfo.Class_Content, ParameterDirection.Input),
                                             new OracleParameter("p_Used_Special", OracleDbType.Decimal, pInfo.Used_Special, ParameterDirection.Input),

                                             paramReturn);
                var result = Convert.ToDecimal(paramReturn.Value.ToString());
                return(result);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(ErrorCode.Error);
            }
        }
Example #2
0
 public decimal UpDate(A01_Info pInfo)
 {
     try
     {
         A01_DA _obj_da = new A01_DA();
         return(_obj_da.UpDate(pInfo));
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         return(ErrorCode.Error);
     }
 }
Example #3
0
        public ActionResult GetFee(A01_Info pDetail, List <AppDocumentInfo> pAppDocumentInfo, List <UTienInfo> pUTienInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A01(pDetail, pAppDocumentInfo, pUTienInfo, pLstImagePublic);
                ViewBag.LstFeeFix = _lstFeeFix;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            var PartialTableListFees = AppsCommon.RenderRazorViewToString(this.ControllerContext, "~/Areas/Patent/Views/Shared/_PartialTableListFees.cshtml");
            var json = Json(new { success = 1, PartialTableListFees });

            return(json);

            //return PartialView("~/Areas/Patent/Views/A01/_PartialTableListFees.cshtml");
        }
Example #4
0
        public A01_Info GetByID(decimal p_app_header_id, string p_language_code,
                                ref ApplicationHeaderInfo applicationHeaderInfo,
                                ref List <AppDocumentInfo> appDocumentInfos, ref List <AppFeeFixInfo> appFeeFixInfos,
                                ref List <AuthorsInfo> pAppAuthorsInfo, ref List <Other_MasterInfo> pOther_MasterInfo,
                                ref List <AppClassDetailInfo> appClassDetailInfos, ref List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                ref List <UTienInfo> pUTienInfo, ref List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                A01_DA   _obj_da   = new A01_DA();
                DataSet  dataSet   = _obj_da.GetByID(p_app_header_id, p_language_code);
                A01_Info _A01_Info = CBO <A01_Info> .FillObjectFromDataSet(dataSet);

                if (dataSet != null && dataSet.Tables.Count == 10)
                {
                    applicationHeaderInfo = CBO <ApplicationHeaderInfo> .FillObjectFromDataTable(dataSet.Tables[1]);

                    appDocumentInfos = CBO <AppDocumentInfo> .FillCollectionFromDataTable(dataSet.Tables[2]);

                    appFeeFixInfos = CBO <AppFeeFixInfo> .FillCollectionFromDataTable(dataSet.Tables[3]);

                    pOther_MasterInfo = CBO <Other_MasterInfo> .FillCollectionFromDataTable(dataSet.Tables[4]);

                    pAppAuthorsInfo = CBO <AuthorsInfo> .FillCollectionFromDataTable(dataSet.Tables[5]);

                    appClassDetailInfos = CBO <AppClassDetailInfo> .FillCollectionFromDataTable(dataSet.Tables[6]);

                    pAppDocOtherInfo = CBO <AppDocumentOthersInfo> .FillCollectionFromDataTable(dataSet.Tables[7]);

                    pUTienInfo = CBO <UTienInfo> .FillCollectionFromDataTable(dataSet.Tables[8]);

                    pLstImagePublic = CBO <AppDocumentOthersInfo> .FillCollectionFromDataTable(dataSet.Tables[9]);
                }

                return(_A01_Info);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(new A01_Info());
            }
        }
Example #5
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, A01_Info pDetail,
                                               List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo,
                                               List <AuthorsInfo> pAppAuthorsInfo, List <Other_MasterInfo> pOther_MasterInfo,
                                               List <AppClassDetailInfo> pAppClassInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                               List <UTienInfo> pUTienInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                string _datetimenow         = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language             = AppsCommon.GetCurrentLang();
                var    objBL                = new A01_BL();
                List <A01_Info_Export> _lst = new List <A01_Info_Export>();

                string p_appCode    = "A01_Preview";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "A01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "A01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "A01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "A01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "A01_EN_" + _datetimenow + ".pdf";
                }

                A01_Info_Export _A01_Info_Export = new A01_Info_Export();
                A01_Info_Export.CopyA01_Info(ref _A01_Info_Export, pDetail);


                // Phí cố định
                List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A01(pDetail, pAppDocumentInfo, pUTienInfo, pLstImagePublic);
                AppsCommon.Prepare_Data_Export_A01(ref _A01_Info_Export, pInfo, pAppDocumentInfo, _lstFeeFix, pAppAuthorsInfo, pOther_MasterInfo,
                                                   pAppClassInfo, pAppDocOtherInfo, pUTienInfo, pLstImagePublic);

                _lst.Add(_A01_Info_Export);
                DataSet _ds_all = ConvertData.ConvertToDataSet <A01_Info_Export>(_lst, false);
                //_ds_all.WriteXml(@"C:\inetpub\A01.xml", XmlWriteMode.WriteSchema);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "A01.rpt";
                if (language == Language.LangEN)
                {
                    _tempfile = "A01_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.Database.Tables["Table1"].SetDataSource(_ds_all.Tables[0]);
                    //oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

                System.IO.Stream oStream   = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Example #6
0
        public ActionResult Edit(ApplicationHeaderInfo pInfo, A01_Info pDetail,
                                 List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo,
                                 List <AuthorsInfo> pAppAuthorsInfo, List <Other_MasterInfo> pOther_MasterInfo,
                                 List <AppClassDetailInfo> pAppClassInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                 List <UTienInfo> pUTienInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                Application_Header_BL objBL       = new Application_Header_BL();
                AppFeeFixBL           objFeeFixBL = new AppFeeFixBL();
                A01_BL objDetail = new A01_BL();
                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;

                using (var scope = new TransactionScope())
                {
                    //
                    pInfo.Languague_Code = language;
                    pInfo.Modify_By      = CreatedBy;
                    pInfo.Modify_Date    = CreatedDate;
                    pInfo.Send_Date      = DateTime.Now;

                    //TRA RA ID CUA BANG KHI INSERT
                    pReturn = objBL.AppHeaderUpdate(pInfo);
                    if (pReturn < 0)
                    {
                        goto Commit_Transaction;
                    }

                    // detail
                    if (pReturn >= 0)
                    {
                        if (pDetail.Source_PCT == "Y")
                        {
                            pDetail.DQSC_Filling_Date = DateTime.MinValue;
                            pDetail.GPHI_Filling_Date = DateTime.MinValue;
                        }
                        else if (pDetail.Source_DQSC == "Y")
                        {
                            pDetail.GPHI_Filling_Date   = DateTime.MinValue;
                            pDetail.PCT_Date            = DateTime.MinValue;
                            pDetail.PCT_Filling_Date_Qt = DateTime.MinValue;
                            pDetail.PCT_VN_Date         = DateTime.MinValue;
                        }
                        else if (pDetail.Source_GPHI == "Y")
                        {
                            pDetail.DQSC_Filling_Date   = DateTime.MinValue;
                            pDetail.PCT_Date            = DateTime.MinValue;
                            pDetail.PCT_Filling_Date_Qt = DateTime.MinValue;
                            pDetail.PCT_VN_Date         = DateTime.MinValue;
                        }

                        pDetail.App_Header_Id = pInfo.Id;
                        pReturn = objDetail.UpDate(pDetail);
                        if (pReturn <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    Author_BL _Author_BL = new Author_BL();
                    _Author_BL.Deleted(pInfo.Case_Code, language);
                    if (pAppAuthorsInfo != null && pAppAuthorsInfo.Count > 0)
                    {
                        foreach (var item in pAppAuthorsInfo)
                        {
                            item.Case_Code     = pInfo.Case_Code;
                            item.App_Header_Id = pInfo.Id;
                        }
                        decimal _re = _Author_BL.Insert(pAppAuthorsInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    Other_Master_BL _Other_Master_BL = new Other_Master_BL();
                    _Other_Master_BL.Deleted(pInfo.Case_Code, language);
                    if (pOther_MasterInfo != null && pOther_MasterInfo.Count > 0)
                    {
                        foreach (var item in pOther_MasterInfo)
                        {
                            item.Case_Code     = pInfo.Case_Code;
                            item.App_Header_Id = pInfo.Id;
                        }

                        decimal _re = _Other_Master_BL.Insert(pOther_MasterInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    // xóa đi trước insert lại sau
                    Uu_Tien_BL _Uu_Tien_BL = new Uu_Tien_BL();
                    _Uu_Tien_BL.Deleted(pInfo.Case_Code, language);

                    if (pUTienInfo != null && pUTienInfo.Count > 0)
                    {
                        foreach (var item in pUTienInfo)
                        {
                            item.Case_Code     = pInfo.Case_Code;
                            item.App_Header_Id = pInfo.Id;
                        }

                        decimal _re = _Uu_Tien_BL.Insert(pUTienInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    //tai lieu khac
                    if (pReturn >= 0 && pAppDocOtherInfo != null)
                    {
                        AppDocumentBL objDoc = new AppDocumentBL();
                        List <AppDocumentOthersInfo> Lst_Doc_Others_Old             = objDoc.DocumentOthers_GetByAppHeader(pInfo.Id, language);
                        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(pInfo.Id, language);

                        if (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);
                            }
                        }
                    }

                    // hình công bố
                    if (pReturn >= 0 && pLstImagePublic != null)
                    {
                        if (pLstImagePublic.Count > 0)
                        {
                            AppImageBL _AppImageBL = new AppImageBL();

                            List <AppDocumentOthersInfo> Lst_ImagePublic_Old       = _AppImageBL.GetByAppHeader(pInfo.Id, language);
                            Dictionary <decimal, AppDocumentOthersInfo> _dic_image = new Dictionary <decimal, AppDocumentOthersInfo>();
                            foreach (AppDocumentOthersInfo item in Lst_ImagePublic_Old)
                            {
                                _dic_image[item.Id] = item;
                            }

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

                            int check = 0;
                            foreach (AppDocumentOthersInfo info in pLstImagePublic)
                            {
                                if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                                {
                                    string _url = (string)SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    info.Filename = _url;
                                    check         = 1;
                                }
                                else if (_dic_image.ContainsKey(info.Id))
                                {
                                    info.Filename = _dic_image[info.Id].Filename;
                                    check         = 1;
                                }

                                info.App_Header_Id = pInfo.Id;
                                info.Language_Code = language;
                            }

                            if (check == 1)
                            {
                                pReturn = _AppImageBL.AppImageInsertBatch(pLstImagePublic);
                            }
                        }
                    }

                    #region Phí cố định
                    // xóa đi
                    AppFeeFixBL _AppFeeFixBL = new AppFeeFixBL();
                    _AppFeeFixBL.AppFeeFixDelete(pInfo.Case_Code, language);

                    List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A01(pDetail, pAppDocumentInfo, pUTienInfo, pLstImagePublic);
                    if (_lstFeeFix.Count > 0)
                    {
                        pReturn = _AppFeeFixBL.AppFeeFixInsertBath(_lstFeeFix, pInfo.Case_Code);
                        if (pReturn < 0)
                        {
                            goto Commit_Transaction;
                        }
                    }
                    #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 = _AppDocumentBL.AppDocumentInsertBath(pAppDocumentInfo, pInfo.Id);
                        }
                    }
                    #endregion

                    //end
Commit_Transaction:
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return(Json(new { status = pReturn }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }
Example #7
0
        public ActionResult Register(ApplicationHeaderInfo pInfo, A01_Info pDetail,
                                     List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo,
                                     List <AuthorsInfo> pAppAuthorsInfo, List <Other_MasterInfo> pOther_MasterInfo,
                                     List <AppClassDetailInfo> pAppClassInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                     List <UTienInfo> pUTienInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                Application_Header_BL objBL       = new Application_Header_BL();
                AppFeeFixBL           objFeeFixBL = new AppFeeFixBL();
                A01_BL          objDetail         = new A01_BL();
                AppDocumentBL   objDoc            = new AppDocumentBL();
                Other_Master_BL _Other_Master_BL  = new Other_Master_BL();
                Author_BL       _Author_BL        = new Author_BL();

                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;
                int     pAppHeaderID = 0;
                string  p_case_code  = "";

                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;
                    pInfo.Send_Date    = DateTime.Now;

                    //TRA RA ID CUA BANG KHI INSERT
                    pAppHeaderID = objBL.AppHeaderInsert(pInfo, ref p_case_code);
                    if (pAppHeaderID < 0)
                    {
                        goto Commit_Transaction;
                    }

                    // detail
                    if (pAppHeaderID >= 0)
                    {
                        pDetail.Appcode       = pInfo.Appcode;
                        pDetail.Language_Code = language;
                        pDetail.App_Header_Id = pAppHeaderID;
                        pDetail.Case_Code     = p_case_code;

                        if (pDetail.Source_PCT == "Y")
                        {
                            pDetail.DQSC_Filling_Date = DateTime.MinValue;
                            pDetail.GPHI_Filling_Date = DateTime.MinValue;
                        }
                        else if (pDetail.Source_DQSC == "Y")
                        {
                            pDetail.GPHI_Filling_Date   = DateTime.MinValue;
                            pDetail.PCT_Date            = DateTime.MinValue;
                            pDetail.PCT_Filling_Date_Qt = DateTime.MinValue;
                            pDetail.PCT_VN_Date         = DateTime.MinValue;
                        }
                        else if (pDetail.Source_GPHI == "Y")
                        {
                            pDetail.DQSC_Filling_Date   = DateTime.MinValue;
                            pDetail.PCT_Date            = DateTime.MinValue;
                            pDetail.PCT_Filling_Date_Qt = DateTime.MinValue;
                            pDetail.PCT_VN_Date         = DateTime.MinValue;
                        }

                        pReturn = objDetail.Insert(pDetail);
                        if (pReturn <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    if (pAppAuthorsInfo != null && pAppAuthorsInfo.Count > 0)
                    {
                        foreach (var item in pAppAuthorsInfo)
                        {
                            item.Case_Code     = p_case_code;
                            item.App_Header_Id = pAppHeaderID;
                        }
                        decimal _re = _Author_BL.Insert(pAppAuthorsInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }

                        ////Thêm thông tin class
                        //if (pAppClassInfo != null)
                        //{
                        //    AppClassDetailBL objClassDetail = new AppClassDetailBL();
                        //    pReturn = objClassDetail.AppClassDetailInsertBatch(pAppClassInfo, pAppHeaderID, language);
                        //}
                    }

                    if (pOther_MasterInfo != null && pOther_MasterInfo.Count > 0)
                    {
                        foreach (var item in pOther_MasterInfo)
                        {
                            item.Case_Code     = p_case_code;
                            item.App_Header_Id = pAppHeaderID;
                        }

                        decimal _re = _Other_Master_BL.Insert(pOther_MasterInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    if (pUTienInfo != null && pUTienInfo.Count > 0)
                    {
                        foreach (var item in pUTienInfo)
                        {
                            item.Case_Code     = p_case_code;
                            item.App_Header_Id = pAppHeaderID;
                        }

                        Uu_Tien_BL _Uu_Tien_BL = new Uu_Tien_BL();
                        decimal    _re         = _Uu_Tien_BL.Insert(pUTienInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    //tai lieu khac
                    if (pReturn >= 0 && pAppDocOtherInfo != null)
                    {
                        if (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;
                                }
                                info.App_Header_Id = pAppHeaderID;
                                info.Language_Code = language;
                            }
                            if (check == 1)
                            {
                                pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocOtherInfo);
                            }
                        }
                    }

                    // hình công bố
                    if (pReturn >= 0 && pLstImagePublic != null)
                    {
                        if (pLstImagePublic.Count > 0)
                        {
                            int check = 0;
                            foreach (var info in pLstImagePublic)
                            {
                                if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                                {
                                    string _url = (string)SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    info.Filename = _url;
                                    check         = 1;
                                }
                                info.App_Header_Id = pAppHeaderID;
                                info.Language_Code = language;
                            }
                            if (check == 1)
                            {
                                AppImageBL _AppImageBL = new AppImageBL();
                                pReturn = _AppImageBL.AppImageInsertBatch(pLstImagePublic);
                            }
                        }
                    }

                    #region Phí cố định
                    List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A01(pDetail, pAppDocumentInfo, pUTienInfo, pLstImagePublic);
                    if (_lstFeeFix.Count > 0)
                    {
                        AppFeeFixBL _AppFeeFixBL = new AppFeeFixBL();
                        pReturn = _AppFeeFixBL.AppFeeFixInsertBath(_lstFeeFix, p_case_code);
                        if (pReturn < 0)
                        {
                            goto Commit_Transaction;
                        }
                    }
                    #endregion

                    #region 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);
                        }
                    }
                    #endregion

                    //end
Commit_Transaction:
                    if (pReturn < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return(Json(new { status = pReturn }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }