Beispiel #1
0
        public ActionResult Edit_Pages(Sys_Pages_Info p_Sys_Pages_Info)
        {
            try
            {
                if (p_Sys_Pages_Info == null)
                {
                    return(Json(new { status = -99 }));
                }

                string language     = AppsCommon.GetCurrentLang();
                var    ModifiedBy   = SessionData.CurrentUser.Username;
                var    ModifiedDate = CommonFuc.CurrentDate();
                if (p_Sys_Pages_Info.pfileLogo != null)
                {
                    p_Sys_Pages_Info.Imageheader = AppLoadHelpers.PushFileToServer(p_Sys_Pages_Info.pfileLogo, AppUpload.Logo);
                }
                p_Sys_Pages_Info.Modified_By = SessionData.CurrentUser.Username;
                var     objBL   = new Sys_Pages_BL();
                decimal preturn = objBL.Sys_Pages_Update(p_Sys_Pages_Info);
                if (preturn >= 0)
                {
                    MemoryData.Load_Sys_page();
                }
                return(Json(new { status = preturn }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult DoEdit(Docking_Info p_Docking_Info)
        {
            try
            {
                Docking_BL _obj_bl = new Docking_BL();
                p_Docking_Info.Modify_By     = SessionData.CurrentUser.Username;
                p_Docking_Info.Modify_Date   = DateTime.Now;
                p_Docking_Info.Language_Code = AppsCommon.GetCurrentLang();
                p_Docking_Info.Document_Name = p_Docking_Info.Document_Name_Type + p_Docking_Info.Document_Name_Other;

                if (p_Docking_Info.File_Upload != null)
                {
                    var url_File_Upload = AppLoadHelpers.PushFileToServer(p_Docking_Info.File_Upload, AppUpload.Document);
                    p_Docking_Info.FileName = p_Docking_Info.File_Upload.FileName;
                    p_Docking_Info.Url      = url_File_Upload;
                }
                else
                {
                    p_Docking_Info.FileName = "NA";
                    p_Docking_Info.Url      = "NA";
                }

                decimal _ck = _obj_bl.Docking_Update(p_Docking_Info);
                return(Json(new { success = _ck }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = "-1" }));
            }
        }
        public ActionResult ExecuteNewsArticles(NewsInfo pNewsInfo)
        {
            try
            {
                if (SessionData.CurrentUser == null)
                {
                    return(Redirect("/"));
                }

                decimal preturn = 0;
                if (pNewsInfo == null)
                {
                    return(Json(new { status = -99 }));
                }
                string language     = AppsCommon.GetCurrentLang();
                var    ModifiedBy   = SessionData.CurrentUser == null ? "" : SessionData.CurrentUser.Username;
                var    ModifiedDate = CommonFuc.CurrentDate();
                if (pNewsInfo.pfileLogo != null)
                {
                    pNewsInfo.Imageheader = AppLoadHelpers.PushFileToServer(pNewsInfo.pfileLogo, AppUpload.Logo);
                }
                pNewsInfo.Languagecode = language;
                pNewsInfo.Modifiedby   = ModifiedBy;
                pNewsInfo.Modifieddate = ModifiedDate;
                var objNewsBL = new NewsBL();
                preturn = objNewsBL.ArticlesUpdate(pNewsInfo);

                return(Json(new { status = preturn }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(View());
            }
        }
Beispiel #4
0
        public ActionResult UpdateRepEmail(ContactInfo _contact)
        {
            decimal _ck = -1;

            try
            {
                decimal _status = 1;
                if (_contact.FileBase_File_Url != null)
                {
                    _contact.URL = AppLoadHelpers.PushFileToServer(_contact.FileBase_File_Url, AppUpload.Search);
                }
                if (_contact.FileBase_File_Url02 != null)
                {
                    _contact.URL01 = AppLoadHelpers.PushFileToServer(_contact.FileBase_File_Url02, AppUpload.Search);
                }
                Contact_BL _bl = new Contact_BL();
                // update trạng thái phản hồi status = 1 và nội jdung phản hồi
                _ck = _bl.Contact_UpdateStatus(_contact.ID, _status, _contact.ReplyContent, _contact.ReplySubject, SessionData.CurrentUser.Username, _contact.URL, _contact.URL01);
                if (_ck > 0)
                {
                    string        _content       = _contact.ReplyContent.Replace("\n", "<br><br>");
                    List <string> _LstAttachment = new List <string>();
                    if (_contact.URL != null)
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_contact.URL));
                    }
                    if (_contact.URL01 != null)
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_contact.URL01));
                    }
                    string     content     = AppsCommon.SetContentMailTemplate(_content, yourref: "", outref: _contact.Case_Code, dearname: _contact.ContactName);
                    Email_Info _Email_Info = new Email_Info
                    {
                        EmailFrom     = EmailHelper.EmailOriginal.EMailFrom_Business,
                        Pass          = EmailHelper.EmailOriginal.PassWord_Business,
                        Display_Name  = EmailHelper.EmailOriginal.DisplayName_Business,
                        EmailTo       = _contact.Email,
                        EmailCC       = "",
                        Subject       = _contact.ReplySubject,
                        Content       = content,
                        LstAttachment = _LstAttachment,
                    };
                    CommonFunction.AppsCommon.EnqueueSendEmail(_Email_Info);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(Json(new { status = _ck }));
        }
Beispiel #5
0
        public ActionResult do_SendEmail(Email_Info pInfo)
        {
            try
            {
                List <string> _LstAttachment = new List <string>();
                if (pInfo.File_Attach_1 != null)
                {
                    var _url_File_Attach_1 = AppLoadHelpers.PushFileToServer(pInfo.File_Attach_1, AppUpload.App);
                    _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_url_File_Attach_1));
                }

                if (pInfo.File_Attach_2 != null)
                {
                    var _url_File_Attach_2 = AppLoadHelpers.PushFileToServer(pInfo.File_Attach_2, AppUpload.App);
                    _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_url_File_Attach_2));
                }

                pInfo.LstAttachment = _LstAttachment;

                if (pInfo.EmailFrom == "*****@*****.**")
                {
                    pInfo.EmailFrom    = EmailHelper.EmailOriginal.EMailFrom_Business;
                    pInfo.Pass         = EmailHelper.EmailOriginal.PassWord_Business;
                    pInfo.Display_Name = EmailHelper.EmailOriginal.DisplayName_Business;
                }
                else
                {
                    pInfo.EmailFrom    = EmailHelper.EmailOriginal.EMailFrom;
                    pInfo.Pass         = EmailHelper.EmailOriginal.PassWord;
                    pInfo.Display_Name = EmailHelper.EmailOriginal.DisplayName;
                }

                string _content = pInfo.Content.Replace("<br />", "<br /><br />");  //.Replace("\n", "<br><br>");


                _content = AppsCommon.SetContentMailTemplate(_content, yourref: pInfo.Your_Ref, outref: pInfo.Out_Ref,
                                                             dearname: pInfo.Customer_Name, p_namereply: pInfo.Sign, p_position_name: pInfo.Position);
                pInfo.Content = _content;

                pInfo.Created_by = SessionData.CurrentUser.Username;
                CommonFunction.AppsCommon.EnqueueSendEmail(pInfo);

                return(Json(new { success = 1 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = "-1" }));
            }
        }
 public ActionResult PushFileToServer(AppDocumentInfo pInfo)
 {
     try
     {
         if (pInfo.pfiles != null)
         {
             var url = AppLoadHelpers.PushFileToServer(pInfo.pfiles, AppUpload.Document);
             SessionData.CurrentUser.chashFile[pInfo.keyFileUpload] = pInfo.pfiles;
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         return(Json(new { success = -1 }));
     }
     return(Json(new { success = 0 }));
 }
        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 }));
            }
        }
Beispiel #8
0
        public ActionResult DoSearchResult(SearchObject_Question_Info p_SearchObject_Header_Info, Billing_Header_Info p_Billing_Header_Info)
        {
            try
            {
                List <Billing_Detail_Info> _lst_billing_detail = AppsCommon.Get_LstFee_Detail(p_SearchObject_Header_Info.CASE_CODE);
                decimal _ck         = 0;
                decimal _billing_id = 0;
                using (var scope = new TransactionScope())
                {
                    p_SearchObject_Header_Info.LANGUAGE_CODE = AppsCommon.GetCurrentLang();
                    p_SearchObject_Header_Info.MODIFIED_BY   = SessionData.CurrentUser.Username;
                    p_SearchObject_Header_Info.MODIFIED_DATE = DateTime.Now;

                    p_SearchObject_Header_Info.FILE_URL   = AppLoadHelpers.PushFileToServer(p_SearchObject_Header_Info.FileBase_File_Url, AppUpload.Search);
                    p_SearchObject_Header_Info.FILE_URL02 = AppLoadHelpers.PushFileToServer(p_SearchObject_Header_Info.FileBase_File_Url02, AppUpload.Search);

                    SearchObject_BL _con = new SearchObject_BL();
                    _ck = _con.SEARCH_RESULT_SEARCH(p_SearchObject_Header_Info);

                    if (_ck < 0)
                    {
                        goto Commit_Transaction;
                    }

                    // insert billing
                    // lấy thông tin cũ
                    if (_lst_billing_detail.Count == 0)
                    {
                        goto Commit_Transaction;
                    }

                    SearchObject_BL            _SearchObject_BL     = new SearchObject_BL();
                    List <Billing_Detail_Info> _lst_detail          = new List <Billing_Detail_Info>();
                    SearchObject_Header_Info   objSearch_HeaderInfo = _SearchObject_BL.GetBilling_By_Case_Code(p_SearchObject_Header_Info.CASE_CODE, SessionData.CurrentUser.Username,
                                                                                                               AppsCommon.GetCurrentLang(), ref _lst_detail);

                    Billing_BL _obj_bl = new Billing_BL();
                    p_Billing_Header_Info.Created_By    = SessionData.CurrentUser.Username;
                    p_Billing_Header_Info.Created_Date  = DateTime.Now;
                    p_Billing_Header_Info.Language_Code = AppsCommon.GetCurrentLang();
                    p_Billing_Header_Info.Status        = (decimal)CommonEnums.Billing_Status.New_Wait_Approve;
                    p_Billing_Header_Info.Billing_Type  = (decimal)CommonEnums.Billing_Type.Search;
                    p_Billing_Header_Info.Notes         = "Billing for case code " + p_SearchObject_Header_Info.CASE_CODE; // + " - " + p_SearchObject_Header_Info.NOTE;

                    p_Billing_Header_Info.Case_Code     = _obj_bl.Billing_GenCaseCode();
                    p_Billing_Header_Info.App_Case_Code = p_SearchObject_Header_Info.CASE_CODE;

                    p_Billing_Header_Info.Billing_Date = DateTime.Now;
                    p_Billing_Header_Info.Deadline     = DateTime.Now.AddDays(30);

                    p_Billing_Header_Info.Request_By = SessionData.CurrentUser.Username;
                    p_Billing_Header_Info.Approve_By = "";


                    decimal _Total_Amount_Represent = 0;
                    decimal _Total_Amount_Temp      = 0;

                    decimal            _Percent_discount = 0;
                    List <AllCodeInfo> _lstDiscount      = WebApps.CommonFunction.AppsCommon.AllCode_GetBy_CdTypeCdName("DISCOUNT", "SERVICE");
                    if (_lstDiscount.Count > 0)
                    {
                        _Percent_discount = Convert.ToDecimal(_lstDiscount[0].CdVal);
                    }

                    foreach (Billing_Detail_Info item in _lst_billing_detail)
                    {
                        _Total_Amount_Represent = _Total_Amount_Represent + item.Represent_Fee;
                        _Total_Amount_Temp      = _Total_Amount_Temp + item.Total_Fee;
                    }

                    decimal _discount = Math.Round(_Total_Amount_Represent * _Percent_discount / 100);
                    p_Billing_Header_Info.Total_Pre_Tex = _Total_Amount_Temp - _discount;

                    p_Billing_Header_Info.Tex_Fee      = Math.Round(p_Billing_Header_Info.Total_Pre_Tex / 100 * Common.Common.Tax);
                    p_Billing_Header_Info.Total_Amount = p_Billing_Header_Info.Total_Pre_Tex + p_Billing_Header_Info.Tex_Fee;

                    p_Billing_Header_Info.Currency      = objSearch_HeaderInfo.Currency_Type;
                    p_Billing_Header_Info.Currency_Rate = AppsCommon.Get_Currentcy_VCB();

                    p_Billing_Header_Info.Insert_Type = (decimal)Common.CommonData.CommonEnums.Billing_Insert_Type.Search;

                    p_Billing_Header_Info.Discount_Fee_Service = _discount;
                    p_Billing_Header_Info.Percent_Discount     = _Percent_discount;
                    p_Billing_Header_Info.Currency_Rate        = AppsCommon.Get_Currentcy_VCB();

                    _billing_id = _obj_bl.Billing_Insert(p_Billing_Header_Info);

                    if (_billing_id > 0 && _lst_billing_detail.Count > 0)
                    {
                        _ck = _obj_bl.Billing_Detail_InsertBatch(_lst_billing_detail, _billing_id);
                    }

                    if (_ck > 0 && p_Billing_Header_Info.Insert_Type == (decimal)Common.CommonData.CommonEnums.Billing_Insert_Type.Search)
                    {
                        //string _fileExport = AppsCommon.Export_Billing(p_Billing_Header_Info.Case_Code);

                        string _mapPath_Report = Server.MapPath("~/Report/");
                        string _mapPath        = Server.MapPath("~/");

                        string _fileExport = AppsCommon.Export_Billing_Crytal(p_Billing_Header_Info.Case_Code, _mapPath_Report, _mapPath, objSearch_HeaderInfo.CREATED_BY, p_Billing_Header_Info, _lst_billing_detail);
                        if (_fileExport == "")
                        {
                            goto Commit_Transaction;
                        }

                        SearchObject_BL _bl = new SearchObject_BL();
                        _ck = _bl.Update_Url_Billing(p_Billing_Header_Info.App_Case_Code, _billing_id, _fileExport);

                        // insert vào docking
                        AppsCommon.Insert_Docketing(p_Billing_Header_Info.Case_Code, "Report Billing", _fileExport, true);
                    }

                    //end
Commit_Transaction:
                    if (_ck < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        SessionData.RemoveDataSession(p_SearchObject_Header_Info.CASE_CODE);
                        scope.Complete();
                    }
                }
                return(Json(new { success = _ck }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = "-1" }));
            }
        }
Beispiel #9
0
        public ActionResult SearchEdit(SearchObject_Header_Info p_searchHeaderInfo, List <SearchObject_Detail_Info> p_SearchObject_Detail_Info,
                                       SearchObject_Question_Info p_questionInfo, List <Search_Class_Info> pAppClassInfo)
        {
            decimal _rel = 0;

            try
            {
                using (var scope = new TransactionScope())
                {
                    SearchObject_BL _searchBL = new SearchObject_BL();
                    p_searchHeaderInfo.MODIFIED_BY   = SessionData.CurrentUser.Username;
                    p_searchHeaderInfo.MODIFIED_DATE = DateTime.Now;
                    p_searchHeaderInfo.REQUEST_DATE  = DateTime.Now;

                    var url_File_Atachment = "";
                    if (p_searchHeaderInfo.Url_File_Up != null)
                    {
                        url_File_Atachment          = AppLoadHelpers.PushFileToServer(p_searchHeaderInfo.Url_File_Up, AppUpload.Search);
                        p_searchHeaderInfo.Url_File = url_File_Atachment;
                    }
                    else
                    {
                        p_searchHeaderInfo.Url_File = "NA";
                    }

                    //HungTD
                    if (p_searchHeaderInfo.Object_Search == Common.CommonData.Search_Object_Enum.Trademark)
                    {
                        if (p_searchHeaderInfo.pfileLogo != null)
                        {
                            p_searchHeaderInfo.Logourl = AppLoadHelpers.PushFileToServer(p_searchHeaderInfo.pfileLogo, AppUpload.Logo);
                        }
                        else
                        {
                            p_searchHeaderInfo.Logourl = p_searchHeaderInfo.LogourlOrg;
                        }
                        if (p_searchHeaderInfo.Logochu != 1)
                        {
                            //pDetail.Logochu = 0;
                            if (p_searchHeaderInfo.pfileLogo != null)
                            {
                                p_searchHeaderInfo.Logourl = AppLoadHelpers.PushFileToServer(p_searchHeaderInfo.pfileLogo, AppUpload.Logo);
                            }
                        }
                        else
                        {
                            p_searchHeaderInfo.Logourl = p_searchHeaderInfo.ChuLogo;
                            p_searchHeaderInfo.Logochu = 1;
                        }
                        //End HungTD
                    }

                    _rel = _searchBL.SEARCH_HEADER_UPDATE(p_searchHeaderInfo);
                    if (_rel < 0)
                    {
                        return(Json(new { success = _rel }));
                    }

                    p_questionInfo.SEARCH_ID = p_searchHeaderInfo.SEARCH_ID;
                    _rel = _searchBL.SEARCH_QUESTION_UPDATE(p_questionInfo);
                    if (_rel < 0)
                    {
                        goto Commit_Transaction;
                    }

                    // detail
                    if (p_SearchObject_Detail_Info == null)
                    {
                        p_SearchObject_Detail_Info = new List <SearchObject_Detail_Info>();
                    }
                    if (p_SearchObject_Detail_Info.Count > 0)
                    {
                        foreach (SearchObject_Detail_Info item in p_SearchObject_Detail_Info)
                        {
                            item.SEARCH_ID     = p_searchHeaderInfo.SEARCH_ID;
                            item.SEARCH_OBJECT = p_searchHeaderInfo.Object_Search;
                        }
                        _searchBL.SEARCH_DETAIL_DELETE(p_searchHeaderInfo.SEARCH_ID);
                        _rel = _searchBL.SEARCH_DETAIL_INSERT(p_SearchObject_Detail_Info);
                        if (_rel < 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    //Thêm thông tin class
                    if (pAppClassInfo != null)
                    {
                        _rel = _searchBL.Search_Class_Delete(p_searchHeaderInfo.SEARCH_ID, AppsCommon.GetCurrentLang());
                        _rel = _searchBL.Search_Class_InsertBatch(pAppClassInfo, p_searchHeaderInfo.SEARCH_ID, AppsCommon.GetCurrentLang());
                    }

                    if (_rel < 0)
                    {
                        goto Commit_Transaction;
                    }

                    // thông tin thằng fee
                    List <Search_Fix_Info> _lstFee = new List <Search_Fix_Info>();
                    string _keyFee = "";

                    foreach (var item in p_SearchObject_Detail_Info)
                    {
                        Search_Fix_Info _Search_Fix_Info = new Search_Fix_Info();
                        _Search_Fix_Info.Search_Object = item.SEARCH_OBJECT;
                        _Search_Fix_Info.Search_Type   = item.SEARCH_TYPE;
                        _Search_Fix_Info.Country_Id    = p_searchHeaderInfo.Country_Id;
                        if (pAppClassInfo != null)
                        {
                            List <Search_Class_Info> list = pAppClassInfo
                                                            .GroupBy(a => a.Code)
                                                            .Select(g => g.First())
                                                            .ToList();

                            _Search_Fix_Info.Number_Of_Class = list.Count();
                        }
                        else
                        {
                            _Search_Fix_Info.Number_Of_Class = 0;
                        }

                        _keyFee = p_searchHeaderInfo.Country_Id.ToString() + "_" + item.SEARCH_OBJECT.ToString() + "_" + item.SEARCH_TYPE.ToString();

                        if (MemoryData.c_dic_FeeBySearch.ContainsKey(_keyFee))
                        {
                            if (_Search_Fix_Info.Number_Of_Class == 0)
                            {
                                _Search_Fix_Info.Amount     = MemoryData.c_dic_FeeBySearch[_keyFee].Amount;
                                _Search_Fix_Info.Amount_usd = MemoryData.c_dic_FeeBySearch[_keyFee].Amount_usd;
                            }
                            else
                            {
                                _Search_Fix_Info.Amount     = MemoryData.c_dic_FeeBySearch[_keyFee].Amount * _Search_Fix_Info.Number_Of_Class;
                                _Search_Fix_Info.Amount_usd = MemoryData.c_dic_FeeBySearch[_keyFee].Amount_usd * _Search_Fix_Info.Number_Of_Class;
                            }
                        }
                        else
                        {
                            _Search_Fix_Info.Amount = 0;
                        }

                        _lstFee.Add(_Search_Fix_Info);
                    }

                    _rel = _searchBL.Search_Fee_Delete(p_searchHeaderInfo.SEARCH_ID, AppsCommon.GetCurrentLang());
                    if (_lstFee.Count > 0)
                    {
                        _rel = _searchBL.Search_Fee_InsertBatch(_lstFee, p_searchHeaderInfo.SEARCH_ID, AppsCommon.GetCurrentLang());
                    }

                    //end
Commit_Transaction:
                    if (_rel < 0)
                    {
                        Transaction.Current.Rollback();
                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return(Json(new { success = _rel }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(Json(new { success = _rel }));
        }
Beispiel #10
0
        public ActionResult Register(ApplicationHeaderInfo pInfo, C07_Info pDetail,
            List<AppDocumentInfo> pAppDocumentInfo, List<AppFeeFixInfo> pFeeFixInfo,
             List<Other_MasterInfo> pOther_MasterInfo,
             List<AppDocumentOthersInfo> pAppDocOtherInfo, List<AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                Application_Header_BL objBL = new Application_Header_BL();
                AppFeeFixBL objFeeFixBL = new AppFeeFixBL();
                C07_BL objDetail = new C07_BL();
                AppDocumentBL objDoc = new AppDocumentBL();
                Other_Master_BL _Other_Master_BL = new Other_Master_BL();
                Author_BL _Author_BL = new Author_BL();
                AppClassDetailBL objClassDetail = new AppClassDetailBL();
                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.pfileLogo != null)
                        {
                            pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                        }
                        pReturn = objDetail.Insert(pDetail);


                        if (pReturn < 0)
                            goto Commit_Transaction;
                        // thêm thông tin class
                        pReturn = objClassDetail.AppClassDetailInsertBatch(pAppClassInfo, pAppHeaderID, language);
                        if (pReturn < 0)
                            goto Commit_Transaction;
                    }

                    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;
                    }


                    //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
                    }



                    #region tính phí
                    List<AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_C07(pDetail, pAppClassInfo);
                    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))
                                {
                                    var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    if (_updateitem.GetType() == typeof(string))
                                    {
                                        string _url = (string)_updateitem;
                                        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();
                        return Json(new { status = -1 });

                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return Json(new { status = pAppHeaderID });

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return Json(new { status = ErrorCode.Error });
            }
        }
Beispiel #11
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, C07_Info pDetail,
           List<AppDocumentInfo> pAppDocumentInfo,
           List<AppFeeFixInfo> pFeeFixInfo,
           List<Other_MasterInfo> pOther_MasterInfo,
           List<AppClassDetailInfo> pAppClassInfo,
           List<AppDocumentOthersInfo> pAppDocOtherInfo 
           )
        {
            try
            {
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language = AppsCommon.GetCurrentLang();
                var objBL = new C07_BL();
                List<C07_Info_Export> _lst = new List<C07_Info_Export>();

                string p_appCode = "C07_Preview";

                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C07_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C07_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C07_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C07_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C07_EN_" + _datetimenow + ".pdf";
                }
                // đẩy file lên server
                if (pDetail.pfileLogo != null)
                {
                    pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                }
                C07_Info_Export _C07_Info_Export = new C07_Info_Export();

                C07_Info_Export.CopyC07_Info(ref _C07_Info_Export, pDetail);

                _C07_Info_Export.LOGOURL = Server.MapPath(_C07_Info_Export.LOGOURL);

                // Phí cố định

                List<AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_C07(pDetail, pAppClassInfo);
                Prepare_Data_Export_C07(ref _C07_Info_Export, pInfo, pAppDocumentInfo, _lstFeeFix, pOther_MasterInfo,
                       pAppDocOtherInfo, pAppClassInfo);

                _lst.Add(_C07_Info_Export);
                DataSet _ds_all = ConvertData.ConvertToDataSet<C07_Info_Export>(_lst, false);
                try
                {
                    _ds_all.WriteXml(@"C:\inetpub\C07.xml", XmlWriteMode.WriteSchema);
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "C07.rpt";
                if (pInfo.View_Language_Report == Language.LangEN)
                {
                    _tempfile = "C07_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));
                #region Set vị trí ảnh

                CrystalDecisions.CrystalReports.Engine.PictureObject _pic01;
                _pic01 = (CrystalDecisions.CrystalReports.Engine.PictureObject)oRpt.ReportDefinition.Sections[0].ReportObjects["Picture1"];
                _pic01.Width = 200;
                _pic01.Height = 200;
                try
                {
                    pDetail.LOGOURL = Server.MapPath(pDetail.LOGOURL);
                    Bitmap img = new Bitmap(pDetail.LOGOURL);
                    try
                    {

                        double _Const = 6.666666666666/2;
                        int _left = 0, _top = 0, _marginleft = 225, _margintop = 5580;
                        int _h = 600;
                        double _d1 = (_h - img.Width) / 2;
                        _d1 = _Const * _d1;
                        _left = _marginleft + Convert.ToInt32(_d1);
                        if (_left < 0)
                        {
                            _left = _marginleft;
                        }
                        _pic01.Left = _left;
                        // top

                        _d1 = (_h - img.Height) / 2;
                        _d1 = _Const * _d1;
                        _top = _margintop + Convert.ToInt32(_d1);
                        if (_top < 0)
                        {
                            _top = _margintop;
                        }
                        _pic01.Top = _top;

                    }
                    catch (Exception ex)
                    {
                        Logger.LogException(ex);
                    }
                    finally
                    {
                        img.Dispose();
                    }
                }
                catch (Exception)
                {


                }

                System.IO.FileInfo file = new System.IO.FileInfo(pDetail.LOGOURL);

                #endregion
                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

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


                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 });
            }
        }
Beispiel #12
0
        public ActionResult Edit(ApplicationHeaderInfo pInfo, C07_Info pDetail,
            List<AppDocumentInfo> pAppDocumentInfo, List<AppFeeFixInfo> pFeeFixInfo, List<Other_MasterInfo> pOther_MasterInfo,
             List<AppDocumentOthersInfo> pAppDocOtherInfo, List<AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                Application_Header_BL objBL = new Application_Header_BL();
                AppFeeFixBL objFeeFixBL = new AppFeeFixBL();
                C07_BL objDetail = new C07_BL();
                AppClassDetailBL objClassDetail = new AppClassDetailBL();
                if (pInfo == null || pDetail == null) return Json(new { status = ErrorCode.Error });
                string language = AppsCommon.GetCurrentLang();
                decimal pReturn = ErrorCode.Success;
                int pAppHeaderID = (int)pInfo.Id;
                string p_case_code = pInfo.Case_Code;

                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 = "";
                    //TRA RA ID CUA BANG KHI INSERT
                    pReturn = objBL.AppHeaderUpdate(pInfo);
                    if (pReturn < 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.pfileLogo != null)
                        {
                            pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                        }
                        else
                        {
                            pDetail.LOGOURL = pDetail.IMG_URLOrg;
                        }
                        pReturn = objDetail.UpDate(pDetail);

                        if (pReturn < 0)
                            goto Commit_Transaction;

                        #region  Thêm thông tin class
                        if (pReturn >= 0 && pAppClassInfo != null)
                        {

                            //Xoa cac class cu di 
                            pReturn = objClassDetail.AppClassDetailDeleted(pInfo.Id, language);
                            if (pReturn < 0)
                                goto Commit_Transaction;

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

                            if (pReturn < 0)
                                goto Commit_Transaction;
                        }
                        #endregion

                    }



                    // ok 
                    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 = pAppHeaderID;
                        }

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




                    //tai lieu khac 
                    #region Tài liệu khác
                    AppDocumentBL 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 = pAppHeaderID;
                            info.Language_Code = language;
                        }
                        if (check == 1)
                        {
                            pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocOtherInfo);
                        }
                    }
                    #endregion


                    #region tính phí
                    // xóa đi
                    AppFeeFixBL _AppFeeFixBL = new AppFeeFixBL();
                    _AppFeeFixBL.AppFeeFixDelete(pInfo.Case_Code, language);

                    List<AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_C07(pDetail, pAppClassInfo);
                    if (_lstFeeFix.Count > 0)
                    {
                        pReturn = _AppFeeFixBL.AppFeeFixInsertBath(_lstFeeFix, p_case_code);
                        if (pReturn < 0)
                            goto Commit_Transaction;
                    }
                    #endregion

                    #region Tai lieu dinh kem 
                    if (pReturn >= 0 && pAppDocumentInfo != null && 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)
                        {
                            info.App_Header_Id = pDetail.App_Header_Id;
                            if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                            {
                                var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                if (_updateitem.GetType() == typeof(string))
                                {
                                    string _url = (string)_updateitem;
                                    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 = 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();
                        return Json(new { status = -1 });

                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return Json(new { status = pAppHeaderID });

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return Json(new { status = ErrorCode.Error });
            }
        }
Beispiel #13
0
        public ActionResult Register(ApplicationHeaderInfo pInfo, A02_Info pDetail,
                                     List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo,
                                     List <AuthorsInfo> pAppAuthorsInfo, List <Other_MasterInfo> pOther_MasterInfo,
                                     List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                     List <AppDocumentOthersInfo> pAppDocDesign)
        {
            try
            {
                Application_Header_BL objBL       = new Application_Header_BL();
                AppFeeFixBL           objFeeFixBL = new AppFeeFixBL();
                A02_BL           objDetail        = new A02_BL();
                AppDocumentBL    objDoc           = new AppDocumentBL();
                Other_Master_BL  _Other_Master_BL = new Other_Master_BL();
                Author_BL        _Author_BL       = new Author_BL();
                AppClassDetailBL objClassDetail   = new AppClassDetailBL();
                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;
                        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;
                        }
                    }

                    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;
                        }
                    }


                    //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
                    }


                    #region bộ tài liệu ảnh
                    if (pReturn >= 0 && pAppDocDesign != null)
                    {
                        if (pAppDocDesign.Count > 0)
                        {
                            int check = 0;
                            foreach (var info in pAppDocDesign)
                            {
                                if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                                {
                                    var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    if (_updateitem.GetType() == typeof(AppDocumentInfo))
                                    {
                                        HttpPostedFileBase pfiles = (_updateitem as AppDocumentInfo).pfiles;

                                        info.Filename = pfiles.FileName;
                                        info.Filename = AppLoadHelpers.convertToUnSign2(info.Filename);
                                        info.Filename = System.Text.RegularExpressions.Regex.Replace(info.Filename, "[^0-9A-Za-z.]+", "_");

                                        info.Filename = "/Content/Archive/" + AppUpload.Document + "/" + pfiles.FileName;
                                        info.IdRef    = Convert.ToDecimal((_updateitem as AppDocumentInfo).refId);
                                        check         = 1;
                                    }
                                }
                                info.App_Header_Id = pAppHeaderID;
                                info.Language_Code = language;
                            }
                            if (check == 1)
                            {
                                pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocDesign);
                            }
                        }
                    }
                    #endregion

                    #region tính phí
                    List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A02(pDetail, pAppDocumentInfo, pAppDocDesign);
                    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))
                                {
                                    var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                    if (_updateitem.GetType() == typeof(string))
                                    {
                                        string   _url      = (string)_updateitem;
                                        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();
                        return(Json(new { status = -1 }));
                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return(Json(new { status = pAppHeaderID }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }
        public ActionResult ExportDataNew(ApplicationHeaderInfo pInfo, AppTM06DKQTInfoExport pDetail, List <AppDocumentInfo> pAppDocumentInfo,
                                          List <AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                //  AppTM06DKQTInfoExport pDetail= new AppTM06DKQTInfoExport();
                string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/C06_Request for_international_trademark_registration_vi_exp.doc");

                // Fill export_header
                string fileName = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C06_Request_for_international_trademark_registration_vi_exp_" + pInfo.Appcode + ".pdf");
                // Fill export_detail
                pDetail.Status        = 254;
                pDetail.Status_Form   = 252;
                pDetail.Relationship  = "11";
                pDetail.strNgayNopDon = pDetail.NGAYNOPDON.ToDateStringN0();
                if (pDetail.REF_APPNO_TEXT != null)
                {
                    pDetail.REF_APPNO_TEXT = pDetail.REF_APPNO_TEXT.Trim();
                }
                pDetail = CreateInstanceTM06DKQT.CopyAppHeaderInfo(pDetail, pInfo);

                if (pAppClassInfo != null)
                {
                    Hashtable _hsGroupclass = new Hashtable();
                    foreach (var item in pAppClassInfo)
                    {
                        AppClassDetailInfo _newinfo = new AppClassDetailInfo();
                        _newinfo.CloneObj();
                        if (_hsGroupclass.ContainsKey(item.Code.Substring(0, 2)))
                        {
                            _newinfo = (AppClassDetailInfo)_hsGroupclass[item.Code.Substring(0, 2)];
                        }
                        _newinfo.Code       = item.Code;
                        _newinfo.Textinput += item.Textinput + ", ";
                        _newinfo.IntTongSanPham++;
                        _hsGroupclass[item.Code.Substring(0, 2)] = _newinfo;
                    }
                    List <AppClassDetailInfo> _listApp = new List <AppClassDetailInfo>();
                    foreach (DictionaryEntry item in _hsGroupclass)
                    {
                        _listApp.Add((AppClassDetailInfo)item.Value);
                    }
                    foreach (AppClassDetailInfo item in _listApp.OrderBy(m => m.Code))
                    {
                        pDetail.strListClass += "Nhóm " + item.Code.Substring(0, 2) + ": " + item.Textinput.Trim().Trim(',') + " (" + (item.IntTongSanPham < 10 ? "0" + item.IntTongSanPham.ToString() : item.IntTongSanPham.ToString()) + " sản phẩm)" + "\n";
                    }
                }

                // đẩy file lên server
                if (pDetail.pfileLogo != null)
                {
                    pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                }

                if (!string.IsNullOrEmpty(pDetail.LOGOURL))
                {
                    //Kết xuất ảnh
                }

                #region hiển thị tài liệu đính kèm
                if (pAppDocumentInfo == null)
                {
                    pAppDocumentInfo = new List <AppDocumentInfo>();
                }
                foreach (AppDocumentInfo item in pAppDocumentInfo)
                {
                    if (item.Document_Id == "C06DKQT_D_01")
                    {
                        pDetail.TOKHAI_USED    = item.Isuse.ToString();
                        pDetail.TOKHAI_SOTRANG = item.CHAR01;
                        pDetail.TOKHAI_SOBAN   = item.CHAR02;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_02")
                    {
                        pDetail.MAUDK_VPQT_USED    = item.Isuse.ToString();
                        pDetail.MAUDK_VPQT_SO      = item.CHAR01;
                        pDetail.MAUDK_VPQT_NGONNGU = item.CHAR02;
                        pDetail.MAUDK_VPQT_SOTRANG = item.CHAR03;
                        pDetail.MAUDK_VPQT_SOBAN   = item.CHAR04;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_03")
                    {
                        pDetail.MAUNDH_USED  = item.Isuse.ToString();
                        pDetail.MAUNDH_SOMAU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_04")
                    {
                        pDetail.BANSAO_TOKHAI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_05")
                    {
                        pDetail.BANSAO_GIAYDK_NHCS_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_06")
                    {
                        pDetail.BAN_CK_SD_NGANHANG_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_07")
                    {
                        pDetail.GIAY_UQ_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_NGONNGU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_08")
                    {
                        pDetail.GIAY_UQ_BANDICH_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANDICH_SOTRANG = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_09")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANGOC_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_010")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANSAO_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_011")
                    {
                        pDetail.GIAY_UQ_BANGOCNOPSAU_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_012")
                    {
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO_USED = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO      = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_013")
                    {
                        pDetail.CHUNGTU_LEPHI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_014")
                    {
                        pDetail.TAILIEUBOSUNG_USED = item.Isuse.ToString();
                        pDetail.TAILIEUBOSUNG      = item.CHAR01;
                        continue;
                    }
                }

                #endregion
                List <AppFeeFixInfo> pFeeFixInfo = CommonFunction.Call_Fee.CallFee_C06(pDetail);
                pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount;
                if (pInfo.Languague_Code == Language.LangEN)
                {
                    pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount_Usd;
                }
                List <AppTM06DKQTInfoExport> _lst = new List <AppTM06DKQTInfoExport>();
                pDetail.LOGOURL = Server.MapPath(pDetail.LOGOURL);
                _lst.Add(pDetail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <AppTM06DKQTInfoExport>(_lst, false);

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string _tempfile = "C06.rpt";
                //if(AppsCommon.GetCurrentLang() == Language.LangEN)
                if (pInfo.Languague_Code != Language.LangVI)
                {
                    _tempfile = "C06.rpt";
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile), OpenReportMethod.OpenReportByTempCopy);

                //   _ds_all.WriteXmlSchema(@"C:\Users\user\Desktop\LEGALTECH\XMLFILE\TM06DKQT.xml");
                //Logger.LogInfo("b3: ");
                CrystalDecisions.CrystalReports.Engine.PictureObject _pic01;
                _pic01        = (CrystalDecisions.CrystalReports.Engine.PictureObject)oRpt.ReportDefinition.Sections[0].ReportObjects["Picture1"];
                _pic01.Width  = 200;
                _pic01.Height = 200;

                System.IO.FileInfo file = new System.IO.FileInfo(pDetail.LOGOURL);
                Bitmap             img  = new Bitmap(pDetail.LOGOURL);
                try
                {
                    double _Const = 6.666666666666 / 2;
                    int    _left = 0, _top = 0, _marginleft = 225, _margintop = 5580;
                    int    _h  = 600;
                    double _d1 = (_h - img.Width) / 2;
                    _d1   = _Const * _d1;
                    _left = _marginleft + Convert.ToInt32(_d1);
                    if (_left < 0)
                    {
                        _left = _marginleft;
                    }
                    _pic01.Left = _left;
                    // top

                    _d1  = (_h - img.Height) / 2;
                    _d1  = _Const * _d1;
                    _top = _margintop + Convert.ToInt32(_d1);
                    if (_top < 0)
                    {
                        _top = _margintop;
                    }
                    _pic01.Top = _top;
                }
                catch (Exception)
                {
                }
                finally
                {
                    img.Dispose();
                }

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

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

                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, byteArray.ToArray()); // Requires System.Linq


                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
        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 }));
            }
        }
        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 }));
            }
        }
Beispiel #17
0
        public ActionResult Edit(ApplicationHeaderInfo pInfo, A02_Info pDetail,
                                 List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo,
                                 List <AuthorsInfo> pAppAuthorsInfo, List <Other_MasterInfo> pOther_MasterInfo,
                                 List <AppDocumentOthersInfo> pAppDocOtherInfo,
                                 List <AppDocumentOthersInfo> pAppDocDesign)
        {
            try
            {
                Application_Header_BL objBL       = new Application_Header_BL();
                AppFeeFixBL           objFeeFixBL = new AppFeeFixBL();
                A02_BL           objDetail        = new A02_BL();
                AppClassDetailBL objClassDetail   = new AppClassDetailBL();
                if (pInfo == null || pDetail == null)
                {
                    return(Json(new { status = ErrorCode.Error }));
                }
                string  language     = AppsCommon.GetCurrentLang();
                decimal pReturn      = ErrorCode.Success;
                int     pAppHeaderID = (int)pInfo.Id;
                string  p_case_code  = pInfo.Case_Code;

                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       = "";
                    //TRA RA ID CUA BANG KHI INSERT
                    pReturn = objBL.AppHeaderUpdate(pInfo);
                    if (pReturn < 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;
                        pReturn = objDetail.UpDate(pDetail);

                        if (pReturn <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    // ok
                    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 = pAppHeaderID;
                        }
                        decimal _re = _Author_BL.Insert(pAppAuthorsInfo);
                        if (_re <= 0)
                        {
                            goto Commit_Transaction;
                        }
                    }

                    // ok
                    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 = pAppHeaderID;
                        }

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

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



                    //tai lieu khac
                    #region Tài liệu khác
                    AppDocumentBL 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 = pAppHeaderID;
                            info.Language_Code = language;
                        }
                        if (check == 1)
                        {
                            pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocOtherInfo);
                        }
                    }
                    #endregion

                    #region bộ tài liệu ảnh -> chưa sửa
                    // chưa sửa
                    List <AppDocumentOthersInfo> Lst_DocIndusDesign_Old             = Lst_Doc_Others.FindAll(m => m.FILETYPE == 2).ToList();
                    Dictionary <decimal, AppDocumentOthersInfo> _dic_DocIndusDesign = new Dictionary <decimal, AppDocumentOthersInfo>();
                    foreach (AppDocumentOthersInfo item in Lst_DocIndusDesign_Old)
                    {
                        _dic_DocIndusDesign[item.Id] = item;
                    }

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

                    if (pReturn >= 0 && pAppDocDesign != null && pAppDocDesign.Count > 0)
                    {
                        int check = 0;
                        foreach (var info in pAppDocDesign)
                        {
                            if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                            {
                                var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                if (_updateitem.GetType() == typeof(AppDocumentInfo))
                                {
                                    HttpPostedFileBase pfiles = (_updateitem as AppDocumentInfo).pfiles;

                                    info.Filename = pfiles.FileName;
                                    info.Filename = AppLoadHelpers.convertToUnSign2(info.Filename);
                                    info.Filename = System.Text.RegularExpressions.Regex.Replace(info.Filename, "[^0-9A-Za-z.]+", "_");

                                    info.Filename = "/Content/Archive/" + AppUpload.Document + "/" + pfiles.FileName;
                                    //info.IdRef = Convert.ToDecimal((_updateitem as AppDocumentInfo).refId);
                                    check = 1;
                                }
                            }
                            else if (_dic_DocIndusDesign.ContainsKey(info.Id))
                            {
                                info.Filename = _dic_DocIndusDesign[info.Id].Filename;
                                //info.IdRef = _dic_doc_others[info.Id].IdRef;
                                check = 1;
                            }

                            info.App_Header_Id = pAppHeaderID;
                            info.Language_Code = language;
                        }
                        if (check == 1)
                        {
                            pReturn = objDoc.AppDocumentOtherInsertBatch(pAppDocDesign);
                        }
                    }
                    #endregion

                    #region tính phí
                    // xóa đi
                    AppFeeFixBL _AppFeeFixBL = new AppFeeFixBL();
                    _AppFeeFixBL.AppFeeFixDelete(pInfo.Case_Code, language);

                    List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_A02(pDetail, pAppDocumentInfo, pAppDocDesign);
                    if (_lstFeeFix.Count > 0)
                    {
                        pReturn = _AppFeeFixBL.AppFeeFixInsertBath(_lstFeeFix, p_case_code);
                        if (pReturn < 0)
                        {
                            goto Commit_Transaction;
                        }
                    }
                    #endregion

                    #region Tai lieu dinh kem
                    if (pReturn >= 0 && pAppDocumentInfo != null && 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)
                        {
                            info.App_Header_Id = pDetail.App_Header_Id;
                            if (SessionData.CurrentUser.chashFile.ContainsKey(info.keyFileUpload))
                            {
                                var _updateitem = SessionData.CurrentUser.chashFile[info.keyFileUpload];
                                if (_updateitem.GetType() == typeof(string))
                                {
                                    string   _url      = (string)_updateitem;
                                    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        = 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();
                        return(Json(new { status = -1 }));
                    }
                    else
                    {
                        scope.Complete();
                    }
                }
                return(Json(new { status = pAppHeaderID }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { status = ErrorCode.Error }));
            }
        }