コード例 #1
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
            }
        }