public void actualizarAcreditacion() { string nombre = txtNombreAcreditacion.Text; richAcreditacion.SaveFile(@"C:\Users\ndealbera\Documents\Visual Studio 2010\Projects\CoffeeAndCake\CoffeeAndCake\Acreditaciones\" + nombre + ".rtf", RichTextBoxStreamType.RichText); Acreditacion acr = new Acreditacion(); int maxAcr = 0; DataSet ds = new DataSet(); ds = con.fillDs("SELECT * FROM ACREDITACIONES;", "ALL_ACREDITACIONES"); foreach (DataRow dr in ds.Tables[0].Rows) { int current = Convert.ToInt32(dr["id_acreditacion"].ToString()); if (current > maxAcr) maxAcr = current; } acr.pIdAcreditacion = Convert.ToString(maxAcr + 1); acr.pPathAcreditacion = txtNombreAcreditacion.Text + ".rtf"; acr.pIdEmpresa = txtCuit.Text; lisAcreditaciones.Items.Add(acr); }
private void lisAcreditaciones_SelectedIndexChanged(object sender, EventArgs e) { Acreditacion acr = new Acreditacion(); acr = (Acreditacion)lisAcreditaciones.SelectedItem; if (acr!=null) { txtNombreAcreditacion.Text = acr.pPathAcreditacion; cargarAcreditacionesRTF(acr); } }
private void cargarAcreditacionesEnEntidades(List<Entidad> listEnt) { if (listEnt != null) { for (int i = 0; i < listEnt.Count; i++) { dsAcreditaciones = con.fillDs("SELECT * FROM ACREDITACIONES WHERE id_empresa ='" + listEnt[i].pCuit + "';", "ACREDITACIONES"); Console.WriteLine("SELECT * FROM ACREDITACIONES WHERE id_empresa ='" + listEnt[i].pCuit + "';", "ACREDITACIONES"); listEnt[i].pAcreditaciones = new List<Acreditacion>(); foreach (DataRow dr in dsAcreditaciones.Tables[0].Rows) { Acreditacion acr = new Acreditacion(); acr.pIdAcreditacion = dr["id_acreditacion"].ToString(); acr.pPathAcreditacion = dr["path_to_file"].ToString(); acr.pIdEmpresa = dr["id_empresa"].ToString(); listEnt[i].pAcreditaciones.Add(acr); } } } }
private void cargarAcreditacionesRTF(Acreditacion acr) { if (acr != null && acr.pPathAcreditacion != String.Empty) { richAcreditacion.LoadFile(@"C:\Users\ndealbera\Documents\Visual Studio 2010\Projects\CoffeeAndCake\CoffeeAndCake\Acreditaciones\" + acr.pPathAcreditacion); } else { richAcreditacion.Text = String.Empty; } }
public bool actualizarEntidad() { bool estadoOk = false; Entidad ent = new Entidad(); String errores = ""; if (String.IsNullOrEmpty(txtNombre.Text)) { errores += "- Debe completar el nombre de la empresa \n"; estadoOk = false; } else { estadoOk = true; } if (String.IsNullOrEmpty(txtCuit.Text) || txtCuit.TextLength < 13) { errores += "- Debe indicar un CUIT en el formato correcto \n"; estadoOk = false; } else { estadoOk = true; } if (estadoOk) { ent.pNombre = txtNombre.Text; if (!String.IsNullOrEmpty(txtCp.Text)) ent.pCp = Convert.ToInt32(txtCp.Text); ent.pCuit = txtCuit.Text; ent.pDireccion = txtDireccion.Text; ent.pEmail = txtEmail.Text; ent.pTel = txtTel.Text; ent.pId_provincia = Convert.ToInt32(cboProvincia.SelectedValue); ent.pId_departamento = Convert.ToInt32(cboDepartamento.SelectedValue); ent.pId_localidad = Convert.ToInt32(cboCiudad.SelectedValue); if (txtCuit.Enabled) { con.modifyData("INSERT INTO ENTIDADES VALUES('" + ent.pCuit + "','" + ent.pNombre + "'," + ent.pId_provincia + "," + ent.pId_departamento + "," + ent.pId_localidad + ",'" + ent.pTel + "','" + ent.pCp + "','" + ent.pEmail + "','" + ent.pDireccion + "');"); if (lisAcreditaciones.Items.Count > 0) { ent.pAcreditaciones = new List<Acreditacion>(); DataSet ds = new DataSet(); int maxAcr = 0; con.Connect(); ds = con.fillDs("SELECT * FROM ACREDITACIONES;", "ALL_ACREDITACIONES"); foreach (DataRow dr in ds.Tables[0].Rows) { int current = Convert.ToInt32(dr["id_acreditacion"].ToString()); if (current > maxAcr) maxAcr = current; } for (int i = 0; i < lisAcreditaciones.Items.Count; i++) { maxAcr++; Acreditacion acr = new Acreditacion(); acr = (Acreditacion)lisAcreditaciones.Items[i]; acr.pIdAcreditacion = Convert.ToString(maxAcr); ent.pAcreditaciones.Add(acr); Console.WriteLine("INSERT INTO ACREDITACIONES VALUES ('" + acr.pIdAcreditacion + "','" + acr.pIdEmpresa + "','" + acr.pPathAcreditacion + "');"); con.modifyData("INSERT INTO ACREDITACIONES VALUES ('" + acr.pIdAcreditacion + "','" + acr.pIdEmpresa + "','" + acr.pPathAcreditacion + "');"); } } listEnt.Add(ent); lisEntidades.Items.Add(ent); return true; } else { int i = lisEntidades.SelectedIndex; listEnt[i].pNombre = txtNombre.Text; listEnt[i].pCp = Convert.ToInt32(txtCp.Text); listEnt[i].pCuit = txtCuit.Text; listEnt[i].pDireccion = txtDireccion.Text; listEnt[i].pEmail = txtEmail.Text; listEnt[i].pTel = txtTel.Text; listEnt[i].pId_provincia = Convert.ToInt32(cboProvincia.SelectedValue); listEnt[i].pId_departamento = Convert.ToInt32(cboDepartamento.SelectedValue); listEnt[i].pId_localidad = Convert.ToInt32(cboCiudad.SelectedValue); con.modifyData("UPDATE ENTIDADES SET nombre='" + listEnt[i].pNombre + "'," + "id_provincia=" + listEnt[i].pId_provincia + ", " + "id_departamento=" + listEnt[i].pId_departamento + ", " + "id_localidad=" + listEnt[i].pId_localidad + ", " + "tel='" + listEnt[i].pTel + "'," + "cp='" + listEnt[i].pCp + "'," + "email='" + listEnt[i].pEmail + "'," + "direccion='" + listEnt[i].pDireccion + "' WHERE cuit = '" + listEnt[i].pCuit + "';"); Console.WriteLine("UPDATE ENTIDADES SET nombre='" + listEnt[i].pNombre + "'," + "id_provincia=" + listEnt[i].pId_provincia + ", " + "id_departamento=" + listEnt[i].pId_departamento + ", " + "id_localidad=" + listEnt[i].pId_localidad + ", " + "tel='" + listEnt[i].pTel + "'," + "cp='" + listEnt[i].pCp + "'," + "email='" + listEnt[i].pEmail + "'," + "direccion='" + listEnt[i].pDireccion + "' WHERE cuit = '" + listEnt[i].pCuit + "';"); if (lisAcreditaciones.Items.Count > 0) { listEnt[i].pAcreditaciones = new List<Acreditacion>(); DataSet ds = new DataSet(); int maxAcr = 0; con.Connect(); ds = con.fillDs("SELECT * FROM ACREDITACIONES;", "ALL_ACREDITACIONES"); foreach (DataRow dr in ds.Tables[0].Rows) { int current = Convert.ToInt32(dr["id_acreditacion"].ToString()); if (current > maxAcr) maxAcr = current; } for (int j = 0; j < lisAcreditaciones.Items.Count; j++) { maxAcr++; Acreditacion acr = new Acreditacion(); acr = (Acreditacion)lisAcreditaciones.Items[i]; if (!listEnt[i].pAcreditaciones.Contains(acr)) { listEnt[i].pAcreditaciones.Add(acr); } } } lisEntidades.DataSource = listEnt; return true; } } MessageBox.Show(errores, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; }