/// <summary> /// Muestra la ventana detalle en modo edit /// </summary> /// <history> /// [emoguel] 28/04/2016 Created /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Warehouse warehouse = (Warehouse)dgrWarehouses.SelectedItem; frmWarehouseDetail frmWarehouseDetail = new frmWarehouseDetail(); frmWarehouseDetail.Owner = this; frmWarehouseDetail.oldWarehouse = warehouse; frmWarehouseDetail.enumMode = (_blnEdit) ? EnumMode.Edit : EnumMode.Add; if (frmWarehouseDetail.ShowDialog() == true) { List <Warehouse> lstWarehouses = (List <Warehouse>)dgrWarehouses.ItemsSource; int nIndex = 0; if (ValidateFilter(frmWarehouseDetail.warehouse)) //Validamos que cumpla con los filtros actuales { ObjectHelper.CopyProperties(warehouse, frmWarehouseDetail.warehouse); //Actualizamos los datos lstWarehouses.Sort((x, y) => string.Compare(x.whN, y.whN)); //Ordenamos la lista nIndex = lstWarehouses.IndexOf(warehouse); //Buscamos la posición del registro } else { lstWarehouses.Remove(warehouse); //Eliminamos el registro } dgrWarehouses.Items.Refresh(); //Actualizamos la vista del grid GridHelper.SelectRow(dgrWarehouses, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstWarehouses.Count + " Warehouses."; //Actualizamos el contador } }
/// <summary> /// Abre la ventana de busqueda /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 28/04/2016 /// </history> private void btnSearch_Click(object sender, RoutedEventArgs e) { frmWarehouseDetail frmWarehouseDetail = new frmWarehouseDetail(); frmWarehouseDetail.Owner = this; frmWarehouseDetail.enumMode = EnumMode.Search; frmWarehouseDetail.oldWarehouse = _warehouseFilter; frmWarehouseDetail.nStatus = _nStatus; if (frmWarehouseDetail.ShowDialog() == true) { _nStatus = frmWarehouseDetail.nStatus; _warehouseFilter = frmWarehouseDetail.warehouse; LoadWarehouses(); } }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 28/04/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmWarehouseDetail frmWarehouseDetail = new frmWarehouseDetail(); frmWarehouseDetail.Owner = this; frmWarehouseDetail.enumMode = EnumMode.Add; if (frmWarehouseDetail.ShowDialog() == true) { if (ValidateFilter(frmWarehouseDetail.warehouse))//Validamos que cumpla con los filtros actuales { List <Warehouse> lstWarehouses = (List <Warehouse>)dgrWarehouses.ItemsSource; lstWarehouses.Add(frmWarehouseDetail.warehouse); //Agregamos el registro a la lista lstWarehouses.Sort((x, y) => string.Compare(x.whN, y.whN)); //Ordenamos la lista int nIndex = lstWarehouses.IndexOf(frmWarehouseDetail.warehouse); //Obtenemos la posición del registro dgrWarehouses.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrWarehouses, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstWarehouses.Count + " Warehouses"; //Actualizamos el contador } } }