private void btn_save_Click(object sender, EventArgs e) { try { var BL = new tb_pt_familiadetBL(); var BE = new tb_pt_familiadet(); BE.lineaid = tejidoid.SelectedValue.ToString(); BE.moduloid = cboModuloID.SelectedValue.ToString(); BE.familiaid = familiaid.Text.Trim().PadLeft(3, '0'); var Detalle = new tb_pt_familiadet.Item(); var ListaItems = new List<tb_pt_familiadet.Item>(); var item = 0; foreach (DataRow fila in Tablafamiliadet.Rows) { Detalle = new tb_pt_familiadet.Item(); item++; Detalle.moduloid = cboModuloID.SelectedValue.ToString(); Detalle.lineaid = tejidoid.SelectedValue.ToString(); Detalle.familiaid = familiaid.Text.Trim().PadLeft(3, '0'); Detalle.productid = fila["productid"].ToString(); Detalle.unmed = fila["unmed"].ToString(); Detalle.status = "0"; Detalle.usuar = VariablesPublicas.Usuar.Trim(); ListaItems.Add(Detalle); } if (ListaItems.Count == 0) { MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BE.ListaItems = ListaItems; if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos Actualizados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; limpiar_documento(); Data_Tablafamiliadet(); btn_save.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Insert() { try { if (familiatelaid.Text.Trim().Length != 3) { MessageBox.Show("Falta Codigo Familia !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (familiatelaname.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Nombre de Familia", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_pt_familiadetBL(); var BE = new tb_pt_familiadet(); BE.familiaid = familiatelaid.Text.Trim().PadLeft(3, '0'); BE.productid = productid.Text.ToUpper(); if (tejidoid.SelectedValue != null && tejidoid.Text.Trim().Length > 0) { BE.lineaid = tejidoid.SelectedValue.ToString(); } BE.usuar = VariablesPublicas.Usuar.Trim(); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }