/// <summary>
	/// Gets the Excel data from current spreadsheet
	/// </summary>
	/// <returns>The spreadsheet data table.</returns>
	/// <param name="excelReader">Excel Reader.</param>
	private DataTable GetExcelSheetData(IExcelDataReader excelReader)
	{
		if (excelReader == null)
		{
			Debug.LogError("Excel To Json Converter: Excel Reader is null. Cannot read data");
			return null;
		}
		
		// Ignore sheets which start with ~
		Regex sheetNameRegex = new Regex(@"^~.*$");
		if (sheetNameRegex.IsMatch(excelReader.Name))
		{
			return null;
		}
		
		// Create the table with the spreadsheet name
		DataTable table = new DataTable(excelReader.Name);
		table.Clear();
		
		string value = "";
		bool rowIsEmpty;
		
		// Read the rows and columns
		while (excelReader.Read())
		{
			DataRow row = table.NewRow();
			rowIsEmpty = true;
			
			for (int i = 0; i < excelReader.FieldCount; i++) 
			{
				// If the column is null and this is the first row, skip
				// to next iteration (do not want to include empty columns)
				if (excelReader.IsDBNull(i) && 
				    (excelReader.Depth == 1 || i > table.Columns.Count - 1))
				{
					continue;
				}
				
				value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
				
				// If this is the first row, add the values as columns
				if (excelReader.Depth == 1)
				{
					table.Columns.Add(value);
				}
				else // Otherwise, add as rows
				{
					row[table.Columns[i]] = value;
				}
				
				if (!string.IsNullOrEmpty(value))
				{
					rowIsEmpty = false;
				}
			}
			
			// Add the row to the table if it was not column headers and 
			// the row was not empty
			if (excelReader.Depth != 1 && !rowIsEmpty)
			{
				table.Rows.Add(row);
			}
		}
		
		return table;
	}
Beispiel #2
0
        public TestClass2(IExcelDataReader reader)
        {
            Sku = reader.IsDBNull(0) ? default : reader.GetString(0);

                  SupplierCategory = reader.IsDBNull(6) ? default : reader.GetString(1);

                                     Store = reader.IsDBNull(2) ? default : reader.GetString(2);

                                             SupplierDescription                 = reader.IsDBNull(3) ? default : reader.GetString(3);
                                                                           Price = reader.GetDouble(4);

                                                                           VAT                     = reader.IsDBNull(5) ? default : reader.GetString(5);
                                                                                           CaseQty = reader.IsDBNull(6) ? default(double?) : reader.GetDouble(6);
                                                                                           PackQty = reader.IsDBNull(7) ? default(double?) : reader.GetDouble(7);
                                                                                           Unit    = reader.GetDouble(8);

                                                                                           Measure = reader.IsDBNull(9) ? default : reader.GetString(9);

                                                                                                     UomDescription = reader.IsDBNull(10) ? default : reader.GetString(10);

                                                                                                                      Origin = reader.IsDBNull(11) ? default : reader.GetString(11);

                                                                                                                               Brand = reader.IsDBNull(12) ? default : reader.GetString(12);
                                                                                                                                       LastPeriodVolume = reader.IsDBNull(13) ? default(double?) : reader.GetDouble(13);
        }
Beispiel #3
0
    /// <summary>
    /// 获得表格数据
    /// </summary>
    private static DataTable GetTable(IExcelDataReader excelReader)
    {
        DataTable dt = new DataTable();

        dt.TableName = excelReader.Name;

        bool isInit = false;

        string[] ItemArray = null;
        while (excelReader.Read())
        {
            if (!isInit)
            {
                isInit = true;
                for (int i = 0; i < excelReader.FieldCount; i++)
                {
                    dt.Columns.Add("", typeof(string));
                }
                ItemArray = new string[excelReader.FieldCount];
            }

            if (excelReader.IsDBNull(0))
            {
                continue;
            }
            for (int i = 0; i < excelReader.FieldCount; i++)
            {
                string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
                ItemArray[i] = value;
            }
            dt.Rows.Add(ItemArray);
        }
        return(dt);
    }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            List <in_Ing_Egr_Inven_det_Info> Lista_IngresoInventarioDet = new List <in_Ing_Egr_Inven_det_Info>();
            in_Ing_Egr_Inven_det_List        ListaIngresoInventario     = new in_Ing_Egr_Inven_det_List();
            in_Producto_Bus bus_producto         = new in_Producto_Bus();
            int             cont                 = 0;
            decimal         IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int             IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            tb_sucursal_Bus bus_sucursal         = new tb_sucursal_Bus();

            #endregion

            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Ingreso Inventario
                var lst_producto = bus_producto.get_list(IdEmpresa, false);
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        var pr_codigo_producto = Convert.ToString(reader.GetValue(3));
                        var IdUnidadMedida     = Convert.ToString(reader.GetValue(2));
                        var costo_total        = Convert.ToDouble(reader.GetValue(6));
                        var cantidad           = Convert.ToDouble(reader.GetValue(5));
                        var info_producto      = lst_producto.Where(q => q.pr_codigo == pr_codigo_producto).FirstOrDefault();

                        if ((info_producto != null && info_producto.IdProducto != 0) && (costo_total > 0 && cantidad > 0))
                        {
                            in_Ing_Egr_Inven_det_Info info_detalle = new in_Ing_Egr_Inven_det_Info
                            {
                                Secuencia      = cont++,
                                IdEmpresa      = IdEmpresa,
                                IdProducto     = info_producto.IdProducto,
                                pr_descripcion = info_producto.pr_descripcion,
                                IdUnidadMedida_sinConversion = string.IsNullOrEmpty(IdUnidadMedida) ? info_producto.IdUnidadMedida_Consumo : IdUnidadMedida,
                                dm_cantidad_sinConversion    = cantidad,
                                mv_costo_sinConversion       = costo_total / cantidad,
                            };

                            Lista_IngresoInventarioDet.Add(info_detalle);
                        }
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaIngresoInventario.set_list(Lista_IngresoInventarioDet, IdTransaccionSession);
                #endregion
            }
        }
Beispiel #5
0
        private List <string> _GetRow(IExcelDataReader excelReader)
        {
            List <string> rowList = new List <string>();

            for (int i = 0; i < excelReader.FieldCount; i++)
            {
                string value = excelReader.IsDBNull(i) ? "" : excelReader[i].ToString();
                value = value.Trim();
                rowList.Add(value);
            }
            return(rowList);
        }
Beispiel #6
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            ct_plancta_Bus              bus_ctacble = new ct_plancta_Bus();
            ct_cbtecble_det_List        ListaDet    = new ct_cbtecble_det_List();
            List <ct_cbtecble_det_Info> Lista_Det   = new List <ct_cbtecble_det_Info>();

            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                var SecDet = 1;
                #region Presupuesto
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        var             IdCtaCble   = Convert.ToString(reader.GetValue(1));
                        ct_plancta_Info infoCtaCble = bus_ctacble.get_info(IdEmpresa, IdCtaCble);

                        if (infoCtaCble != null)
                        {
                            ct_cbtecble_det_Info info = new ct_cbtecble_det_Info
                            {
                                IdEmpresa      = IdEmpresa,
                                secuencia      = SecDet++,
                                IdCtaCble      = IdCtaCble,
                                Descripcion    = infoCtaCble.pc_Cuenta,
                                dc_Valor       = Convert.ToDouble(reader.GetValue(2)) > 0 ? Convert.ToDouble(reader.GetValue(2)) : (Convert.ToDouble(reader.GetValue(3)) * -1),
                                dc_Valor_debe  = Convert.ToDouble(reader.GetValue(2)),
                                dc_Valor_haber = Convert.ToDouble(reader.GetValue(3))
                            };
                            Lista_Det.Add(info);
                        }
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaDet.set_list(Lista_Det, IdTransaccionSession);
                #endregion
            }
        }
        public static List <ExcelStateObj> ReadExcel(string path)
        {
            MemoryStream         memory      = new MemoryStream(LoadFilebytes(path));
            List <ExcelStateObj> list        = new List <ExcelStateObj>();
            IExcelDataReader     excelReader = ExcelReaderFactory.CreateOpenXmlReader(memory);

            do
            {
                // sheet name
                //Debug.Log(excelReader.Name);
                List <RowStateObj> rowList = new List <RowStateObj>();
                int rowCount = 0;
                int colCount = 0;
                while (excelReader.Read())
                {
                    bool        isAdd = false;
                    RowStateObj row   = new RowStateObj(excelReader.FieldCount);
                    colCount = Mathf.Max(excelReader.FieldCount, colCount);
                    for (int i = 0; i < colCount; i++)
                    {
                        CellStateObj cell = new CellStateObj();
                        row.Cells[i] = cell;
                        if (i < excelReader.FieldCount)
                        {
                            string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
                            cell.Value = value;
                            if (!string.IsNullOrEmpty(value))
                            {
                                isAdd = true;
                            }
                        }
                    }
                    if (isAdd)
                    {
                        rowCount++;
                        rowList.Add(row);
                    }
                }
                ExcelStateObj excelStateObj = new ExcelStateObj(rowCount, colCount);
                excelStateObj.ExcelName = excelReader.Name;
                excelStateObj.Rows      = rowList.ToArray();
                list.Add(excelStateObj);
            }while(excelReader.NextResult());
            //DataSet result = excelReader.AsDataSet();
            excelReader.Close();
            excelReader.Dispose();
            memory.Close();
            memory.Dispose();
            return(list);
        }
        private static bool AreAllColumnsEmpty(IExcelDataReader reader)
        {
            bool result = true;

            for (int i = 0; i < reader.FieldCount; i++)
            {
                if (!reader.IsDBNull(i))
                {
                    result = false;
                    break;
                }
            }

            return(result);
        }
Beispiel #9
0
    private string SafeGetString(IExcelDataReader reader, int ordinal, string def = "")
    {
        try
        {
            if (reader.IsDBNull(ordinal))
            {
                return(def);
            }

            return((reader.GetValue(ordinal) ?? def).ToString());
        }
        catch (Exception ex)
        {
            return(def);
        }
    }
Beispiel #10
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            pre_rubro_Bus                  bus_rubro = new pre_rubro_Bus();
            pre_PresupuestoDet_List        ListaDet  = new pre_PresupuestoDet_List();
            List <pre_PresupuestoDet_Info> Lista_Det = new List <pre_PresupuestoDet_Info>();

            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                var SecDet = 1;
                #region Presupuesto
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        var            IdRubroDet = Convert.ToInt32(reader.GetValue(0));
                        pre_rubro_Info infoRubro  = bus_rubro.GetInfo(IdEmpresa, IdRubroDet);

                        pre_PresupuestoDet_Info info = new pre_PresupuestoDet_Info
                        {
                            IdEmpresa   = IdEmpresa,
                            Secuencia   = SecDet++,
                            IdRubro     = IdRubroDet,
                            Descripcion = infoRubro.Descripcion,
                            Monto       = Convert.ToDouble(reader.GetValue(1)),
                        };
                        Lista_Det.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaDet.set_list(Lista_Det, IdTransaccionSession);
                #endregion
            }
        }
Beispiel #11
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            int cont = 0;
            ro_rubro_tipo_Bus                 bus_rubro                   = new ro_rubro_tipo_Bus();
            ro_empleado_info_list             empleado_info_list          = new ro_empleado_info_list();
            ro_PrestamoMasivo_Det_List        ListaDetalle_PrestamoMasivo = new ro_PrestamoMasivo_Det_List();
            List <ro_PrestamoMasivo_Det_Info> PrestamoMasivo_Det          = new List <ro_PrestamoMasivo_Det_Info>();
            var    IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            int    Secuencia            = 1;
            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);

            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        if (cont != 0)
                        {
                            int    IdEmpresa  = Convert.ToInt32(SessionFixed.IdEmpresa);
                            string cedula     = reader.GetString(0);
                            var    empleado   = empleado_info_list.get_list(IdTransaccionSession).Where(v => v.pe_cedulaRuc == cedula).FirstOrDefault();
                            var    CodRubro   = Convert.ToString(reader.GetValue(2));
                            var    info_rubro = bus_rubro.get_info_x_codigo(IdEmpresa, CodRubro);
                            if (empleado != null)
                            {
                                ro_PrestamoMasivo_Det_Info info = new ro_PrestamoMasivo_Det_Info
                                {
                                    Secuencia         = Secuencia++,
                                    IdEmpleado        = (empleado == null ? 0 : empleado.IdEmpleado),
                                    IdRubro           = (info_rubro == null ? null : info_rubro.IdRubro),
                                    Monto             = Convert.ToDouble(reader.GetValue(3)),
                                    NumCuotas         = Convert.ToInt32(reader.GetValue(4)),
                                    ru_descripcion    = (info_rubro == null ? "" : info_rubro.ru_descripcion),
                                    pe_nombreCompleto = (empleado == null ? "" : empleado.Empleado)
                                };
                                PrestamoMasivo_Det.Add(info);
                            }
                        }
                        cont++;
                    }
                }
                ListaDetalle_PrestamoMasivo.set_list(PrestamoMasivo_Det, IdTransaccionSession);
            }
        }
Beispiel #12
0
        public static void HandleDescriptionFactor(IExcelDataReader reader)
        {
            var descriptionModel = new Description();

            //loop through each row.
            while (reader.Read())
            {
                //Loop through each column of the the current row.
                for (int i = 0; i < reader.FieldCount; i += 2)
                {
                    //gets the current value.
                    var currentCellValue = reader.IsDBNull(i) ? reader.GetValue(i) : reader.GetValue(i).ToString().Trim();

                    Console.WriteLine(currentCellValue);
                }
            }
        }
        private List <string> GetFields(IExcelDataReader rowReader)
        {
            var fieldCount = rowReader.FieldCount;

            var fields = new List <string>();

            for (var i = 0; i < fieldCount; ++i)
            {
                var field = rowReader.IsDBNull(i)
                    ? string.Empty
                    : Convert.ToString(rowReader.GetValue(i)).Trim();

                fields.Add(field);
            }

            return(fields);
        }
Beispiel #14
0
        public static void HandleTimingFactor(IExcelDataReader reader)
        {
            while (reader.Read())
            {
                //Loop through each column of the the current row.
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (reader.IsDBNull(i))
                    {
                        break;
                    }
                    //gets the current value.
                    var currentCellValue = reader.GetValue(i).ToString().Trim();

                    Console.WriteLine(currentCellValue);
                }
            }
        }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            int cont = 0;
            ro_empleado_info_list empleado_info_list = new ro_empleado_info_list();
            ro_EmpleadoNovedadCargaMasiva_detLis_Info     EmpleadoNovedadCargaMasiva_detLis_Info = new ro_EmpleadoNovedadCargaMasiva_detLis_Info();
            List <ro_EmpleadoNovedadCargaMasiva_det_Info> lista_novedades = new List <ro_EmpleadoNovedadCargaMasiva_det_Info>();
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);

            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);

            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        if (cont != 0)
                        {
                            string cedua    = reader.GetString(0);
                            var    empleado = empleado_info_list.get_list(IdTransaccionSession).Where(v => v.pe_cedulaRuc == cedua).FirstOrDefault();
                            if (empleado != null)
                            {
                                ro_EmpleadoNovedadCargaMasiva_det_Info info = new ro_EmpleadoNovedadCargaMasiva_det_Info
                                {
                                    Valor         = Convert.ToDouble(reader.GetValue(3)),
                                    CantidadHoras = Convert.ToDouble(reader.GetValue(4)),

                                    pe_cedulaRuc = cedua,
                                    pe_apellido  = empleado.Empleado,
                                    em_codigo    = empleado.em_codigo,
                                    Secuancia    = cont,
                                    IdEmpleado   = empleado.IdEmpleado
                                };
                                lista_novedades.Add(info);
                            }
                        }
                        cont++;
                    }
                }
                EmpleadoNovedadCargaMasiva_detLis_Info.set_list(lista_novedades, IdTransaccionSession);
            }
        }
Beispiel #16
0
    void XLSX()
    {
        FileStream       stream      = File.Open(Application.dataPath + "/Scripts/DataList/ItemTable.xlsx", FileMode.Open, FileAccess.Read);
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

        do
        {
            // sheet name
            Debug.Log(excelReader.Name);
            while (excelReader.Read())
            {
                for (int i = 0; i < excelReader.FieldCount; i++)
                {
                    string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
                    Debug.Log(value);
                }
            }
        }while(excelReader.NextResult());
    }
Beispiel #17
0
    public static ExcelDataSet ReadExcel(string excelPath)
    {
        ExcelDataSet set = new ExcelDataSet();

        if (!File.Exists(excelPath))
        {
            throw new Exception("path not exists");
        }
        try
        {
            FileStream       stream      = File.Open(excelPath, FileMode.Open, FileAccess.Read);
            IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            do
            {
                ExcelDataTable table = new ExcelDataTable();
                // sheet name
                while (excelReader.Read())
                {
                    ExcelDataRow row = new ExcelDataRow();
                    for (int i = 0; i < excelReader.FieldCount; i++)
                    {
                        string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
                        row.Cells.Add(value);
                    }
                    table.Rows.Add(row);
                }
                if (table.Rows.Count > 0)
                {
                    set.Tables.Add(table);
                }
            } while (excelReader.NextResult());
            excelReader.Dispose();
            stream.Dispose();
        }
        catch (Exception e)
        {
            DebugLogWrapper.LogError(e);
        }

        return(set);
    }
Beispiel #18
0
        public void DataReader_Read_Test()
        {
            IExcelDataReader r =
                ExcelReaderFactory.CreateOpenXmlReader(Helper.GetTestWorkbook("xTest_num_double_date_bool_string"));

            var table = new DataTable();

            table.Columns.Add(new DataColumn("num_col", typeof(int)));
            table.Columns.Add(new DataColumn("double_col", typeof(double)));
            table.Columns.Add(new DataColumn("date_col", typeof(DateTime)));
            table.Columns.Add(new DataColumn("boo_col", typeof(bool)));

            int fieldCount = -1;

            while (r.Read())
            {
                fieldCount = r.FieldCount;
                table.Rows.Add(r.GetInt32(0), r.GetDouble(1), r.GetDateTime(2), r.IsDBNull(4));
            }

            r.Close();

            Assert.AreEqual(6, fieldCount);

            Assert.AreEqual(30, table.Rows.Count);

            Assert.AreEqual(1, int.Parse(table.Rows[0][0].ToString()));
            Assert.AreEqual(1346269, int.Parse(table.Rows[29][0].ToString()));

            //double + Formula
            Assert.AreEqual(1.02, double.Parse(table.Rows[0][1].ToString()));
            Assert.AreEqual(4.08, double.Parse(table.Rows[2][1].ToString()));
            Assert.AreEqual(547608330.24, double.Parse(table.Rows[29][1].ToString()));

            //Date + Formula
            Assert.AreEqual(new DateTime(2009, 5, 11).ToShortDateString(),
                            DateTime.Parse(table.Rows[0][2].ToString()).ToShortDateString());
            Assert.AreEqual(new DateTime(2009, 11, 30).ToShortDateString(),
                            DateTime.Parse(table.Rows[29][2].ToString()).ToShortDateString());
        }
Beispiel #19
0
        public static void ReadXLSX(Stream stream, bool isFirstRowAsColumnNames)
        {
            IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

            excelReader.IsFirstRowAsColumnNames = isFirstRowAsColumnNames;
            int index = 0;

            do
            {
                // 读取当前行

                // sheet name
                Log(">>> Table [{0}]", excelReader.Name);
                List <List <string> > sheetData = new List <List <string> >();
                // 读取列
                while (excelReader.Read())
                {
                    Log("-------------------------------");
                    Log("Count[{0}]", excelReader.FieldCount);


                    List <string> data = new List <string>();

                    for (int i = 0; i < excelReader.FieldCount; i++)
                    {
                        string value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);
                        Log(value);
                        data.Add(value);
                        //if (index == 0)
                        //{
                        //    HeadNameList.Add(value);
                        //}
                    }
                    sheetData.Add(data);
                }
                m_excelData.Add(excelReader.Name, sheetData);
                index++;
            } while (excelReader.NextResult());
        }
Beispiel #20
0
        public void DataReaderReadTest()
        {
            using (IExcelDataReader r = OpenReader("Test_num_double_date_bool_string"))
            {
                var table = new DataTable();
                table.Columns.Add(new DataColumn("num_col", typeof(int)));
                table.Columns.Add(new DataColumn("double_col", typeof(double)));
                table.Columns.Add(new DataColumn("date_col", typeof(DateTime)));
                table.Columns.Add(new DataColumn("boo_col", typeof(bool)));

                int fieldCount = -1;

                while (r.Read())
                {
                    fieldCount = r.FieldCount;
                    table.Rows.Add(
                        Convert.ToInt32(r.GetValue(0)),
                        Convert.ToDouble(r.GetValue(1)),
                        r.GetDateTime(2),
                        r.IsDBNull(4));
                }

                Assert.AreEqual(6, fieldCount);

                Assert.AreEqual(30, table.Rows.Count);

                Assert.AreEqual(1, int.Parse(table.Rows[0][0].ToString()));
                Assert.AreEqual(1346269, int.Parse(table.Rows[29][0].ToString()));

                // double + Formula
                Assert.AreEqual(1.02, double.Parse(table.Rows[0][1].ToString()));
                Assert.AreEqual(4.08, double.Parse(table.Rows[2][1].ToString()));
                Assert.AreEqual(547608330.24, double.Parse(table.Rows[29][1].ToString()));

                // Date + Formula
                Assert.AreEqual(new DateTime(2009, 5, 11).ToShortDateString(), DateTime.Parse(table.Rows[0][2].ToString()).ToShortDateString());
                Assert.AreEqual(new DateTime(2009, 11, 30).ToShortDateString(), DateTime.Parse(table.Rows[29][2].ToString()).ToShortDateString());
            }
        }
Beispiel #21
0
        public void Read(OnRowRead onRowRead)
        {
            using (FileStream stream = File.Open(_path, FileMode.Open, FileAccess.Read))
            {
                //Choose one of either 1 or 2
                //1. Reading from a binary Excel file ('97-2003 format; *.xls)
                //IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
                //2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                //IExcelDataReader excelReader = ExcelReaderFactory.CreateReader(stream);
                //...
                //3. DataSet - The result of each spreadsheet will be created in the result.Tables
                while (excelReader.Read())
                {
                    List <string> colList  = new List <string>();
                    var           colCount = excelReader.FieldCount;
                    for (int i = 0; i < colCount; i++)
                    {
                        if (!excelReader.IsDBNull(i))
                        {
                            colList.Add(excelReader[i].ToString());
                        }
                        else
                        {
                            colList.Add(Empty);
                        }
                    }
                    onRowRead(excelReader.Depth, colList);
                }

                excelReader.Close();
                excelReader.Dispose();
                stream.Close();
                stream.Dispose();
            }
        }
    /// <summary>
    /// Gets the Excel data from current spreadsheet
    /// </summary>
    /// <returns>The spreadsheet data table.</returns>
    /// <param name="excelReader">Excel Reader.</param>
    private DataTable GetExcelSheetData(IExcelDataReader excelReader)
    {
        if (excelReader == null)
        {
            Debug.LogError("Excel To Json Converter: Excel Reader is null. Cannot read data");
            return(null);
        }

        // Ignore sheets which start with ~
        Regex sheetNameRegex = new Regex(@"^~.*$");

        if (sheetNameRegex.IsMatch(excelReader.Name))
        {
            return(null);
        }

        // Create the table with the spreadsheet name
        DataTable table = new DataTable(excelReader.Name);

        table.Clear();

        string value = "";
        bool   rowIsEmpty;

        // Read the rows and columns
        while (excelReader.Read())
        {
            DataRow row = table.NewRow();
            rowIsEmpty = true;

            for (int i = 0; i < excelReader.FieldCount; i++)
            {
                // If the column is null and this is the first row, skip
                // to next iteration (do not want to include empty columns)
                if (excelReader.IsDBNull(i) &&
                    (excelReader.Depth == 1 || i > table.Columns.Count - 1))
                {
                    continue;
                }

                value = excelReader.IsDBNull(i) ? "" : excelReader.GetString(i);

                // If this is the first row, add the values as columns
                if (excelReader.Depth == 1)
                {
                    table.Columns.Add(value);
                }
                else                 // Otherwise, add as rows
                {
                    row[table.Columns[i]] = value;
                }

                if (!string.IsNullOrEmpty(value))
                {
                    rowIsEmpty = false;
                }
            }

            // Add the row to the table if it was not column headers and
            // the row was not empty
            if (excelReader.Depth != 1 && !rowIsEmpty)
            {
                table.Rows.Add(row);
            }
        }

        return(table);
    }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            ro_empleado_Bus         bus_empleado = new ro_empleado_Bus();
            Af_Activo_fijo_tipo_Bus bus_tipo     = new Af_Activo_fijo_tipo_Bus();

            Af_Activo_fijo_tipo_List             ListaTipo       = new Af_Activo_fijo_tipo_List();
            List <Af_Activo_fijo_tipo_Info>      Lista_Tipo      = new List <Af_Activo_fijo_tipo_Info>();
            Af_Activo_fijo_Categoria_List        ListaCategoria  = new Af_Activo_fijo_Categoria_List();
            List <Af_Activo_fijo_Categoria_Info> Lista_Categoria = new List <Af_Activo_fijo_Categoria_Info>();
            Af_Departamento_List        ListaDepartamento        = new Af_Departamento_List();
            List <Af_Departamento_Info> Lista_Departamento       = new List <Af_Departamento_Info>();
            Af_Catalogo_List            ListaCatalogo            = new Af_Catalogo_List();
            List <Af_Catalogo_Info>     Lista_Catalogo           = new List <Af_Catalogo_Info>();
            Af_Activo_fijo_List         ListaActivoFijo          = new Af_Activo_fijo_List();
            List <Af_Activo_fijo_Info>  Lista_ActivoFijo         = new List <Af_Activo_fijo_Info>();
            //Af_Activo_fijo_CtaCble_List ListaActivoFijoCtaCble = new Af_Activo_fijo_CtaCble_List();
            List <Af_Activo_fijo_CtaCble_Info> Lista_ActivoFijoCtaCble = new List <Af_Activo_fijo_CtaCble_Info>();


            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Tipo
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        Af_Activo_fijo_tipo_Info info = new Af_Activo_fijo_tipo_Info
                        {
                            IdEmpresa              = IdEmpresa,
                            IdActivoFijoTipo       = Convert.ToInt32(reader.GetValue(0)),
                            CodActivoFijo          = reader.GetString(1),
                            Af_Descripcion         = reader.GetString(2),
                            Af_Porcentaje_depre    = Convert.ToDouble(reader.GetValue(3)),
                            Af_anio_depreciacion   = Convert.ToInt32(reader.GetValue(4)),
                            IdCtaCble_Activo       = Convert.ToString(reader.GetValue(6)),
                            IdCtaCble_Dep_Acum     = Convert.ToString(reader.GetValue(7)),
                            IdCtaCble_Gastos_Depre = Convert.ToString(reader.GetValue(8)),
                            Se_Deprecia            = reader.GetString(5) == "SI" ? true : false,
                            IdCtaCble_CostoVenta   = Convert.ToString(reader.GetValue(9)),
                            IdCtaCble_Mejora       = Convert.ToString(reader.GetValue(10)),
                            IdCtaCble_Baja         = Convert.ToString(reader.GetValue(11)),
                            IdCtaCble_Retiro       = Convert.ToString(reader.GetValue(12)),
                            IdUsuario              = SessionFixed.IdUsuario
                        };
                        Lista_Tipo.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaTipo.set_list(Lista_Tipo, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Categoria
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        Af_Activo_fijo_Categoria_Info info = new Af_Activo_fijo_Categoria_Info
                        {
                            IdEmpresa        = IdEmpresa,
                            IdCategoriaAF    = Convert.ToInt32(reader.GetValue(0)),
                            IdActivoFijoTipo = Convert.ToInt32(reader.GetValue(1)),
                            CodCategoriaAF   = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(2))) ? null : Convert.ToString(reader.GetValue(2)),
                            Descripcion      = Convert.ToString(reader.GetValue(3)),
                            IdUsuario        = SessionFixed.IdUsuario
                        };
                        Lista_Categoria.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaCategoria.set_list(Lista_Categoria, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region Departamento
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        Af_Departamento_Info info = new Af_Departamento_Info
                        {
                            IdEmpresa         = IdEmpresa,
                            IdDepartamento    = Convert.ToInt32(reader.GetValue(0)),
                            Descripcion       = Convert.ToString(reader.GetValue(1)),
                            IdUsuarioCreacion = SessionFixed.IdUsuario
                        };
                        Lista_Departamento.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaDepartamento.set_list(Lista_Departamento, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region Catalogo
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        Af_Catalogo_Info info = new Af_Catalogo_Info
                        {
                            IdCatalogo     = Convert.ToString(reader.GetValue(0)),
                            IdTipoCatalogo = Convert.ToString(reader.GetValue(1)),
                            Descripcion    = Convert.ToString(reader.GetValue(2)),
                            IdUsuario      = SessionFixed.IdUsuario
                        };
                        info.IdCatalogo     = info.IdCatalogo.Trim();
                        info.IdTipoCatalogo = info.IdTipoCatalogo.Trim();

                        Lista_Catalogo.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaCatalogo.set_list(Lista_Catalogo, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region ActivoFijo
                var ListaEmpleado = bus_empleado.get_list_combo(IdEmpresa);
                ro_empleado_info_list Lista_Empleado = new ro_empleado_info_list();
                Lista_Empleado.set_list(ListaEmpleado);

                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        var IdTipo    = Convert.ToInt32(reader.GetValue(3));
                        var ini_depre = Convert.ToDateTime(reader.GetValue(13));
                        var info_empleado_custodio  = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(23))).FirstOrDefault();
                        var info_empleado_encargado = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(22))).FirstOrDefault();
                        var info_tipo_activofijo    = ListaTipo.get_list(IdTransaccionSession).Where(q => q.IdActivoFijoTipo == IdTipo).FirstOrDefault();

                        Af_Activo_fijo_Info info = new Af_Activo_fijo_Info
                        {
                            IdEmpresa                = IdEmpresa,
                            IdUsuario                = SessionFixed.IdUsuario,
                            IdActivoFijo             = Convert.ToInt32(reader.GetValue(0)),
                            CodActivoFijo            = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(1))) ? null : Convert.ToString(reader.GetValue(1)),
                            Af_Codigo_Barra          = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(24))) ? null : Convert.ToString(reader.GetValue(24)),
                            Af_Nombre                = Convert.ToString(reader.GetValue(2)),
                            IdCategoriaAF            = Convert.ToInt32(reader.GetValue(4)),
                            IdActivoFijoTipo         = Convert.ToInt32(reader.GetValue(3)),
                            IdSucursal               = Convert.ToInt32(reader.GetValue(5)),
                            IdDepartamento           = Convert.ToInt32(reader.GetValue(6)),
                            IdCatalogo_Marca         = Convert.ToString(reader.GetValue(7)),
                            IdCatalogo_Modelo        = Convert.ToString(reader.GetValue(8)),
                            IdCatalogo_Color         = Convert.ToString(reader.GetValue(10)),
                            IdTipoCatalogo_Ubicacion = Convert.ToString(reader.GetValue(11)),
                            IdEmpleadoCustodio       = info_empleado_custodio.IdEmpleado,
                            IdEmpleadoEncargado      = info_empleado_encargado.IdEmpleado,
                            Af_fecha_compra          = Convert.ToDateTime(reader.GetValue(12)),
                            Af_fecha_ini_depre       = ini_depre,
                            Af_costo_compra          = Convert.ToDouble(reader.GetValue(15)),
                            Af_Depreciacion_acum     = Convert.ToDouble(reader.GetValue(16)),
                            Af_ValorSalvamento       = Convert.ToDouble(reader.GetValue(25)),
                            Af_NumSerie              = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(9))) ? null : Convert.ToString(reader.GetValue(9)),
                            Af_NumPlaca              = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(21))) ? null : Convert.ToString(reader.GetValue(21)),
                            Estado_Proceso           = "TIP_ESTADO_AF_ACTIVO",
                            Af_fecha_fin_depre       = ini_depre.AddYears(info_tipo_activofijo.Af_anio_depreciacion),
                            Af_Meses_depreciar       = (info_tipo_activofijo.Af_anio_depreciacion * 12),
                            Af_porcentaje_deprec     = info_tipo_activofijo.Af_Porcentaje_depre,
                            Af_Vida_Util             = info_tipo_activofijo.Af_anio_depreciacion,
                            Af_observacion           = Convert.ToString(reader.GetValue(20)),
                            Cantidad = Convert.ToInt32(reader.GetValue(26))
                        };

                        Lista_ActivoFijo.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaActivoFijo.set_list(Lista_ActivoFijo, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region ActivoFijo_CtaCble
                //while (reader.Read())
                //{
                //    if (!reader.IsDBNull(0) && cont > 0)
                //    {
                //        Af_Activo_fijo_CtaCble_Info info = new Af_Activo_fijo_CtaCble_Info
                //        {
                //            IdEmpresa = IdEmpresa,
                //            IdActivoFijo = Convert.ToInt32(reader.GetValue(0)),
                //            IdDepartamento = Convert.ToInt32(reader.GetValue(1)),
                //            IdCtaCble = Convert.ToString(reader.GetValue(2)),
                //            Porcentaje = Convert.ToDouble(reader.GetValue(3))
                //        };
                //        Lista_ActivoFijoCtaCble.Add(info);
                //    }
                //    else
                //        cont++;
                //}
                //ListaActivoFijoCtaCble.set_list(Lista_ActivoFijoCtaCble, IdTransaccionSession);
                #endregion
            }
        }
Beispiel #24
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            fa_cliente_tipo_List                            ListaClienteTipo          = new fa_cliente_tipo_List();
            List <fa_cliente_tipo_Info>                     Lista_ClienteTipo         = new List <fa_cliente_tipo_Info>();
            fa_cliente_List                                 ListaCliente              = new fa_cliente_List();
            List <fa_cliente_Info>                          Lista_Cliente             = new List <fa_cliente_Info>();
            fa_cliente_contactos_List                       List_fa_cliente_contactos = new fa_cliente_contactos_List();
            List <fa_cliente_contactos_Info>                Lista_ClienteContactos    = new List <fa_cliente_contactos_Info>();
            fa_cliente_x_fa_Vendedor_x_sucursal_list        List_fa_cliente_x_fa_Vendedor_x_sucursal = new fa_cliente_x_fa_Vendedor_x_sucursal_list();
            List <fa_cliente_x_fa_Vendedor_x_sucursal_Info> Lista_ClienteVendedor = new List <fa_cliente_x_fa_Vendedor_x_sucursal_Info>();

            tb_persona_Bus bus_persona = new tb_persona_Bus();

            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion

            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region ClienteTipo
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        fa_cliente_tipo_Info info = new fa_cliente_tipo_Info
                        {
                            IdEmpresa               = IdEmpresa,
                            Idtipo_cliente          = Convert.ToInt32(reader.GetValue(0)),
                            Cod_cliente_tipo        = Convert.ToString(reader.GetValue(1)),
                            Descripcion_tip_cliente = Convert.ToString(reader.GetValue(2)),
                            IdCtaCble_CXC_Cred      = Convert.ToString(reader.GetValue(3)),
                            IdUsuario               = SessionFixed.IdUsuario
                        };
                        Lista_ClienteTipo.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaClienteTipo.set_list(Lista_ClienteTipo, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Cliente
                var lst_persona = bus_persona.get_list(false);

                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        var             return_naturaleza    = "";
                        var             cedula_ruc           = (Convert.ToString(reader.GetValue(3))).Trim();
                        tb_persona_Info info_persona         = new tb_persona_Info();
                        tb_persona_Info info_persona_cliente = new tb_persona_Info();

                        info_persona         = lst_persona.Where(q => q.pe_cedulaRuc == cedula_ruc).FirstOrDefault();
                        info_persona_cliente = info_persona;

                        if (cl_funciones.ValidaIdentificacion(Convert.ToString(reader.GetValue(2)), Convert.ToString(reader.GetValue(4)), cedula_ruc, ref return_naturaleza))
                        {
                            if (info_persona == null)
                            {
                                tb_persona_Info info_ = new tb_persona_Info
                                {
                                    pe_Naturaleza       = Convert.ToString(reader.GetValue(4)),
                                    pe_nombreCompleto   = Convert.ToString(reader.GetValue(6)) + ' ' + Convert.ToString(reader.GetValue(7)),
                                    pe_razonSocial      = Convert.ToString(reader.GetValue(5)),
                                    pe_apellido         = Convert.ToString(reader.GetValue(6)),
                                    pe_nombre           = Convert.ToString(reader.GetValue(7)),
                                    IdTipoDocumento     = Convert.ToString(reader.GetValue(2)),
                                    pe_cedulaRuc        = cedula_ruc,
                                    pe_direccion        = Convert.ToString(reader.GetValue(9)),
                                    pe_telfono_Contacto = Convert.ToString(reader.GetValue(10)),
                                    pe_celular          = Convert.ToString(reader.GetValue(11)),
                                    pe_correo           = Convert.ToString(reader.GetValue(8)),
                                };
                                info_persona_cliente = info_;
                            }
                            else
                            {
                                info_persona_cliente = bus_persona.get_info(info_persona.IdPersona);
                                var x = Convert.ToString(reader.GetValue(4));
                                info_persona_cliente.pe_Naturaleza       = x;
                                info_persona_cliente.pe_nombreCompleto   = Convert.ToString(reader.GetValue(6)) + ' ' + Convert.ToString(reader.GetValue(7));
                                info_persona_cliente.pe_razonSocial      = Convert.ToString(reader.GetValue(5));
                                info_persona_cliente.pe_apellido         = Convert.ToString(reader.GetValue(6));
                                info_persona_cliente.pe_nombre           = Convert.ToString(reader.GetValue(7));
                                info_persona_cliente.IdTipoDocumento     = Convert.ToString(reader.GetValue(2));
                                info_persona_cliente.pe_cedulaRuc        = cedula_ruc;
                                info_persona_cliente.pe_direccion        = Convert.ToString(reader.GetValue(9));
                                info_persona_cliente.pe_telfono_Contacto = Convert.ToString(reader.GetValue(10));
                                info_persona_cliente.pe_celular          = Convert.ToString(reader.GetValue(11));
                                info_persona_cliente.pe_correo           = Convert.ToString(reader.GetValue(8));
                            }

                            info_persona_cliente.pe_Naturaleza     = return_naturaleza;
                            info_persona_cliente.pe_nombreCompleto = (info_persona_cliente.pe_razonSocial != "" ? info_persona_cliente.pe_razonSocial : (info_persona_cliente.pe_apellido + ' ' + info_persona.pe_nombre));

                            var             CtaCbleClase = Lista_ClienteTipo.Where(q => q.Idtipo_cliente == Convert.ToInt32(reader.GetValue(13))).FirstOrDefault();
                            fa_cliente_Info info         = new fa_cliente_Info
                            {
                                IdEmpresa              = IdEmpresa,
                                IdPersona              = info_persona_cliente.IdPersona,
                                IdCliente              = Convert.ToInt32(reader.GetValue(0)),
                                Codigo                 = Convert.ToString(reader.GetValue(1)),
                                Idtipo_cliente         = Convert.ToInt32(reader.GetValue(13)),
                                cl_plazo               = Convert.ToInt32(reader.GetValue(15)),
                                cl_Cupo                = Convert.ToDouble(reader.GetValue(16)),
                                IdCtaCble_cxc_Credito  = CtaCbleClase == null ? null: CtaCbleClase.IdCtaCble_CXC_Cred,
                                es_empresa_relacionada = (Convert.ToString(reader.GetValue(12)) == "SI") ? true : false,
                                EsClienteExportador    = false,
                                IdNivel                = 1,
                                IdTipoCredito          = "CON",
                                FormaPago              = "01",
                                IdUsuario              = SessionFixed.IdUsuario,
                                IdCiudad               = Convert.ToString(reader.GetValue(18)),
                                IdParroquia            = Convert.ToString(reader.GetValue(19)),
                                Celular                = Convert.ToString(reader.GetValue(11)),
                                Correo                 = Convert.ToString(reader.GetValue(8)),
                                Direccion              = Convert.ToString(reader.GetValue(9)),
                                Telefono               = Convert.ToString(reader.GetValue(10))
                            };

                            fa_cliente_contactos_Info info_cliente_contacto = new fa_cliente_contactos_Info
                            {
                                IdEmpresa   = IdEmpresa,
                                IdContacto  = 1,
                                IdCiudad    = Convert.ToString(reader.GetValue(18)),
                                IdParroquia = Convert.ToString(reader.GetValue(19)),
                                Celular     = Convert.ToString(reader.GetValue(11)),
                                Correo      = Convert.ToString(reader.GetValue(8)),
                                Direccion   = Convert.ToString(reader.GetValue(9)),
                                Nombres     = (Convert.ToString(reader.GetValue(4)) == "NATU") ? Convert.ToString(reader.GetValue(6)) + ' ' + Convert.ToString(reader.GetValue(7)) : Convert.ToString(reader.GetValue(5)),
                                Telefono    = Convert.ToString(reader.GetValue(10)),
                            };

                            info.lst_fa_cliente_contactos = new List <fa_cliente_contactos_Info>();
                            info.lst_fa_cliente_contactos.Add(info_cliente_contacto);
                            info.Lst_fa_cliente_x_fa_Vendedor_x_sucursal = new List <fa_cliente_x_fa_Vendedor_x_sucursal_Info>();
                            info.info_persona = info_persona_cliente;

                            if (Lista_Cliente.Where(q => q.info_persona.pe_cedulaRuc == info_persona_cliente.pe_cedulaRuc).Count() == 0)
                            {
                                Lista_Cliente.Add(info);
                            }
                        }
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaCliente.set_list(Lista_Cliente, IdTransaccionSession);
                #endregion
            }
        }
        public static void FileUploadComplete_marcaciones(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            int cont = 0;
            ro_empleado_info_list empleado_info_list = new ro_empleado_info_list();
            ro_marcaciones_x_empleado_detLis_Info EmpleadoNovedadCargaMasiva_detLis_Info = new ro_marcaciones_x_empleado_detLis_Info();
            List <ro_marcaciones_x_empleado_Info> lista_novedades = new List <ro_marcaciones_x_empleado_Info>();
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);

            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);

            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                DateTime Fecha_registro;
                DateTime marcacion;
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        if (cont != 0)
                        {
                            string cedua    = reader.GetString(0);
                            var    empleado = empleado_info_list.get_list(IdTransaccionSession).Where(v => v.pe_cedulaRuc == cedua).FirstOrDefault();
                            if (empleado != null)
                            {
                                if (!reader.IsDBNull(2))// si tiene fehca de marcacion
                                {
                                    Fecha_registro = Convert.ToDateTime(reader.GetDateTime(2));
                                    if (!reader.IsDBNull(3))// si tiene entrada del primer turno
                                    {
                                        marcacion = Convert.ToDateTime(reader.GetValue(3));
                                        if (marcacion.Hour != 0)
                                        {
                                            ro_marcaciones_x_empleado_Info info = new ro_marcaciones_x_empleado_Info
                                            {
                                                IdEmpleado       = empleado.IdEmpleado,
                                                IdEmpresa        = empleado.IdEmpresa,
                                                es_fechaRegistro = Fecha_registro,

                                                IdCalendadrio      = Convert.ToInt32(Fecha_registro.ToString("ddMMyyyy")),
                                                IdNomina           = empleado.IdTipoNomina,
                                                IdUsuario          = SessionFixed.IdUsuario,
                                                es_Hora            = new TimeSpan(marcacion.Hour, marcacion.Minute, 0),
                                                IdTipoMarcaciones  = cl_enumeradores.eTipoMarcacionRRHH.IN1.ToString(),
                                                pe_NombreCompleato = empleado.Empleado,
                                                pe_cedula          = cedua,
                                                EstadoBool         = true,
                                                IdRegistro         = cont++
                                            };
                                            lista_novedades.Add(info);
                                        }
                                    }


                                    if (!reader.IsDBNull(4))// si tiene salida del primer turno
                                    {
                                        marcacion = Convert.ToDateTime(reader.GetValue(4));
                                        if (marcacion.Hour != 0)
                                        {
                                            ro_marcaciones_x_empleado_Info info = new ro_marcaciones_x_empleado_Info
                                            {
                                                IdEmpleado         = empleado.IdEmpleado,
                                                IdEmpresa          = empleado.IdEmpresa,
                                                es_fechaRegistro   = Fecha_registro,
                                                IdCalendadrio      = Convert.ToInt32(Fecha_registro.ToString("ddMMyyyy")),
                                                IdNomina           = empleado.IdTipoNomina,
                                                IdUsuario          = SessionFixed.IdUsuario,
                                                es_Hora            = new TimeSpan(marcacion.Hour, marcacion.Minute, 0),
                                                IdTipoMarcaciones  = cl_enumeradores.eTipoMarcacionRRHH.OUT1.ToString(),
                                                pe_NombreCompleato = empleado.Empleado,
                                                pe_cedula          = cedua,
                                                EstadoBool         = true,
                                                IdRegistro         = cont++
                                            };
                                            lista_novedades.Add(info);
                                        }
                                    }

                                    if (!reader.IsDBNull(5))// si tiene entrada del segundo turno
                                    {
                                        marcacion = Convert.ToDateTime(reader.GetValue(5));
                                        if (marcacion.Hour != 0)
                                        {
                                            ro_marcaciones_x_empleado_Info info = new ro_marcaciones_x_empleado_Info
                                            {
                                                IdEmpleado         = empleado.IdEmpleado,
                                                IdEmpresa          = empleado.IdEmpresa,
                                                es_fechaRegistro   = Fecha_registro,
                                                IdCalendadrio      = Convert.ToInt32(Fecha_registro.ToString("ddMMyyyy")),
                                                IdNomina           = empleado.IdTipoNomina,
                                                IdUsuario          = SessionFixed.IdUsuario,
                                                es_Hora            = new TimeSpan(marcacion.Hour, marcacion.Minute, 0),
                                                IdTipoMarcaciones  = cl_enumeradores.eTipoMarcacionRRHH.IN2.ToString(),
                                                pe_NombreCompleato = empleado.Empleado,
                                                pe_cedula          = cedua,
                                                EstadoBool         = true,
                                                IdRegistro         = cont++
                                            };
                                            lista_novedades.Add(info);
                                        }
                                    }


                                    if (reader.IsDBNull(6))// si tiene salida del segundo turno
                                    {
                                        marcacion = Convert.ToDateTime(reader.GetValue(6));
                                        if (marcacion.Hour != 0)
                                        {
                                            ro_marcaciones_x_empleado_Info info = new ro_marcaciones_x_empleado_Info
                                            {
                                                IdEmpleado       = empleado.IdEmpleado,
                                                IdEmpresa        = empleado.IdEmpresa,
                                                es_fechaRegistro = Fecha_registro,

                                                IdCalendadrio      = Convert.ToInt32(Fecha_registro.ToString("ddMMyyyy")),
                                                IdNomina           = empleado.IdTipoNomina,
                                                IdUsuario          = SessionFixed.IdUsuario,
                                                es_Hora            = new TimeSpan(marcacion.Hour, marcacion.Minute, 0),
                                                IdTipoMarcaciones  = cl_enumeradores.eTipoMarcacionRRHH.OUT2.ToString(),
                                                pe_NombreCompleato = empleado.Empleado,
                                                pe_cedula          = cedua,
                                                EstadoBool         = true,
                                                IdRegistro         = cont++
                                            };
                                            lista_novedades.Add(info);
                                        }
                                    }
                                }
                            }
                        }
                        cont++;
                    }
                }
                EmpleadoNovedadCargaMasiva_detLis_Info.set_list(lista_novedades, Convert.ToDecimal(SessionFixed.IdTransaccionSession));
            }
        }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            tb_empresa_List         ListaEmpresa   = new tb_empresa_List();
            List <tb_empresa_Info>  Lista_Empresa  = new List <tb_empresa_Info>();
            tb_sucursal_List        ListaSucursal  = new tb_sucursal_List();
            List <tb_sucursal_Info> Lista_Sucursal = new List <tb_sucursal_Info>();
            tb_bodega_List          ListaBodega    = new tb_bodega_List();
            List <tb_bodega_Info>   Lista_Bodega   = new List <tb_bodega_Info>();


            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Empresa
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_empresa_Info info = new tb_empresa_Info
                        {
                            IdEmpresa              = Convert.ToInt32(reader.GetValue(0)),
                            codigo                 = Convert.ToString(reader.GetValue(1)),
                            em_nombre              = Convert.ToString(reader.GetValue(2)),
                            RazonSocial            = Convert.ToString(reader.GetValue(3)),
                            NombreComercial        = Convert.ToString(reader.GetValue(4)),
                            ContribuyenteEspecial  = Convert.ToString(reader.GetValue(5)),
                            em_ruc                 = Convert.ToString(reader.GetValue(6)),
                            em_gerente             = Convert.ToString(reader.GetValue(7)),
                            em_contador            = Convert.ToString(reader.GetValue(8)),
                            em_rucContador         = Convert.ToString(reader.GetValue(9)),
                            em_telefonos           = Convert.ToString(reader.GetValue(10)),
                            em_direccion           = Convert.ToString(reader.GetValue(11)),
                            em_fechaInicioContable = reader.GetDateTime(12),
                            cod_entidad_dinardap   = Convert.ToString(reader.GetValue(13)),
                            em_Email               = Convert.ToString(reader.GetValue(14))
                        };
                        info.em_fechaInicioActividad = info.em_fechaInicioContable;
                        Lista_Empresa.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaEmpresa.set_list(Lista_Empresa, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region Sucursal
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_sucursal_Info info = new tb_sucursal_Info
                        {
                            IdEmpresa                = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal               = Convert.ToInt32(reader.GetValue(1)),
                            codigo                   = Convert.ToString(reader.GetValue(2)),
                            Su_Descripcion           = Convert.ToString(reader.GetValue(3)),
                            Su_CodigoEstablecimiento = Convert.ToString(reader.GetValue(4)),
                            Su_Ruc                   = Convert.ToString(reader.GetValue(5)),
                            Su_JefeSucursal          = Convert.ToString(reader.GetValue(6)),
                            Su_Telefonos             = Convert.ToString(reader.GetValue(7)),
                            Su_Direccion             = Convert.ToString(reader.GetValue(8)),
                            IdUsuario                = SessionFixed.IdUsuario
                        };
                        Lista_Sucursal.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaSucursal.set_list(Lista_Sucursal, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Bodega
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_bodega_Info info = new tb_bodega_Info
                        {
                            IdEmpresa       = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal      = Convert.ToInt32(reader.GetValue(1)),
                            IdBodega        = Convert.ToInt32(reader.GetValue(2)),
                            cod_bodega      = Convert.ToString(reader.GetValue(3)),
                            bo_Descripcion  = Convert.ToString(reader.GetValue(4)),
                            IdCtaCtble_Inve = Convert.ToString(reader.GetValue(5)),
                            IdUsuario       = SessionFixed.IdUsuario
                        };
                        Lista_Bodega.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaBodega.set_list(Lista_Bodega, IdTransaccionSession);
                #endregion
            }
        }
        private static Song ReadSongFromSpreadsheetTab(IExcelDataReader reader)
        {
            var row                = 0;
            var currentLines       = new List <List <List <List <Note> > > >();
            var noteGroups         = new List <NoteGroup>();
            var instrumentMappings = new List <InstrumentMapping>();
            var instrumentOffsets  = new Dictionary <Instrument, int>();
            var instrumentVolumes  = new Dictionary <Instrument, double>();
            var masterVolume       = 1d;
            var beatsPerMinute     = 60d;

            while (reader.Read())
            {
                row++;

                if (!reader.IsDBNull(0) && reader.GetFieldType(0) == typeof(double))
                {
                    var noteNumber = (int)reader.GetDouble(0);
                    var noteName   = reader.GetString(1);
                    var isDrum     = Constants.Drums.Contains(noteName);

                    var notes = Enumerable.Range(2, reader.FieldCount - 2)
                                .Select(column => StringUtil.SplitString(Convert.ToString(reader.GetValue(column)), '_')
                                        .Select(rawNotes => rawNotes.Split(", ")
                                                .Select(rawNote =>
                    {
                        var noteMatch = SpreadsheetNoteRegex.Match(rawNote);
                        if (noteMatch.Success)
                        {
                            var length              = double.Parse(noteMatch.Groups[1].Value);
                            var sharpOrFlat         = noteMatch.Groups[2].Value;
                            var instrumentIndicator = noteMatch.Groups[3].Value;

                            var effectiveNoteNumber = sharpOrFlat switch { "#" => noteNumber + 1, "b" => noteNumber - 1, _ => noteNumber };
                            var instrument          = isDrum
                                            ? Instrument.Drumkit
                                            : instrumentIndicator switch
                            {
                                "P" => Instrument.Piano,
                                "B" => Instrument.BassGuitar,
                                "L" => Instrument.LeadGuitar,
                                "W" => Instrument.Sawtooth,
                                "Q" => Instrument.Square,
                                "R" => Instrument.Celesta,
                                "V" => Instrument.Vibraphone,
                                "T" => Instrument.PluckedStrings,
                                "S" => Instrument.SteelDrum,
                                _ => instrumentMappings.FirstOrDefault(mapping => mapping.RangeStart <= effectiveNoteNumber && effectiveNoteNumber <= mapping.RangeEnd)?.Instrument ?? Instrument.Piano
                            };
                            var noteOffset       = instrumentOffsets.TryGetValue(instrument, out var offsetValue) ? offsetValue : 0;
                            var instrumentVolume = instrumentVolumes.TryGetValue(instrument, out var instrumentVolumeValue) ? instrumentVolumeValue : 1;

                            return(new Note
                            {
                                Instrument = instrument,
                                Number = effectiveNoteNumber + noteOffset,
                                Pitch = isDrum ? effectiveNoteNumber * 5 : effectiveNoteNumber,
                                Name = isDrum ? noteName : $"{noteName[0]}{sharpOrFlat}{noteName.Substring(1)}",
                                Volume = instrumentVolume * masterVolume,
                                Length = length
                            });
                        }
                        else
                        {
                            return(null);
                        }
                    }).ToList()
                                                ).ToList()
                                        ).ToList();

                    currentLines.Add(notes);
                }
                else
                {
                    ProcessSpreadsheetLines(currentLines, noteGroups, ref beatsPerMinute);

                    if (!reader.IsDBNull(0) && reader.GetFieldType(0) == typeof(string))
                    {
                        switch (reader.GetString(0))
                        {
                        case "Instrument Mappings":
                            foreach (var column in Enumerable.Range(1, reader.FieldCount - 1))
                            {
                                var value = reader.GetValue(column);
                                if (value == null)
                                {
                                    continue;
                                }

                                var match = InstrumentMappingRegex.Match(Convert.ToString(value));

                                if (match.Success)
                                {
                                    var instrument = ParseInstrument(match.Groups[1].Value);
                                    var rangeStart = int.Parse(match.Groups[2].Value);
                                    var rangeEnd   = int.Parse(match.Groups[3].Value);

                                    instrumentMappings.Add(new InstrumentMapping {
                                        Instrument = instrument, RangeStart = rangeStart, RangeEnd = rangeEnd
                                    });
                                }
                                else
                                {
                                    Console.Error.WriteLine($"Unable to parse instrument mapping on sheet {reader.Name} row {row} column {column}");
                                }
                            }

                            break;

                        case "Instrument Offsets":
                            foreach (var column in Enumerable.Range(1, reader.FieldCount - 1))
                            {
                                var value = reader.GetValue(column);
                                if (value == null)
                                {
                                    continue;
                                }

                                var match = InstrumentOffsetRegex.Match(Convert.ToString(value));

                                if (match.Success)
                                {
                                    var instrument = ParseInstrument(match.Groups[1].Value);
                                    var offset     = int.Parse(match.Groups[2].Value);

                                    instrumentOffsets[instrument] = offset;
                                }
                                else
                                {
                                    Console.Error.WriteLine($"Unable to parse instrument offset on sheet {reader.Name} row {row} column {column}");
                                }
                            }

                            break;

                        case "Volume":
                            foreach (var column in Enumerable.Range(1, reader.FieldCount - 1))
                            {
                                var value = reader.GetValue(column);
                                if (value == null)
                                {
                                    continue;
                                }

                                var match = VolumeLevelRegex.Match(Convert.ToString(value));

                                if (match.Success)
                                {
                                    var instrumentName = match.Groups[1].Value;
                                    var volume         = double.Parse(match.Groups[2].Value) / 100;

                                    if (instrumentName.Length > 0)
                                    {
                                        var instrument = ParseInstrument(instrumentName);

                                        instrumentVolumes[instrument] = volume;
                                    }
                                    else
                                    {
                                        masterVolume = volume;
                                    }
                                }
                                else
                                {
                                    Console.Error.WriteLine($"Unable to parse volume level on sheet {reader.Name} row {row} column {column}");
                                }
                            }

                            break;
                        }
                    }
                }
            }

            // Process any remaining lines
            ProcessSpreadsheetLines(currentLines, noteGroups, ref beatsPerMinute);

            return(new Song
            {
                NoteGroups = noteGroups
            });
        }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            ct_anio_fiscal_List        ListaAnioFiscal = new ct_anio_fiscal_List();
            ct_plancta_List            ListaPlancta    = new ct_plancta_List();
            List <ct_plancta_Info>     ListaPlan       = new List <ct_plancta_Info>();
            List <ct_anio_fiscal_Info> ListaAnio       = new List <ct_anio_fiscal_Info>();

            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Plan de cuentas
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        //var IdCtaCble = Convert.ToString(reader.GetValue(0));
                        //var pc_clave_corta = reader.GetValue(1) == null || string.IsNullOrEmpty(reader.GetString(1)) ? "" : reader.GetString(1);
                        //var pc_Cuenta = reader.GetString(2);
                        //var IdCtaCIdCtaCblePadreble = reader.GetValue(3) == null || string.IsNullOrEmpty(Convert.ToString(reader.GetValue(3))) ? null : Convert.ToString(reader.GetValue(3));
                        //var pc_Naturaleza = Convert.ToString(reader.GetValue(4));
                        //var IdNivelCta = Convert.ToInt32(reader.GetValue(5));
                        //var pc_EsMovimiento_bool = Convert.ToString(reader.GetValue(6)) == "SI" ? true : false;
                        //var pc_EsMovimiento = Convert.ToString(reader.GetValue(6)) == "SI" ? "S" : "N";
                        //var IdGrupoCble = Convert.ToString(reader.GetValue(7));

                        ct_plancta_Info info = new ct_plancta_Info
                        {
                            IdEmpresa            = IdEmpresa,
                            IdCtaCble            = Convert.ToString(reader.GetValue(0)),
                            pc_clave_corta       = reader.GetValue(1) == null || string.IsNullOrEmpty(reader.GetString(1)) ? "" : reader.GetString(1),
                            pc_Cuenta            = reader.GetString(2),
                            IdCtaCblePadre       = reader.GetValue(3) == null || string.IsNullOrEmpty(Convert.ToString(reader.GetValue(3))) ? null : Convert.ToString(reader.GetValue(3)),
                            pc_Naturaleza        = Convert.ToString(reader.GetValue(4)),
                            IdNivelCta           = Convert.ToInt32(reader.GetValue(5)),
                            pc_EsMovimiento_bool = Convert.ToString(reader.GetValue(6)) == "SI" ? true : false,
                            pc_EsMovimiento      = Convert.ToString(reader.GetValue(6)) == "SI" ? "S" : "N",
                            IdGrupoCble          = Convert.ToString(reader.GetValue(7))
                        };
                        ListaPlan.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Cuentas contables por anio
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        int    Anio              = Convert.ToInt32(reader.GetValue(0));
                        string IdCtaCble         = reader.GetValue(1).ToString();
                        ct_anio_fiscal_Info info = new ct_anio_fiscal_Info
                        {
                            IdanioFiscal      = Anio,
                            af_fechaIni       = new DateTime(Anio, 1, 1),
                            af_fechaFin       = new DateTime(Anio, 12, 31),
                            info_anio_ctautil = new ct_anio_fiscal_x_cuenta_utilidad_Info
                            {
                                IdEmpresa    = IdEmpresa,
                                IdCtaCble    = IdCtaCble,
                                IdanioFiscal = Anio,
                            },
                        };
                        ListaAnio.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                #endregion

                ListaPlancta.set_list(ListaPlan, IdTransaccionSession);
                ListaAnioFiscal.set_list(ListaAnio, IdTransaccionSession);
            }
        }
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            string ruc_proveedor = "";
            List <cp_nota_DebCre_Info> Lista_NotaDebito = new List <cp_nota_DebCre_Info>();
            cp_nota_DebCre_List        ListaNotaDebito  = new cp_nota_DebCre_List();
            int     cont                 = 0;
            int     IdCbteCble_Nota      = 1;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);

            cp_proveedor_Bus  bus_proveedor     = new cp_proveedor_Bus();
            tb_sucursal_Bus   bus_sucursal      = new tb_sucursal_Bus();
            cp_parametros_Bus bus_cp_parametros = new cp_parametros_Bus();
            #endregion

            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region NotaDebito
                var info_cp_parametro = bus_cp_parametros.get_info(IdEmpresa);

                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        ruc_proveedor = Convert.ToString(reader.GetValue(1)).Trim();
                        var info_proveedor           = bus_proveedor.get_info_x_num_cedula(IdEmpresa, ruc_proveedor);
                        var lst_sucursal             = bus_sucursal.get_list(IdEmpresa, false);
                        var Su_CodigoEstablecimiento = Convert.ToString(reader.GetValue(0)).Trim();
                        var IdSucursal = Convert.ToInt32(reader.GetValue(0));

                        if (info_proveedor != null && info_proveedor.IdProveedor != 0)
                        {
                            cp_nota_DebCre_Info info = new cp_nota_DebCre_Info
                            {
                                IdEmpresa       = IdEmpresa,
                                IdCbteCble_Nota = IdCbteCble_Nota++,
                                IdTipoCbte_Nota = Convert.ToInt32(info_cp_parametro.pa_TipoCbte_ND),
                                DebCre          = "D",
                                IdTipoNota      = "T_TIP_NOTA_INT",
                                IdProveedor     = info_proveedor.IdProveedor,
                                //IdSucursal = lst_sucursal.Where(q => q.Su_CodigoEstablecimiento == Su_CodigoEstablecimiento).FirstOrDefault().IdSucursal,
                                IdSucursal         = IdSucursal,
                                cn_fecha           = Convert.ToDateTime(reader.GetValue(5)),
                                Fecha_contable     = Convert.ToDateTime(reader.GetValue(5)),
                                cn_Fecha_vcto      = Convert.ToDateTime(reader.GetValue(6)),
                                cn_observacion     = Convert.ToString(reader.GetValue(7)),
                                cn_subtotal_iva    = 0,
                                cn_subtotal_siniva = Convert.ToDouble(reader.GetValue(4)),
                                cn_baseImponible   = 0,
                                cn_Por_iva         = 12,
                                cn_valoriva        = 0,
                                cn_Ice_base        = 0,
                                cn_Ice_por         = 0,
                                cn_Ice_valor       = 0,
                                cn_Serv_por        = 0,
                                cn_Serv_valor      = 0,
                                cn_BaseSeguro      = 0,
                                cn_total           = Convert.ToDecimal(reader.GetValue(4)),
                                cn_vaCoa           = "N",
                                cod_nota           = Convert.ToString(reader.GetValue(2)),
                                IdUsuario          = SessionFixed.IdUsuario,
                                Fecha_Transac      = DateTime.Now,
                                Nombre_proveedor   = info_proveedor.info_persona.pe_razonSocial
                            };

                            Lista_NotaDebito.Add(info);
                        }
                        else
                        {
                            cp_nota_DebCre_Info info = new cp_nota_DebCre_Info
                            {
                                IdEmpresa          = IdEmpresa,
                                IdCbteCble_Nota    = IdCbteCble_Nota++,
                                IdTipoCbte_Nota    = Convert.ToInt32(info_cp_parametro.pa_TipoCbte_ND),
                                DebCre             = "D",
                                IdTipoNota         = "T_TIP_NOTA_INT",
                                cn_fecha           = Convert.ToDateTime(reader.GetValue(5)),
                                Fecha_contable     = Convert.ToDateTime(reader.GetValue(5)),
                                cn_Fecha_vcto      = Convert.ToDateTime(reader.GetValue(6)),
                                cn_observacion     = Convert.ToString(reader.GetValue(7)),
                                cn_subtotal_iva    = 0,
                                cn_subtotal_siniva = Convert.ToDouble(reader.GetValue(4)),
                                cn_baseImponible   = 0,
                                cn_Por_iva         = 12,
                                cn_valoriva        = 0,
                                cn_Ice_base        = 0,
                                cn_Ice_por         = 0,
                                cn_Ice_valor       = 0,
                                cn_Serv_por        = 0,
                                cn_Serv_valor      = 0,
                                cn_BaseSeguro      = 0,
                                cn_total           = Convert.ToDecimal(reader.GetValue(4)),
                                cn_vaCoa           = "N",
                                cod_nota           = Convert.ToString(reader.GetValue(2)),
                                IdUsuario          = SessionFixed.IdUsuario,
                                Fecha_Transac      = DateTime.Now,
                                Nombre_proveedor   = ruc_proveedor
                            };
                            Lista_NotaDebito.Add(info);
                        }
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaNotaDebito.set_list(Lista_NotaDebito, IdTransaccionSession);
                #endregion
            }
        }
Beispiel #30
0
 public bool IsDBNull(int i) => _reader.IsDBNull(i);
Beispiel #31
0
    void ReadTables(IExcelDataReader _excelReader)
    {
        if (_excelReader == null)
        {
            return;
        }

        do
        {
            int tempReadLine   = 0;
            int tempFieldCount = 0;

            string tempReaderName = _excelReader.Name;
            if (tempReaderName.Contains("#"))
            {
                continue;
            }

            if (!tablesDataList.ContainsKey(tempReaderName))
            {
                tablesDataList.Add(tempReaderName, new List <List <string> >());
            }

            List <List <string> > tempDataValue = new List <List <string> >();
            while (_excelReader.Read())
            {
                if (_excelReader.IsDBNull(0))
                {
                    break;
                }

                // 第一行的是参数名,这个是必须存在的值,长度以这个为标准
                if (tempReadLine == 0)
                {
                    for (int i = 0; i < _excelReader.FieldCount; i++)
                    {
                        if (_excelReader.IsDBNull(i))
                        {
                            continue;
                        }

                        string temp = _excelReader.GetString(i);

                        tempFieldCount++;
                    }

                    tempReadLine++;
                }

                List <string> tempValue = new List <string>();
                for (int i = 0; i < tempFieldCount; i++)
                {
                    string value = _excelReader.IsDBNull(i) ? "" : _excelReader.GetString(i);
                    tempValue.Add(value);
                }

                tempDataValue.Add(tempValue);
            }

            tablesDataList[tempReaderName] = tempDataValue;
        }while (_excelReader.NextResult());
    }