protected void ActualizarListaPrecios(Object Sender, EventArgs e) { if (this.plFiltros.Visible && this.dtFiltrosValor.Rows.Count == 0) { Utils.MostrarAlerta(Response, "Por favor ingrese al menos un filtro"); } else { ListaPrecios listaActualizar = new ListaPrecios(Request.QueryString["codLista"]); bool status = true; DataTable dtOut = listaActualizar.ActualizacionValores(this.plFiltros.Visible, this.dtFiltrosValor, Request.QueryString["valBase"], Request.QueryString["tipOper"], Request.QueryString["valOper"], ref status); if (status) { dgResultado.DataSource = dtOut; dgResultado.DataBind(); DatasToControls.JustificacionGrilla(dgResultado, dtOut); plProceso.Visible = false; plResultado.Visible = true; } else { lb.Text += listaActualizar.ProcessMsg; } } }
protected void CrearLista(Object Sender, EventArgs E) { //Creamos un objeto de tipo ListaPrecios y creamos la lista de precios ListaPrecios nuevaLista = new ListaPrecios(this.tbCodigoLista.Text, this.tbNombreLista.Text, this.ddlMoneda.SelectedValue); if (nuevaLista.CrearLista()) { Response.Redirect("" + indexPage + "?process=Inventarios.ListaPrecios"); } else { Utils.MostrarAlerta(Response, "" + nuevaLista.ProcessMsg + ""); } }
protected void EliminarLista(Object Sender, EventArgs E) { if (this.ddlListasDelete.Items.Count > 0) { ListaPrecios listaBorrar = new ListaPrecios(this.ddlListasDelete.SelectedValue); if (listaBorrar.EliminarLista()) { Response.Redirect("" + indexPage + "?process=Inventarios.ListaPrecios"); } else { lb.Text += listaBorrar.ProcessMsg; } } else { Utils.MostrarAlerta(Response, "No se ha seleccionado ninguna lista para su eliminación!"); } }
protected void RealizarProceso(Object Sender, EventArgs E) { ListaPrecios listaActualizar = new ListaPrecios(Request.QueryString["codLista"]); DataTable dtUpdate = dtNew = dtError = new DataTable(); /* * Así es como estaba * * if (listaActualizar.ActualizarListaArchivo((DataTable)Session["dtListaArchivo"], ref dtUpdate, ref dtNew, ref dtError, true)) * Response.Redirect("" + indexPage + "?process=Inventarios.ListaPrecios"); * lb.Text += "<br> Mensaje :" + listaActualizar.ProcessMsg; * */ /* * nuevo metodo aqui */ //Esta tabla tiene TODOS los elementos //DataTable tablaListasTodos = (DataTable)Session["dtListaArchivo"]; //Esta tabla tienes los elementos que van con error(Los que no se actualizarían) //DataTable tablaListasFallos = (DataTable)Session["dtError"]; //Esta tabla tiene los elementos válidos ya existentes en la tabla mprecioitem DataTable tablaListaActualiza = (DataTable)Session["dtUpdate"]; //Esta tabla tiene los elementos válidos nuevos en la tabla mprecioitem DataTable tablaListaNuevos = (DataTable)Session["dtNew"]; string rta = listaActualizar.ActualizarPrecios(tablaListaActualiza, tablaListaNuevos, true); if (rta.ToLower() == "ok") { Session.Clear(); Response.Redirect(indexPage + "?process=Inventarios.ListaPrecios&hecho=1"); } else { lb.Text = rta; } }
protected void AceptarArchivo(Object Sender, EventArgs E) { dtNuevos = dtExistentes = dtFallos = new DataTable(); string[] files = fDocument.PostedFile.FileName.Split('\\'); if ((files[files.Length - 1].Split('.'))[1].Trim().ToUpper() == "XLS" || (files[files.Length - 1].Split('.'))[1].Trim().ToUpper() == "XLSX") { fDocument.PostedFile.SaveAs(ConfigurationManager.AppSettings["PathToImportsExcel"] + files[files.Length - 1]); //Ahora llamamos la clase que me permite traer los datos de una hoja de excel mediante ADO ExcelFunctions excelManager = new ExcelFunctions(ConfigurationManager.AppSettings["PathToImportsExcel"] + files[files.Length - 1]); DataSet ds = new DataSet(); ds = excelManager.Request(ds, IncludeSchema.NO, "SELECT * FROM ListaPrecios"); if (ds.Tables.Count > 0) { lnkExportarExcel.Visible = true; lnkExportarExcel2.Visible = true; if ((files[files.Length - 1].Split('.'))[1].Trim().ToUpper() == "XLSX") { for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ds.Tables[0].Columns[i].ColumnName = ds.Tables[0].Rows[0][i].ToString(); } ds.Tables[0].Rows[0].Delete(); ds.Tables[0].Rows[0].AcceptChanges(); } else { Utils.MostrarAlerta(Response, "El formato del excel no puede ser diferente de la versión 2010 o más reciente (.xlsx)"); return; } if (ds.Tables[0].Columns.Count == 3) { Session["dtListaArchivo"] = ds.Tables[0]; ListaPrecios listaActualizar = new ListaPrecios(Request.QueryString["codLista"]); listaActualizar.ds = ds; string rta; rta = listaActualizar.ActualizarListaArchivo(ds.Tables[0], ref dtExistentes, ref dtNuevos, ref dtFallos, false); if (rta.Length > 0) { Utils.MostrarAlerta(Response, rta); return; } //listaActualizar.ActualizarListaArchivo(ds.Tables[0],ref dtUpdate, ref dtNew, ref dtError, false); //método viejo plUpload.Visible = false; plResultado.Visible = true; dgUpdate.DataSource = dtExistentes; Session["dtUpdate"] = dtExistentes; dgUpdate.DataBind(); dgError.DataSource = dtFallos; Session["dtError"] = dtFallos; dgError.DataBind(); dgNew.DataSource = dtNuevos; Session["dtNew"] = dtNuevos; dgNew.DataBind(); //dgUpdate.DataSource = dtUpdate; //Session["dtUpdate"] = dtUpdate; //dgError.DataSource = dtError; //Session["dtError"] = dtError; //dgUpdate.DataBind(); DatasToControls.JustificacionGrilla(dgUpdate, dtExistentes); DatasToControls.JustificacionGrilla(dgError, dtFallos); DatasToControls.JustificacionGrilla(dgNew, dtNuevos); //DatasToControls.JustificacionGrilla(dgUpdate,dtUpdate); //DatasToControls.JustificacionGrilla(dgError,dtError); } else { Utils.MostrarAlerta(Response, "El archivo no tiene el número de columnas indicado. Revise Por Favor!"); } } else { Utils.MostrarAlerta(Response, "No se ha podido cargar el archivo, no se ha dado el nombre correcto al rango de celdas. Revise Por Favor!"); } } else { Utils.MostrarAlerta(Response, "Tipo de Archivo Invalido!"); } }