private void InicializarInventario() { if (!ContextControls.ContainsKey("PnlInventario")) { PnlInventario pnlInventario = new PnlInventario(); pnlInventario.Dock = DockStyle.Fill; DevExpress.XtraTab.XtraTabPage tabItem = new DevExpress.XtraTab.XtraTabPage(); tabItem.Controls.Add(pnlInventario); tabItem.Text = "Control de inventario"; xtraTabControl.TabPages.Add(tabItem); xtraTabControl.SelectedTabPage = tabItem; ContextControls.Add("PnlInventario", pnlInventario); } }
private void xtraTabControl_CloseButtonClick(object sender, EventArgs e) { string nameTab = (sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Text; if (nameTab == "Ingresos/Egresos") { EgresosIngresos egresosIngresos = (EgresosIngresos)(sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0]; if (egresosIngresos.DataHasChanged) { if (MessageBox.Show(this, "Existen cambios en la tabla, desea salir sin guardar los cambios? ", "Ingresos/Egresos", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } } else if (nameTab == "Lista Compras") { PnlListaComprasInsumos pnlComprasInsumoes = (PnlListaComprasInsumos)(sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0]; if (pnlComprasInsumoes.DataHasChanged) { if (MessageBox.Show(this, "Existen cambios en la tabla, desea salir sin guardar los cambios? ", "Lista Compras", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } } else if (nameTab == "Control de inventario") { PnlInventario invent = (PnlInventario)(sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0]; if (invent.DataHasChanged) { if (MessageBox.Show(this, "Existen cambios en la tabla, desea salir sin guardar los cambios? ", "Control de Inventario", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } } // else if(nameTab=="") //editar insumos if (ContextControlsForInsumo.ContainsValue((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])) { ContextControlsForInsumo.Remove(((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0] as NuevoInsumo).Insumo.idInsumo.ToString());//((NuevoInsumo)((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])); } //editar recetas if (ContextControlsForRecetas.ContainsValue((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])) { ContextControlsForRecetas.Remove(((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0] as PnlNuevaReceta).Receta.idReceta.ToString());//((NuevoInsumo)((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])); } //editar productos if (ContextControlsForProductos.ContainsValue((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])) { ContextControlsForProductos.Remove(((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0] as PnlNuevoProducto).Producto.ProductoID.ToString()); } //editar privilegios if (ContextControlsForPrivilegios.ContainsValue((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])) { ContextControlsForPrivilegios.Remove(((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0] as PnlNuevoPrivilegio).IDUsuario); } if (ContextControls.ContainsValue((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0])) { ContextControls.Remove((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPage.Controls[0].Name); } if ((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPageIndex != 0) { xtraTabControl.TabPages.RemoveAt((sender as DevExpress.XtraTab.XtraTabControl).SelectedTabPageIndex); } }