private void dtgEmpresasAgrupadas_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //sacarlo de la grilla solamente SisPackController.AdministrarGrillas.Configurar(dtgEmpresasAgrupadas, "EmpresaAgrupadaID", 10); DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); DsEmpresasAgrupadas.DatosRow[] dr = null; if (Session["DsEmpresasAgrupadas"] != null) { ds = (DsEmpresasAgrupadas)Session["DsEmpresasAgrupadas"]; } if ((e.Item.Cells[1].Text) != " ") //tengo id { dr = (DsEmpresasAgrupadas.DatosRow[])ds.Datos.Select("EmpresaAgrupadaID = " + e.Item.Cells[1].Text); } else if ((e.Item.Cells[2].Text) != " ") //tengo solo el codigo { dr = (DsEmpresasAgrupadas.DatosRow[])ds.Datos.Select("EmpresaCodigo = '" + e.Item.Cells[2].Text + "'"); } int indice = ddlEmpresas.Items.IndexOf(ddlEmpresas.Items.FindByValue(dr[0].EmpresaCodigo)); ddlEmpresas.Items[indice].Selected = false; ds.Datos.RemoveDatosRow(dr[0]); Session["DsEmpresasAgrupadas"] = ds; dtgEmpresasAgrupadas.DataSource = ds.Datos; dtgEmpresasAgrupadas.PageSize = 20; dtgEmpresasAgrupadas.CurrentPageIndex = 0; dtgEmpresasAgrupadas.DataBind(); BindGridEmpresas(0); }
public void Editar() { DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); try { SisPackController.AdministrarGrillas.Configurar(dtgEmpresasAgrupadas, "EmpresaAgrupadaID", this.CantidadOpciones); IAgrupacionEmpresas agrupacion = AgrupacionEmpresasFactory.GetAgrupacionEmpresasFactory(); agrupacion.AgrupacionEmpresaID = Utiles.Validaciones.obtieneEntero(txtAgrupacionID.Text); agrupacion.Consultar(); //trae el encabezado txtNombreAgrup.Text = agrupacion.AgrupacionNombre; ds = (DsEmpresasAgrupadas)agrupacion.ConsultarEmpresas(); //trae el detalle, por si solo el encabezado no se usa Session["DsEmpresasAgrupadas"] = ds; dtgEmpresasAgrupadas.DataSource = ds; dtgEmpresasAgrupadas.PageSize = 20; dtgEmpresasAgrupadas.CurrentPageIndex = 0; dtgEmpresasAgrupadas.DataBind(); LlenarComboEmpresas(); //con las fechas correspondientes e las que pidio en su momento for (int i = 0; i <= ds.Datos.Count - 1; i++) //selecciona los elegidos { DsEmpresasAgrupadas.DatosRow dr = (DsEmpresasAgrupadas.DatosRow)ds.Datos.Rows[i]; //ddlEmpresas.SelectedValue= dr.EmpresaCodigo; int indice = ddlEmpresas.Items.IndexOf(ddlEmpresas.Items.FindByValue(dr.EmpresaCodigo)); ddlEmpresas.Items[indice].Selected = true; } } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
public override global::System.Data.DataSet Clone() { DsEmpresasAgrupadas cln = ((DsEmpresasAgrupadas)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private void butGuardar_Click(object sender, System.EventArgs e) { try { //el encabezado->la agrupacion IAgrupacionEmpresas agrupacion = AgrupacionEmpresasFactory.GetAgrupacionEmpresasFactory(); agrupacion.AgrupacionNombre = txtNombreAgrup.Text; agrupacion.AgrupacionEmpresaID = Utiles.Validaciones.obtieneEntero(txtAgrupacionID.Text); //el detalle -> los servicios IEmpresasAgrupadas empresasAgrup = EmpresasAgrupadasFactory.GetEmpresasAgrupadasDataSet(); empresasAgrup.AgrupacionEmpresaID = agrupacion.AgrupacionEmpresaID; DsEmpresasAgrupadas ds = (DsEmpresasAgrupadas)Session ["DsEmpresasAgrupadas"]; if (ds.Datos.Count > 0) { if (agrupacion.Guardar(ds)) { //le mando el ds de los recorridos Session["DsEmpresasAgrupadas"] = null; string mensaje = "Los datos se guardaron correctamente. "; string script = "<script language='javascript'>\n"; script += "alert('" + mensaje + "');"; script += "window.location.href = 'AgrupacionEmpresasTransporteConsul.aspx';\n"; script += "</script>"; Page.RegisterStartupScript("scriptOk", script); } else { string script = "<script language='javascript'>\n"; script += "alert('Los datos no se guardaron debido a errores.');\n"; script += "</script>"; Page.RegisterStartupScript("scriptError", script); } } else { ((ErrorWeb)phErrores.Controls[0]).setMensaje("Debe asociar las empresas para poder confirmar"); } } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
public DsEmpresasAgrupadas ConsultarEmpresas() { DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); if (this.AgrupacionEmpresaID != 0) { SqlParameter pAgrupacionID = new SqlParameter("@AgrupacionEmpresaID", this.AgrupacionEmpresaID); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "EmpresasAsociadasByAgrupacionID", pAgrupacionID); } else //quiere todas { Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "EmpresasAsociadasALL"); } return(ds); }
public DsEmpresasAgrupadas GetEmpresasAgrupadasDataSet() { try { DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); SqlParameter id = new SqlParameter("@AgrupacionEmpresaID", Utiles.BaseDatos.IntToSql(this.AgrupacionEmpresaID)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "EmpresasAgrupadasSEL", id); return(ds); } catch (Exception e) { throw e; } }
public bool Guardar(DsEmpresasAgrupadas ds) { DsEmpresasAgrupadas.DatosRow drEmpAgrup; EmpresasAgrupadas empresa; //detalle using (SqlConnection conexion = new SqlConnection()) { SqlTransaction transaccion = null; conexion.ConnectionString = Config.ConnectionString; try { conexion.Open(); //para trabajar con transaccion transaccion = conexion.BeginTransaction(); //escribo el encabezado servicio de transporte if (this.AgrupacionEmpresaID != 0) //si es modificar primero voy a borrar todos los detalles y volverlos crear { EliminarEmpresas(transaccion); } Guardar(transaccion); //guardo el encabezado for (int i = 0; i <= (ds.Datos.Rows.Count) - 1; i++) { drEmpAgrup = (DsEmpresasAgrupadas.DatosRow)ds.Datos.Rows[i]; empresa = new EmpresasAgrupadas(); empresa.AgrupacionEmpresaID = this.AgrupacionEmpresaID; empresa.EmpresaCodigo = drEmpAgrup.EmpresaCodigo; empresa.Guardar(transaccion); } transaccion.Commit(); return(true); } catch (Exception ex) { transaccion.Rollback(); throw ex; } } }
public void BindGridEmpresas(int currentPage) { try { SisPackController.AdministrarGrillas.Configurar(dtgEmpresasAgrupadas, "EmpresaAgrupadaID", this.CantidadOpciones); DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); if (Session["DsEmpresasAgrupadas"] != null) //para limpiarlo { Session["DsEmpresasAgrupadas"] = null; } for (int i = 0; i <= ddlEmpresas.Items.Count - 1; i++) { //recorro la lista de servicios if (ddlEmpresas.Items[i].Selected) { DsEmpresasAgrupadas.DatosRow dr = ds.Datos.NewDatosRow(); dr["EmpresaCodigo"] = ddlEmpresas.Items[i].Value; //asigno el id del servicio y la descripcion //dr["EmpresaCodigo"]=ddlEmpresas.Items[i].Text; ds.Datos.Rows.Add(dr); } } Session["DsEmpresasAgrupadas"] = ds; //lo asigno a la sesion dtgEmpresasAgrupadas.DataSource = ds.Datos; if (currentPage > dtgEmpresasAgrupadas.PageSize) { currentPage = 0; } dtgEmpresasAgrupadas.CurrentPageIndex = currentPage; dtgEmpresasAgrupadas.PageSize = 20; dtgEmpresasAgrupadas.DataBind(); } catch (Exception ex) { ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(ex.Message); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); DsEmpresasAgrupadas ds = new DsEmpresasAgrupadas(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "DatosDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }