public JsonResult modificarSociedad(string Id_Sociedad, string Abreviatura, string Nombre, string Id_SAP, string Sociedad_SAP, int Id, int lineaNegocio) { object respuesta = null; try { Sociedad oSociedad = db.Sociedad.Where(x => x.Id == Id && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); if (oSociedad != null) { oSociedad.AbreviaturaSociedad = Abreviatura; oSociedad.NombreSociedad = Nombre; oSociedad.Id_SAP = Id_SAP; oSociedad.Sociedad_SAP = Sociedad_SAP; oSociedad.Id_Sociedad = Id_Sociedad; Log log = new Log(); log.insertaBitacoraModificacion(oSociedad, "Id", oSociedad.Id, "Sociedad.html", Request.UserHostAddress); db.SaveChanges(); respuesta = new { success = true, results = "ok" }; } else { respuesta = new { success = true, results = "no" } }; } catch (Exception ex) { respuesta = new { success = false, results = ex.Message }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
protected void btnEditar_Command(object sender, CommandEventArgs e) { try { ValidaVariables(); //obtiene indice de la linea actualizar int index = Convert.ToInt32(e.CommandArgument); //Carga los datos del Sociedad Sociedad oSociedad = new Sociedad(grdSociedades.DataKeys[index].Value.ToString()); oSociedad.Cargar(); //Muestra los datos en los controles Session["Accion"] = "Editar"; txtID.Text = oSociedad.ID.ToString(); txtNombre.Text = oSociedad.Nombre; txtRFC.Text = oSociedad.RFC; txtBusArea.Text = oSociedad.BusinessArea; txtContArea.Text = oSociedad.ControllingArea; txtGralLeyerAcc.Text = oSociedad.GeneralLeyerAccount; txtCostCenter.Text = oSociedad.CostCenter; txtCtaProv.Text = oSociedad.CuentaProveedor; txtID.Enabled = false; divDetalle.Visible = true; } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message)); } }
protected void btnEliminar_Command(object sender, CommandEventArgs e) { try { ValidaVariables(); //Obtiene indice de la linea a actualizar int index = Convert.ToInt32(e.CommandArgument); //Carga la información a eliminar Sociedad oSociedad = new Sociedad(grdSociedades.DataKeys[index].Value.ToString()); if (oSociedad.ValidaBaja()) { oSociedad.Eliminar(((Usuario)Session["oUsuario"]).Id); NegocioPF.Sociedades oSociedades = new NegocioPF.Sociedades(); oSociedades.Cargar(); grdSociedades.DataSource = oSociedades.Datos; grdSociedades.DataBind(); MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgSociedadEliminada")); } else { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgSociedadAsociada")); } } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message)); } }
//modificar public JsonResult ModificarCostoFC(int Id, string Id_Acreedor, string nombre, string Id_Moneda, decimal Importe, DateTime Fecha_Inicio, DateTime Fecha_Fin, string Cuenta, string Id_Sociedad, int lineaNegocio) { object respuesta = null; CultureInfo cultureInfo = new CultureInfo("es-ES", false); CostoFR costofr = db.CostoFR.Where(x => x.Id == Id).SingleOrDefault(); //Trafico trafico = db.Trafico.Where(x => x.Id_TraficoTR == Id_TraficoTR && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1 && x.Sentido == "Costos").SingleOrDefault(); Acreedor acreedor = db.Acreedor.Where(x => x.Acreedor1 == Id_Acreedor && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); Operador operador = db.Operador.Where(x => x.Id_Operador == nombre && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); Moneda moneda = db.Moneda.Where(x => x.Moneda1 == Id_Moneda && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); CuentaResultado cuentaResultado = db.CuentaResultado.Where(x => x.Cuenta == Cuenta && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); Sociedad sociedad = db.Sociedad.Where(x => x.Id_Sociedad == Id_Sociedad && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); //Acreedor acreedor = db.Acreedor.Where(x => x.Acreedor1 == Id_Acreedor && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1); //costofr.Id_Operador = operador.Id; bool valid = true; var mensaje = ""; if (DateTime.Compare(Fecha_Inicio, Fecha_Fin) > 0) { valid = false; mensaje = "Fecha Inicio debe ser menor que Fecha Fin"; } if (valid) { try { costofr.TipoOperador = operador.Tipo_Operador; costofr.Operador = operador.Id_Operador; costofr.AcreedorSap = acreedor.Acreedor1; costofr.NombreProveedor = acreedor.NombreAcreedor; costofr.Moneda = moneda.Moneda1; costofr.Importe = Importe; costofr.Fecha_Inicio = Fecha_Inicio.ToShortDateString(); costofr.Fecha_Fin = Fecha_Fin.ToShortDateString(); costofr.CuentaR = cuentaResultado.Cuenta; costofr.SociedadGL = int.Parse(sociedad.Id_Sociedad); Log log = new Log(); log.insertaBitacoraModificacion(costofr, "Id", costofr.Id, "CostoFR.html", Request.UserHostAddress); db.SaveChanges(); respuesta = new { success = true, results = "ok" }; } catch (Exception ex) { var error = ex.Message; respuesta = new { success = false, results = "Hubo un error mientras se procesaba la petición" }; } } else { respuesta = new { success = false, results = mensaje }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
public JsonResult buscarSociedad(int Id) { object respuesta = null; try { Sociedad oSociedad = db.Sociedad.Where(x => x.Id == Id).SingleOrDefault(); respuesta = new { success = true, results = oSociedad }; } catch (Exception ex) { respuesta = new { success = false, results = ex.Message }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
public List <Sociedad> mapingSociedades(MySqlDataReader rdr) { List <Sociedad> sociedadList = new List <Sociedad>(); while (rdr.Read()) { Sociedad sociedad = new Sociedad(); sociedad.Cod = rdr[0].ToString(); sociedad.Razons = rdr[1].ToString(); sociedad.Nif = rdr[2].ToString(); sociedad.Codmoneda = rdr[3].ToString(); sociedadList.Add(sociedad); } rdr.Close(); return(sociedadList); }
public JsonResult borrarSociedad(string strID) { object respuesta = null; string strmsg = "ok"; string strSalto = "</br>"; bool blsucc = true; int Id = 0; strID = strID.TrimEnd(','); try { string[] Ids = strID.Split(','); for (int i = 0; i < Ids.Length; i++) { Id = int.Parse(Ids[i]); string strresp_val = funGralCtrl.ValidaRelacion("Sociedad", Id); if (strresp_val.Length == 0) { Sociedad oSociedad = db.Sociedad.Where(x => x.Id == Id).SingleOrDefault(); oSociedad.Activo = 0; Log log = new Log(); log.insertaNuevoOEliminado(oSociedad, "Eliminado", "Sociedad.html", Request.UserHostAddress); db.SaveChanges(); } else { strmsg = "El(Los) " + Ids.Length.ToString() + " registro(s) que quieres borrar se está(n) usando en el(los) catálogo(s) " + strSalto; strmsg = strmsg + strresp_val + strSalto; blsucc = false; break; } } respuesta = new { success = blsucc, result = strmsg }; } catch (Exception ex) { strmsg = ex.Message; respuesta = new { success = false, result = strmsg }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
public JsonResult agregarSociedad(string Abreviatura, string Nombre, string Id_SAP, string Sociedad_SAP, string Id_Sociedad, int lineaNegocio) { object respuesta = null; try { Sociedad sociedad = db.Sociedad.Where(x => x.Id_Sociedad == Id_Sociedad && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); if (sociedad == null) { var nuevo = new Sociedad(); nuevo.AbreviaturaSociedad = Abreviatura; nuevo.NombreSociedad = Nombre; nuevo.Id_SAP = Id_SAP; nuevo.Sociedad_SAP = Sociedad_SAP; nuevo.Id_Sociedad = Id_Sociedad; nuevo.Activo = 1; nuevo.Id_LineaNegocio = lineaNegocio; db.Sociedad.Add(nuevo); Log log = new Log(); log.insertaNuevoOEliminado(nuevo, "Nuevo", "Sociedad.html", Request.UserHostAddress); db.SaveChanges(); respuesta = new { success = true, results = "ok" }; } else { respuesta = new { success = true, results = "no", dato = Id_Sociedad }; } } catch (Exception ex) { respuesta = new { success = false, results = ex.Message }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
//agregar public JsonResult agregarCostoFC(int Id_Acreedor, int Id_Operador, int Id_Moneda, decimal Importe, DateTime Fecha_Inicio, DateTime Fecha_fin, int Id_Cuenta, int Id_Sociedad, int Linea_Negocio) { object respuesta = null; bool valid = true; var mensaje = ""; TC_Cierre tC_Cierre = db.TC_Cierre.Where(x => x.Id_Moneda == Id_Moneda && x.Mes_Consumo.Year == Fecha_Inicio.Year && x.Mes_Consumo.Month == Fecha_Inicio.Month && x.Sentido == "COSTO" && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); Operador operador = db.Operador.Where(x => x.Id == Id_Operador && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); Acreedor acreedor = db.Acreedor.Where(x => x.Id == Id_Acreedor && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); Moneda moneda = db.Moneda.Where(x => x.Id == Id_Moneda && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); CuentaResultado cuentaR = db.CuentaResultado.Where(x => x.Id == Id_Cuenta && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); Sociedad sociedad = db.Sociedad.Where(x => x.Id == Id_Sociedad && x.Id_LineaNegocio == Linea_Negocio && x.Activo == 1).SingleOrDefault(); if (DateTime.Compare(Fecha_Inicio, Fecha_fin) >= 0) { valid = false; mensaje = "Fecha Inicio Debe Ser MENOR que Fin"; } if (Convert.ToInt64(cuentaR.Cuenta) <= 0) //numeros negativos { valid = false; if (mensaje != "") { mensaje = mensaje + " y " + "Importe No Pueder Ser Menor a Cero"; } else { mensaje = "Cuenta debe ser mayor a cero"; } } if (valid) { try { var nuevo = new CostoFR(); nuevo.TipoOperador = operador.Tipo_Operador; nuevo.Operador = operador.Id_Operador; nuevo.AcreedorSap = acreedor.Acreedor1; nuevo.NombreProveedor = acreedor.NombreAcreedor; nuevo.Moneda = moneda.Moneda1; nuevo.Importe = Importe; nuevo.Fecha_Inicio = Fecha_Inicio.ToShortDateString(); nuevo.Fecha_Fin = Fecha_fin.ToShortDateString(); nuevo.CuentaR = cuentaR.Cuenta; nuevo.SociedadGL = int.Parse(sociedad.Id_Sociedad); if (tC_Cierre == null) { nuevo.TC = 0; } else { nuevo.TC = tC_Cierre.TC_MXN; } nuevo.Activo = 1; nuevo.Id_LineaNegocio = Linea_Negocio; db.CostoFR.Add(nuevo); Log log = new Log(); log.insertaNuevoOEliminado(nuevo, "Nuevo", "CostoFR.html", Request.UserHostAddress); db.SaveChanges(); respuesta = new { success = true, result = "ok" }; } catch (Exception ex) { var error = ex.Message; respuesta = new { success = false, result = "Hubo un error mientras se procesaba la petición" }; } } else { respuesta = new { success = false, result = mensaje }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
public JsonResult Modificar(int Id, string Sentido, string Sociedad, string Trafico, string Servicio, string DeudorAcreedor, string Grupo, string Importe, int lineaNegocio) { object respuesta = null; string oDeudorAcreedor = ""; string noEncontrados = ""; bool valido = false; decimal d_importe = decimal.Parse(Importe); try { Objecion objObjecion = db.Objecion.Where(x => x.id == Id).SingleOrDefault(); Sociedad oSociedad = db.Sociedad.Where(x => x.Id_Sociedad == Sociedad && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); Trafico oTrafico = db.Trafico.Where(x => x.Id_TraficoTR == Trafico && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio && x.Sentido == Sentido).SingleOrDefault(); Servicio oServicio = db.Servicio.Where(x => x.Id_Servicio == Servicio && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); Grupo oGrupo = db.Grupo.Where(x => x.Grupo1 == Grupo && x.Id_LineaNegocio == lineaNegocio && x.Activo == 1).SingleOrDefault(); Deudor oDeudor = db.Deudor.Where(x => x.Deudor1 == DeudorAcreedor && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); if (oSociedad == null) { noEncontrados = noEncontrados + "Sociedad " + Sociedad + ","; } if (oTrafico == null) { noEncontrados = noEncontrados + "Tráfico: " + Trafico + ","; } if (oServicio == null) { noEncontrados = noEncontrados + "Servico: " + Servicio + ","; } if (oGrupo == null) { noEncontrados = noEncontrados + "Grupo: " + Grupo + ","; } if (oDeudor == null) { Acreedor oAcreedor = db.Acreedor.Where(x => x.Acreedor1 == DeudorAcreedor && x.Activo == 1 && x.Id_LineaNegocio == lineaNegocio).SingleOrDefault(); if (oAcreedor != null) { oDeudorAcreedor = oAcreedor.Acreedor1; valido = true; } } else { oDeudorAcreedor = oDeudor.Deudor1; valido = true; } if (valido == false) { noEncontrados = noEncontrados + "Deudor/Acreedor: " + DeudorAcreedor + ","; } if (oSociedad != null && oTrafico != null && oServicio != null && valido == true) { objObjecion.Sentido = Sentido; objObjecion.Id_Sociedad = oSociedad.Id; objObjecion.Id_trafico = oTrafico.Id; objObjecion.Id_servicio = oServicio.Id; objObjecion.Deudor_Acreedor = DeudorAcreedor; objObjecion.Id_Grupo = oGrupo.Id; objObjecion.Importe = d_importe; Log log = new Log(); log.insertaBitacoraModificacion(objObjecion, "id", objObjecion.id, "Objecion.html", Request.UserHostAddress); db.SaveChanges(); respuesta = new { success = true, results = "ok" }; } else { respuesta = new { success = true, results = "no", mensaje = noEncontrados.Trim(',') }; } } catch (Exception ex) { respuesta = new { success = false, results = ex.Message }; } return(Json(respuesta, JsonRequestBehavior.AllowGet)); }
protected void btnAceptarImportar_Click(object sender, EventArgs e) { //string tmp; bool existe; try { //Limpia los controles txtFactura.Text = ""; txtFecha.Text = ""; cboMoneda.SelectedValue = "0"; txtImpSinIva.Text = ""; txtImpuestos.Text = ""; txtTotal.Text = ""; //Copia los archivos en la carpeta destino //string dirDestino = @System.Configuration.ConfigurationSettings.AppSettings["PathArchivos"].ToString(); string dirDestino = Server.MapPath("") + "\\Facturas\\"; string dirDestPDF = dirDestino; if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0)) { dirDestPDF += System.IO.Path.GetFileName(File1.PostedFile.FileName); try { File1.PostedFile.SaveAs(dirDestPDF); } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgErrorCopiarArchivo")); } } if ((File3.PostedFile != null) && (File3.PostedFile.ContentLength > 0)) { dirDestino += System.IO.Path.GetFileName(File3.PostedFile.FileName); try { File3.PostedFile.SaveAs(dirDestino); } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgErrorCopiarArchivo")); } } if ((File4.PostedFile != null) && (File4.PostedFile.ContentLength > 0)) { dirDestino += System.IO.Path.GetFileName(File4.PostedFile.FileName); try { File4.PostedFile.SaveAs(dirDestino); } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgErrorCopiarArchivo")); } } if ((File5.PostedFile != null) && (File5.PostedFile.ContentLength > 0)) { dirDestino += System.IO.Path.GetFileName(File5.PostedFile.FileName); try { File5.PostedFile.SaveAs(dirDestino); } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto("MsgErrorCopiarArchivo")); } } NegocioPF.Factura oFactura = new NegocioPF.Factura(); NegocioPF.Sociedad oSociedad = new Sociedad(cboSociedades.SelectedValue); oSociedad.Cargar(); txtReceptor.Text = oSociedad.RFC + " " + oSociedad.Nombre; oFactura.PDF = System.IO.Path.GetFileName(File1.PostedFile.FileName); oFactura.Sociedad = cboSociedades.SelectedValue; oFactura.Receptor = oSociedad.RFC; //oFactura.Emisor = oProveedor.RFC; //oFactura.PDF = System.IO.Path.GetFileName(File1.PostedFile.FileName); oFactura.Archivos.Add(new NegocioPF.Archivo(System.IO.Path.GetFileName(File1.PostedFile.FileName), 1)); if (File3.PostedFile.FileName != "") { oFactura.Archivos.Add(new NegocioPF.Archivo(System.IO.Path.GetFileName(File3.PostedFile.FileName), 3)); } if (File4.PostedFile.FileName != "") { oFactura.Archivos.Add(new NegocioPF.Archivo(System.IO.Path.GetFileName(File4.PostedFile.FileName), 4)); } if (File5.PostedFile.FileName != "") { oFactura.Archivos.Add(new NegocioPF.Archivo(System.IO.Path.GetFileName(File5.PostedFile.FileName), 5)); } Session["pdf"] = System.IO.Path.GetFileName(File1.PostedFile.FileName); Session["oFactura"] = oFactura; //Muestra la factura en el visor if (File1.PostedFile.FileName.Length > 0) { oViewer.Attributes.Add("src", "Facturas/" + System.IO.Path.GetFileName(File1.PostedFile.FileName)); oViewer.Visible = true; divVisor.Visible = true; } divImportar.Visible = false; divDetalle.Visible = true; } catch (Exception ex) { MessageBox(sender, e, ((Idioma)Session["oIdioma"]).Texto(ex.Message)); } }