private void BttGuardar_Click(object sender, EventArgs e) { cont = 0; if (TxtBxNombre.Text == "") { MessageBox.Show("No se ha registrado ningun nombre del material de seguridad ", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); TxtBxNombre.Focus(); cont++; } if (TxtBxCantidad.Text == "") { MessageBox.Show("No se ha registrado ninguna cantidad", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); TxtBxCantidad.Focus(); cont++; } if (TxtBxPrecio.Text == "") { MessageBox.Show("No se ha registrado ningun precio", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); TxtBxCantidad.Focus(); cont++; } if (cont == 0) { matSeg1.ReadXml(Application.StartupPath + "\\ArchOficina.xml"); object[] oficina = new object[8]; oficina[0] = TxtBxNombre.Text; oficina[2] = Date.Text; oficina[4] = TxtBxCantidad.Text; oficina[5] = TxtBxPrecio.Text; oficina[7] = LblPrecioT.Text; System.Data.DataRow[] nombre; nombre = matSeg1.TblOficina.Select("Nombre='" + TxtBxNombre.Text + "'"); if (nombre.Length > 0) { MessageBox.Show("El Material de Oficina ya existe solo se puede modificar", "ALERTA", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); this.Close(); } else { LblTxtCodigo.Text = matSeg1.TblOficina.Rows.Count.ToString(); agregar = int.Parse(LblTxtCodigo.Text); agregar++; LblTxtCodigo.Text = agregar.ToString(); OficinaCodigo mostrarCodigo = new OficinaCodigo(); mostrarCodigo.LblCodigo.Text = agregar.ToString(); matSeg1.TblOficina.Rows.Add(oficina); matSeg1.WriteXml(Application.StartupPath + "\\ArchOficina.xml"); this.Hide(); mostrarCodigo.ShowDialog(); if (mostrarCodigo.DialogResult == DialogResult.OK) { MessageBox.Show("Se ha guardado exitosamente", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } } }
private void BttGuardar_Click(object sender, EventArgs e) { cont = 0; if (CmBxEstado.Text == "") { MessageBox.Show("No se ha registrado ningun dato en estado ", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); //TxtBxCodigo.Focus(); cont++; } if (TxtBxNombre.Text == "") { MessageBox.Show("No se ha registrado ningun nombre del material de seguridad ", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); TxtBxNombre.Focus(); cont++; } if (TxtBxMarca.Text == "") { MessageBox.Show("No se ha registrado ninguna marca del material", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); TxtBxNombre.Focus(); cont++; } if (TxtBxModelo.Text == "") { MessageBox.Show("No se ha registrado ninguna marca del modelo", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); TxtBxNombre.Focus(); cont++; } if (TxtBxCantidad.Text == "") { MessageBox.Show("No se ha registrado ninguna cantidad", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); TxtBxCantidad.Focus(); cont++; } if (TxtBxPrecio.Text == "") { MessageBox.Show("No se ha registrado ningun precio", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); TxtBxCantidad.Focus(); cont++; } if (cont == 0) { //matSeg1.WriteXml(Application.StartupPath + "\\ArchMatSeg.xml"); matSeg1.ReadXml(Application.StartupPath + "\\ArchMatSeg.xml"); object[] matseg = new object[11]; matseg[0] = TxtBxNombre.Text; matseg[2] = TxtBxMarca.Text; matseg[3] = TxtBxModelo.Text; matseg[4] = Date.Text; matseg[7] = TxtBxCantidad.Text; matseg[8] = TxtBxPrecio.Text; matseg[9] = CmBxEstado.Text; matseg[10] = cant * precio; LblTxtCodigo.Text = matSeg1.TblMatSeg.Rows.Count.ToString(); agregar = int.Parse(LblTxtCodigo.Text); agregar++; LblTxtCodigo.Text = agregar.ToString(); OficinaCodigo mostrarCodigo = new OficinaCodigo(); mostrarCodigo.LblCodigo.Text = agregar.ToString(); matSeg1.TblMatSeg.Rows.Add(matseg); matSeg1.WriteXml(Application.StartupPath + "\\ArchMatSeg.xml"); this.Hide(); mostrarCodigo.ShowDialog(); if (mostrarCodigo.DialogResult == DialogResult.OK) { MessageBox.Show("Se ha guardado exitosamente", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } //TxtBxCantidad.Text = Datos.ToString(); /*if (Datos.Length > 0) * { * MessageBox.Show("El material de seguridad ya esta registrado"); * this.Close(); * * } * else * { * matSeg1.TblMatSeg.Rows.Add(matseg); * matSeg1.WriteXml(Application.StartupPath + "\\ArchMatSeg.xml"); * MessageBox.Show("Se ha guardado exitosamente", "AVISO", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); * this.DialogResult = System.Windows.Forms.DialogResult.OK; * this.Close(); * }*/ } }