Exemplo n.º 1
0
 Boolean Validar()
 {
     try
     {
         var ITEMS = ListExcel.ToList().FindAll(v => v.chk == true);
         foreach (var item in ITEMS)
         {
             if (string.IsNullOrEmpty(item.IdCtaCble))
             {
                 MessageBox.Show("Existen elmentos que no tienen Cta. Contable");
                 return(false);
             }
             if (item.dc_Valor <= 0)
             {
                 MessageBox.Show("Existen montos en cero ");
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
         MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) + ex.Message + " ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
         return(false);
     }
 }
Exemplo n.º 2
0
        public static void SortLocFiles(DirectoryInfo langFolder)
        {
            if (!langFolder.Exists)
            {
                return;
            }

            var files = langFolder.GetFiles();

            foreach (var fil in files)
            {
                switch (fil.Extension)
                {
                case ".dotx":
                case ".docx":
                case ".dotm":
                    ListWord.Add(fil.FullName);
                    break;

                case ".xltx":
                case ".xlsx":
                case ".xltm":
                    ListExcel.Add(fil.FullName);
                    break;

                case ".potx":
                case ".pptx":
                case ".potm":
                    ListPpt.Add(fil.FullName);
                    // Console.WriteLine(fil.Directory.Name); // To get the file language folder name
                    break;
                }
            }
        }
Exemplo n.º 3
0
 private void ExportExcel(DataTable dt, int[] headerWidth)
 {
     if (dt != null && dt.Rows.Count > 0)
     {
         string title = this.GetExportTitle();
         string path  = FileDialogHelper.SaveExcel(title + ".xls");
         if (path != null && path != string.Empty)
         {
             if (File.Exists(path))
             {
                 File.Delete(path);
             }
             ListExcel ls = new ListExcel(path, dt);
             ls.Title       = title;
             ls.HeaderWidth = headerWidth;
             ls.GetExcelReport();
             this.Cursor = Cursors.WaitCursor;
             MessageBoxHelper.Show("导出成功!");
             this.Cursor = Cursors.Default;
         }
     }
     else
     {
         MessageBoxHelper.Show("没有找到可导出的数据!");
     }
 }
Exemplo n.º 4
0
        public void CreateExcel(SpreadsheetDocument document, CardFaceUl template, object obj = null)
        {
            ListExcel        excel  = new ListExcel(document);
            var              list1  = excel.CreateExcelList("Контрагенты");
            AllDocumentExcel docNds = new AllDocumentExcel(excel.Document, excel.WorkBookPart);

            list1.Worksheet = docNds.ReportNds(template, (int)obj);
            excel.WorkBookPart.Workbook.Save();
        }
Exemplo n.º 5
0
        public void CreateExcel(SpreadsheetDocument document, ReportCardModel template, object obj = null)
        {
            ListExcel        excel   = new ListExcel(document);
            var              list1   = excel.CreateExcelList("Табель");
            AllDocumentExcel docCard = new AllDocumentExcel(excel.Document, excel.WorkBookPart);

            list1.Worksheet = docCard.ReportCard(template);
            excel.WorkBookPart.Workbook.Save();
        }
Exemplo n.º 6
0
        public void CreateExcel(SpreadsheetDocument document, List <AllIpServerSelect> template, object obj = null)
        {
            ListExcel        excel   = new ListExcel(document);
            var              list1   = excel.CreateExcelList("Сервера");
            AllDocumentExcel docCard = new AllDocumentExcel(excel.Document, excel.WorkBookPart);

            list1.Worksheet = docCard.ReportStatusIpServer(template);
            excel.WorkBookPart.Workbook.Save();
        }
Exemplo n.º 7
0
        /// <summary>
        /// ListExcel导出名叫reportname的excel报表
        /// </summary>
        /// <param name="reportname">报表名字带xls后缀</param>
        /// <param name="listExcel">ListExcel</param>
        public static void ExportExcelReport(string reportname, ListExcel listExcel)
        {
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(reportname));
            System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";
            string   filename = listExcel.GetExcelReport();
            FileInfo file     = new FileInfo(filename);

            System.Web.HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString()); //添加头文件,指定文件的大小,让浏览器显示文件下载的速度
            System.Web.HttpContext.Current.Response.WriteFile(file.FullName);                            // 把文件流发送到客户端
            System.Web.HttpContext.Current.Response.End();
        }
Exemplo n.º 8
0
        private void Export()
        {
            DataTable dt   = this.GetTableFromGrid();
            string    path = FileDialogHelper.SaveExcel(this.GetTitle() + ".xls");

            if (path != null && path != string.Empty)
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                ListExcel ls = new ListExcel(path, dt);
                ls.Title = this.GetTitle();
                ls.GetExcelReport();
                this.Cursor = Cursors.WaitCursor;
                MessageBoxHelper.Show("导出成功!");
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 9
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            try
            {
                var ITEMS = ListExcel.ToList().FindAll(v => v.chk == true);


                if (!Validar())
                {
                    return;
                }


                ct_Periodo_Bus  BusPeriodo           = new ct_Periodo_Bus();
                ba_Cbte_Ban_Bus BUSBANCOSCOMPROBANTE = new ba_Cbte_Ban_Bus();
                List <ba_Cbte_Ban_tipo_x_ct_CbteCble_tipo_Info> _Parametros_ = _BusCbtBanXCtbtCble.Get_List_Cbte_Ban_tipo_x_ct_CbteCble_tipo(param.IdEmpresa);

                foreach (var item in ITEMS)
                {
                    var prm = _Parametros_.First(v => v.CodTipoCbteBan == item.CodTipoCbteBan.Trim());
                    ct_Cbtecble_Info CabeceraCbte = new ct_Cbtecble_Info();
                    CabeceraCbte.IdEmpresa        = param.IdEmpresa;
                    CabeceraCbte.IdTipoCbte       = prm.IdTipoCbteCble;
                    CabeceraCbte.IdPeriodo        = BusPeriodo.Get_Info_Periodo(param.IdEmpresa, item.cb_Fecha, ref MensajeError).IdPeriodo;
                    CabeceraCbte.IdUsuario        = param.IdUsuario;
                    CabeceraCbte.IdUsuarioUltModi = param.IdUsuario;
                    CabeceraCbte.Mayorizado       = "N";
                    CabeceraCbte.cb_Fecha         = item.cb_Fecha;
                    CabeceraCbte.cb_Observacion   = item.cb_Observacion;
                    CabeceraCbte.cb_Valor         = item.dc_Valor;
                    CabeceraCbte.Estado           = "A";
                    CabeceraCbte.cb_FechaTransac  = param.Fecha_Transac;
                    CabeceraCbte.cb_FechaUltModi  = CabeceraCbte.cb_FechaTransac;


                    ct_Cbtecble_det_Info DetalleInfo = new ct_Cbtecble_det_Info();
                    DetalleInfo.IdEmpresa     = param.IdEmpresa;
                    DetalleInfo.IdTipoCbte    = CabeceraCbte.IdEmpresa;
                    DetalleInfo.secuencia     = 1;
                    DetalleInfo.IdCtaCble     = IdCtaCbleBanco;
                    DetalleInfo.IdCentroCosto = item.IdCentroCosto;
                    if (item.CodTipoCbteBan == "NCBA")
                    {
                        DetalleInfo.dc_Valor = item.dc_Valor * -1;
                    }
                    if (item.CodTipoCbteBan == "NDBA")
                    {
                        DetalleInfo.dc_Valor = item.dc_Valor;
                    }
                    DetalleInfo.dc_Observacion = item.cb_Observacion;
                    CabeceraCbte._cbteCble_det_lista_info.Add(DetalleInfo);

                    DetalleInfo               = new ct_Cbtecble_det_Info();
                    DetalleInfo.IdEmpresa     = param.IdEmpresa;
                    DetalleInfo.IdTipoCbte    = CabeceraCbte.IdEmpresa;
                    DetalleInfo.secuencia     = 2;
                    DetalleInfo.IdCtaCble     = item.IdCtaCble;
                    DetalleInfo.IdCentroCosto = item.IdCentroCosto;
                    if (item.CodTipoCbteBan == "NCBA")
                    {
                        DetalleInfo.dc_Valor = item.dc_Valor;
                    }
                    if (item.CodTipoCbteBan == "NDBA")
                    {
                        DetalleInfo.dc_Valor = item.dc_Valor * -1;
                    }
                    DetalleInfo.dc_Observacion = item.cb_Observacion;
                    CabeceraCbte._cbteCble_det_lista_info.Add(DetalleInfo);


                    decimal IdCbte  = 0;
                    string  Mensaje = "";
                    string  Codigo  = "";



                    BUS_CONTABILIDAD.GrabarDB(CabeceraCbte, ref IdCbte, ref Mensaje);

                    item.IdHASH = string.Format("{0}-MOVI_BAN$-s{1}-{2}-{3}-d{4}-{5}-{6}", fileName, item.SecuenciaRelacionado, item.cb_Fecha, item.CodTipoCbteBan, item.cb_Cheque, item.cb_Observacion, item.dc_Valor);
                    ba_Cbte_Ban_Info COMPROBANTEBANCARIO = new ba_Cbte_Ban_Info();
                    COMPROBANTEBANCARIO.IdEmpresa        = param.IdEmpresa;
                    COMPROBANTEBANCARIO.IdCbteCble       = IdCbte;
                    COMPROBANTEBANCARIO.IdTipocbte       = CabeceraCbte.IdTipoCbte;
                    COMPROBANTEBANCARIO.Cod_Cbtecble     = Codigo;
                    COMPROBANTEBANCARIO.IdPeriodo        = CabeceraCbte.IdPeriodo;
                    COMPROBANTEBANCARIO.IdBanco          = IdBanco;
                    COMPROBANTEBANCARIO.cb_Fecha         = item.cb_Fecha;
                    COMPROBANTEBANCARIO.cb_Observacion   = item.cb_Observacion;
                    COMPROBANTEBANCARIO.cb_Valor         = item.dc_Valor;
                    COMPROBANTEBANCARIO.cb_ChequeImpreso = "N";
                    COMPROBANTEBANCARIO.IdUsuario        = param.IdUsuario;
                    COMPROBANTEBANCARIO.IdUsuarioUltMod  = param.IdUsuario;
                    COMPROBANTEBANCARIO.ip            = param.ip;
                    COMPROBANTEBANCARIO.nom_pc        = param.nom_pc;
                    COMPROBANTEBANCARIO.Fecha_Transac = param.Fecha_Transac;
                    COMPROBANTEBANCARIO.Fecha_UltMod  = COMPROBANTEBANCARIO.Fecha_Transac;
                    //COMPROBANTEBANCARIO.IdTipoNota = null;
                    COMPROBANTEBANCARIO.IdTransaccion = item.IdHASH;
                    BUSBANCOSCOMPROBANTE.GrabarDB(COMPROBANTEBANCARIO, ref MensajeError);
                    item.IdCbteCble = IdCbte;
                    item.IdTipocbte = CabeceraCbte.IdTipoCbte;
                }

                GetList_NotadasDeb_Cred(ITEMS);
                Close();
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) + ex.Message + " ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
            }
        }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now + " " + "Developed by Moravia Publishing & Media automation team. All rights reserved." + "\n");
            Console.WriteLine("Please input the root directory of loc templates folders >> ");
            Console.WriteLine("========================================");

Input:
            var dirInput = Console.ReadLine();

            Console.WriteLine("========================================");
            Console.WriteLine("In progress of processing, please hold on and wait for a while :) ");
            Console.WriteLine("========================================");

            // Check if input path is empty
            if (string.IsNullOrEmpty(dirInput) && string.IsNullOrWhiteSpace(dirInput))
            {
                Console.WriteLine("Empty or invalid directory, please double check and re-enter it!");
                goto Input;
            }

            // Transfer input directory string to DirectoryInfo
            if (!File.Exists(dirInput) && Directory.Exists(dirInput))
            {
                if (!dirInput.EndsWith("\\"))
                {
                    dirInput = dirInput + "\\";
                }

                var dirInfo = new DirectoryInfo(dirInput);

                // Get all subfolder names and add into LocalLanguage List
                try
                {
                    ListLangFolders(dirInfo);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error when create folders list: " + ex.Message);
                    return;
                }

                foreach (var lang in ListLang)
                {
                    try
                    {
                        var langDirInfo = new DirectoryInfo(dirInput + lang + "\\");
                        SortLocFiles(langDirInfo);
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine("Fail to sort files: " + e.Message);
                        return;
                    }
                }
            }
            else if (File.Exists(dirInput))
            {
                var fileInfo = new FileInfo(dirInput);

                switch (fileInfo.Extension)
                {
                case ".dotx":
                case ".docx":
                case ".dotm":
                    ListWord.Add(fileInfo.FullName);
                    break;

                case ".xltx":
                case ".xlsx":
                case ".xltm":
                    ListExcel.Add(fileInfo.FullName);
                    break;

                case ".potx":
                case ".pptx":
                case ".potm":
                    ListPpt.Add(fileInfo.FullName);
                    break;
                }
            }

            KillProcess();

            // PowerPointHandler
            if (ListPpt.Count > 0)
            {
                foreach (var f in ListPpt)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objPpt = new PowerPointHandler(f);
                    objPpt.PptMain(f);
                    Common.WriteSglText(f);
                }
            }

            // WordHandler
            if (ListWord.Count > 0)
            {
                foreach (var f in ListWord)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objWordHandler = new WordHandler(f);
                    objWordHandler.WordMain(f);
                    Common.WriteSglText(f);
                }
            }

            // Process ExcelHandler files
            if (ListExcel.Count > 0)
            {
                foreach (var f in ListExcel)
                {
                    if (f.Contains("~$"))
                    {
                        continue;
                    }
                    Console.Write("\r\n" + "Processing: ");
                    Common.WriteLine("\r\n" + f + "\r\n");
                    var objExcelHandler = new ExcelHandler(f);
                    objExcelHandler.ExcelMain(f);
                    Common.WriteSglText(f);
                }
            }

            // Write all Console content to text
            Common.WriteAllText(dirInput);

            // End
            Console.WriteLine("========================================");
            Console.WriteLine("All files process complete! You are good to go!");
            Console.ReadLine();
        }