public override MembershipUser GetUser(string username, bool userIsOnline) { USERS.RemoveAll(p => p.SessionExpires < DateTime.Now); try { var fn = USERS.FirstOrDefault(p => p.user.Sigla == username); if (fn != null) { return(fn.user == null ? null : new UsuarioMembership(fn.user, fn.roles, fn.clientUser)); } else { using (var db = new GSPSOEntities()) { Usu user = db.Usu.FirstOrDefault(o => o.Sigla == username && o.uactivo == "s"); //var permisos = (from frm in db.GS_FRMS // join acc in db.GS_AccFrm on frm.ID equals acc.Frm // where acc.Usu == user.ID // select frm.WebGS.Trim()).ToList(); var permisos = (from per in db.Permisos_GS_WEB join para in db.Parametros_GS_WEB on per.ID_Parametro equals para.ID_Parametro where per.ID_Usu == user.ID select para.Controller).ToList(); var Clientes = (from clie in db.Clientes join per in db.Permisos on clie.ID equals per.Clie where clie.Activo == "S" && per.Usu == user.ID select clie).ToList(); USERS.Add(new SessionUser() { user = user, roles = permisos, SessionExpires = DateTime.Now.AddMinutes(5), clientUser = Clientes }); return(user == null ? null : new UsuarioMembership(user, permisos, Clientes)); } } } catch (Exception ex) { return(null); } }
public override bool ValidateUser(string username, string password) { try { using (var db = new GSPSOEntities()) { var usu = db.Usu.Where(o => o.Sigla.Trim() == username.Trim() && o.pass.Trim() == password && o.uactivo == "s"); if (usu.Any()) { return(true); } else { return(false); } } } catch (Exception ex) { return(false); } }
public Helper(GSPSOEntities _db) { this._db = _db; }
public ActionResult CargaSoftland(DatosExcel[] data, int?clie, ValidaList[] validaciones, DateTime periodo, string tipoDoc) { try { foreach (var item in validaciones) { if (item.ValTot == false || item.ValFact == true || item.ValExtra == true /* || item.ValCta==false || item.ValCCost==false*/ || item.ValFechEmi == false) { return(JsonError("No se puede cargar a softland debido a que tiene errores en su plantilla, revise su documento")); } } var cuentaIvaVentas = (from gs_ctas in _db.GS_Ctas where gs_ctas.Cta == 28 && gs_ctas.Clie == clie select gs_ctas.CodCta.Trim() ).FirstOrDefault(); if (cuentaIvaVentas == null) { return(JsonError("Solicite al administrador la creación de la IVA Debito")); } var cuentaCliente = (from gs_ctas in _db.GS_Ctas where gs_ctas.Cta == 27 && gs_ctas.Clie == clie select gs_ctas.CodCta.Trim() ).FirstOrDefault(); if (cuentaCliente == null) { return(JsonError("Solicite al administrador la creación de la cuenta del Cliente")); } var cuentaCargo = (from gs_ctas in _db.GS_Ctas where gs_ctas.Cta == 30 && gs_ctas.Clie == clie select gs_ctas.CodCta.Trim() ).FirstOrDefault(); if (cuentaCargo == null) { return(JsonError("Solicite al administrador la creación de la cuenta Contable Ventas")); } var cuentaCentCost = (from gs_ctas in _db.GS_Ctas where gs_ctas.Cta == 29 && gs_ctas.Clie == clie select gs_ctas.CodCta.Trim() ).FirstOrDefault(); if (cuentaCentCost == null) { return(JsonError("Solicite al administrador la creación de la cuenta Contable Ventas")); } var nomCli = _db.Clientes.FirstOrDefault(x => x.ID == clie).Ruta.Split('\\').Last(); var anio = periodo.ToString("yyyy"); var mes = periodo.ToString("MM"); List <SqlParameter> para = new List <SqlParameter>() { new SqlParameter("@base", System.Data.SqlDbType.NVarChar) { Value = nomCli }, new SqlParameter("@anio", System.Data.SqlDbType.NVarChar) { Value = anio }, new SqlParameter("@mes", System.Data.SqlDbType.NVarChar) { Value = mes }, new SqlParameter("@counts", System.Data.SqlDbType.Int) { Value = 0 } }; var numComp = PA_Almacenado(para, "Get_Comprobante_Rtn"); using (var db = new GSPSOEntities()) { db.Database.Connection.Open(); DataTable InsCwcpbte = new DataTable(); //crea columnas cpbte InsCwcpbte.Columns.Add(new DataColumn("CpbAno", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbNum", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("AreaCod", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbFec", typeof(DateTime))); InsCwcpbte.Columns.Add(new DataColumn("CpbMes", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbEst", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbTip", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbNui", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbGlo", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbImp", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbCon", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("Sistema", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("Proceso", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("Usuario", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbNormaIFRS", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbNormaTrib", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbAnoRev", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("CpbNumRev", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("FechaUiMod", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("SistemaMod", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("ProcesoMod", typeof(string))); InsCwcpbte.Columns.Add(new DataColumn("TipoLog", typeof(string))); InsCwcpbte.Rows.Add(anio, numComp.ToString(), "000", periodo, mes, "P", "T", "00000000", "Centralizacion de ventas del mes", "S", "S", "CW", "Comprobante", "softland", "S", "S", "0000", "00000000", null, null, null, null); DataTable InsCwmovim = new DataTable(); //Crear Columnas cwmovim InsCwmovim.Columns.Add(new DataColumn("CpbAno", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CpbNum", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovNum", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("PctCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CpbFec", typeof(DateTime))); InsCwmovim.Columns.Add(new DataColumn("CpbMes", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CcCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovFe", typeof(DateTime))); InsCwmovim.Columns.Add(new DataColumn("MovFv", typeof(DateTime))); InsCwmovim.Columns.Add(new DataColumn("MovDebe", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("MovHaber", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("MovDebeMa", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("MovHaberMa", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("MovGlosa", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovEquiv", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("FecPag", typeof(DateTime))); InsCwmovim.Columns.Add(new DataColumn("CodAux", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("TtdCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("NumDoc", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovTipDocRef", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovNumDocRef", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("AreaCod", typeof(string))); //////////////////HASTA ESTAS COLUMNAS UTILIZARE YO 22////////////////// InsCwmovim.Columns.Add(new DataColumn("CvCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("VendCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("UbicCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CajCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("IfCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovIfCant", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("DgaCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovDgCant", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("TipDocCb", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("NumDocCb", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("MonCod", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovNumCar", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovTC", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovNC", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovIPr", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MovAEquiv", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CODCPAG", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CbaNumMov", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("CbaAnoC", typeof(int))); InsCwmovim.Columns.Add(new DataColumn("GrabaDLib", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CpbOri", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CodBanco", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CodCtaCte", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("MtoTotal", typeof(float))); InsCwmovim.Columns.Add(new DataColumn("Cuota", typeof(int))); InsCwmovim.Columns.Add(new DataColumn("CuotaRef", typeof(int))); InsCwmovim.Columns.Add(new DataColumn("Marca", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("FecEmisionCh", typeof(DateTime))); InsCwmovim.Columns.Add(new DataColumn("PagueseA", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("Impreso", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("DliCoInt_Aperturas", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("Nro_Operacion", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("FormaDePag", typeof(int))); InsCwmovim.Columns.Add(new DataColumn("CpbNormaIFRS", typeof(string))); InsCwmovim.Columns.Add(new DataColumn("CpbNormaTrib", typeof(string))); DataTable InsDetli = new DataTable(); var afecTipo = _db.GS_TDoc.FirstOrDefault(x => x.CodDoc == tipoDoc).Tipo; //Crea columnas en detli InsDetli.Columns.Add(new DataColumn("CpbAno", typeof(string))); InsDetli.Columns.Add(new DataColumn("CpbNum", typeof(string))); InsDetli.Columns.Add(new DataColumn("MovNum", typeof(float))); InsDetli.Columns.Add(new DataColumn("TtdCod", typeof(string))); InsDetli.Columns.Add(new DataColumn("MonCod", typeof(string))); InsDetli.Columns.Add(new DataColumn("DocumentoNulo", typeof(string))); InsDetli.Columns.Add(new DataColumn("DlinDoc", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliFeDoc", typeof(DateTime))); InsDetli.Columns.Add(new DataColumn("CodAux", typeof(string))); InsDetli.Columns.Add(new DataColumn("DliMto01", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto02", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto03", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto10", typeof(float))); InsDetli.Columns.Add(new DataColumn("Monto", typeof(float))); InsDetli.Columns.Add(new DataColumn("CpbFec", typeof(DateTime))); InsDetli.Columns.Add(new DataColumn("DetlDesde", typeof(string))); InsDetli.Columns.Add(new DataColumn("DetlHasta", typeof(string))); InsDetli.Columns.Add(new DataColumn("AreaCod", typeof(string))); ///////////////////////////hasta aca////////////// InsDetli.Columns.Add(new DataColumn("DliCoInt", typeof(string))); InsDetli.Columns.Add(new DataColumn("DliMto04", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto05", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto06", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto07", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto08", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMto09", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd01", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd02", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd03", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd04", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd05", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd06", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd07", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd08", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd09", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliMtoAd10", typeof(float))); InsDetli.Columns.Add(new DataColumn("MovEquiv", typeof(float))); InsDetli.Columns.Add(new DataColumn("LoteDespacho", typeof(int))); InsDetli.Columns.Add(new DataColumn("DliEquiv01", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv02", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv03", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv04", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv05", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv06", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv07", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv08", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv09", typeof(float))); InsDetli.Columns.Add(new DataColumn("DliEquiv10", typeof(float))); InsDetli.Columns.Add(new DataColumn("LibroMonedaBase", typeof(string))); var countMovim = 0; var countDetli = 0; foreach (var item in data) { /// inserta cta cargo /// if (tipoDoc.Substring(0, 1) == "N") { InsCwmovim.Rows.Add(anio, numComp.ToString(), countMovim, cuentaCargo, periodo, mes, cuentaCentCost.ToString(), DateTime.Parse(item.FechaEmision), DateTime.Parse(item.FechaEmision).AddMonths(1), item.Exento + item.Neto, 0, item.Exento + item.Neto, 0, tipoDoc + " " + item.NumFactura + " " + item.RazonSocial + " " + item.FechaEmision, 1, DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), tipoDoc, item.NumFactura, tipoDoc, item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } else { //De acuerdo al tipo de documento, se voltea el debe por haber InsCwmovim.Rows.Add(anio, numComp.ToString(), countMovim, cuentaCargo, periodo, mes, cuentaCentCost.ToString(), DateTime.Parse(item.FechaEmision), DateTime.Parse(item.FechaEmision).AddMonths(1), 0, item.Exento + item.Neto, 0, item.Exento + item.Neto, tipoDoc + " " + item.NumFactura + " " + item.RazonSocial + " " + item.FechaEmision, 1, DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), tipoDoc, item.NumFactura, tipoDoc, item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } countMovim = countMovim + 1; //inserta cuenta cliente InsCwmovim.Rows.Add(anio, numComp.ToString(), countMovim, cuentaCliente, periodo, mes, cuentaCentCost.ToString(), DateTime.Parse(item.FechaEmision), DateTime.Parse(item.FechaEmision).AddMonths(1), item.Total, 0, item.Total, 0, tipoDoc + " " + item.NumFactura + " " + item.RazonSocial + " " + item.FechaEmision, 1, DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), tipoDoc, item.NumFactura, tipoDoc, item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); countMovim = countMovim + 1; if (item.Iva > 0) { //inserta cuenta iva debito InsCwmovim.Rows.Add(anio, numComp.ToString(), countMovim, cuentaIvaVentas, periodo, mes, cuentaCentCost.ToString(), DateTime.Parse(item.FechaEmision), DateTime.Parse(item.FechaEmision).AddMonths(1), 0, item.Iva, 0, item.Iva, tipoDoc + " " + item.NumFactura + " " + item.RazonSocial + " " + item.FechaEmision, 1, DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), tipoDoc, item.NumFactura, tipoDoc, item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); countMovim = countMovim + 1; } if (afecTipo == "E") { //deacuerdo al tipo se cambia el delitmo 01 por el 02 InsDetli.Rows.Add(anio, numComp.ToString(), countDetli, tipoDoc, "01", "N", int.Parse(item.NumFactura), DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), 0, item.Neto, item.Iva, item.Total, item.Total, periodo, "00000000" + item.NumFactura, "00000000" + item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); countDetli = countDetli + 1; } else { InsDetli.Rows.Add(anio, numComp.ToString(), countDetli, tipoDoc, "01", "N", int.Parse(item.NumFactura), DateTime.Parse(item.FechaEmision), Helper.converRut(item.Rut, 1), item.Neto, 0, item.Iva, item.Total, item.Total, periodo, "00000000" + item.NumFactura, "00000000" + item.NumFactura, "000", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); countDetli = countDetli + 1; } } //comunicacion con la base de datos using (var conn = db.Database.Connection as SqlConnection) { SqlCommand cmd = new SqlCommand("PA_INS_CENT_EXCEL", conn); cmd.CommandType = CommandType.StoredProcedure; List <SqlParameter> param = new List <SqlParameter>() { new SqlParameter() { ParameterName = "@ListCpbte", SqlDbType = SqlDbType.Structured, Value = InsCwcpbte, TypeName = "ListaCwcpbte", }, new SqlParameter() { ParameterName = "@ListMovim", SqlDbType = SqlDbType.Structured, Value = InsCwmovim, TypeName = "ListaCwmovim", }, new SqlParameter() { ParameterName = "@ListDetli", SqlDbType = SqlDbType.Structured, Value = InsDetli, TypeName = "ListaCwdetli", }, new SqlParameter("@base", SqlDbType.NVarChar) { Value = nomCli } }; cmd.Parameters.AddRange(param.ToArray()); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { } ; }; }; }; return(JsonExito()); } catch (Exception e) { return(JsonError("Error: " + e.Message)); } }