private void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { if (dataGrid.Items.Count > 0) { SelectItem(); e.Handled = true; } } if (e.Key == Key.Enter) { SelectItem(); e.Handled = true; } if (e.Key == Key.Left) { //if (mostrartodo == false) //{ TxtShear.Focus(); e.Handled = true; //} } }
void mainGrid_PreviewKeyDown(object sender, KeyEventArgs args) { if (args.Key == Key.Enter) { if (returnDt == true) { SelectItem(); } args.Handled = true; } if (args.Key == Key.Left) { if (TxtShear.Visibility == Visibility.Visible) { TxtShear.Focus(); args.Handled = true; return; } if (mostrartodo == false) { //TxtShear.Focus(); //args.Handled = true; } } }
public WindowBuscar(string CmpTabla, string CmpCodigo, string CmpNombre, string CmpOrden, string CmpIdRow, string CmpTitulo, string _Conexion, bool MostrarTodo, string Where, DataTable dt = null, bool ReturnDt = false, bool CacheData = false, int MaxRecords = 0, string ParamInit = "", int idEmp = 0) { //parametro ini se usa para enviar variables en el where ejemplo declare @tipo as int;set @tipo = 1 y esta variable es usada en el where ejemplo tipo_con=@tipo InitializeComponent(); cmptabla = CmpTabla.Trim(); cmpcodigo = CmpCodigo.Trim(); cmpnombre = CmpNombre.Trim(); cmporden = CmpOrden.Trim(); cmpIdRow = CmpIdRow; returnDt = ReturnDt; cacheData = CacheData; _conexion = _Conexion; mostrartodo = MostrarTodo; maxRecords = MaxRecords; where = Where.Trim(); this.Title = CmpTitulo.Trim(); BusinnesId = idEmp; //if (idEmp == 0) BusinnesId = ((Inicio)Application.Current.MainWindow)._BusinessId; //MessageBox.Show("windowsbuscar:"+BusinnesId.ToString()); if (MostrarTodo == true) { if (!string.IsNullOrEmpty(where.Trim())) { where = " where " + where; // MessageBox.Show(where); } if (!string.IsNullOrEmpty(ParamInit)) { paramInit = ParamInit + ";"; } dataGrid.ItemsSource = GetDataTable(where).DefaultView; //BtnBuscar.Visibility = Visibility.Collapsed; //TxtShear.Visibility = Visibility.Collapsed; dataGrid.SelectedIndex = 0; dataGrid.Focus(); if (dataGrid.Items.Count < 20) { TxtShear.Visibility = Visibility.Collapsed; BtnBuscar.Visibility = Visibility.Collapsed; } if (MostrarBuscar == true) { TxtShear.Visibility = Visibility.Visible; BtnBuscar.Visibility = Visibility.Visible; TxtShear.Focus(); } } else { TxtShear.Focus(); } //dataGrid.PreviewKeyDown += new KeyEventHandler(mainGrid_PreviewKeyDown); }
private void Window_Loaded(object sender, RoutedEventArgs e) { idbod = idBod; idemp = idEmp; System.Data.DataRow foundRow = SiaWin.Empresas.Rows.Find(idemp); int idLogo = Convert.ToInt32(foundRow["BusinessLogo"].ToString().Trim()); //cnEmp = foundRow["BusinessCn"].ToString().Trim(); string aliasemp = foundRow["BusinessAlias"].ToString().Trim(); string nomempresa = foundRow["BusinessName"].ToString().Trim(); // tabitem.Logo(idLogo, ".png"); // tabitem.Title = "Analisis de Venta(" + aliasemp + ")"; codemp = foundRow["BusinessCode"].ToString().Trim(); this.Title = "Saldos de Inventario - Empresa:" + codemp + "-" + nomempresa; //GroupId = 0; ultbusqueda = UltBusqueda; if (TiboBusqueda) { TxtTipoBusqueda.Text = "Busqueda por:"; } if (TiboBusqueda == false) { TxtTipoBusqueda.Text = "Busqueda por:"; } if (MostrarTodo == true) { if (where != string.Empty) { where = " where " + where; } dataGrid.ItemsSource = GetDataTable(where).DefaultView; BtnBuscar.Visibility = Visibility.Collapsed; TxtShear.Visibility = Visibility.Collapsed; dataGrid.SelectedIndex = 0; dataGrid.Focus(); } else { if (ultbusqueda != string.Empty) { TxtShear.Text = ultbusqueda; } TxtShear.Text = ""; TxtShear.Focus(); TxtShear.SelectAll(); } //if (SiaWin.Func.Var.ContainsKey("_UltimaReferenciaBuscar")) TxtShear.Text = SiaWin.Func.Var["_UltimaReferenciaBuscar"].ToString().Trim(); //if (!SiaWin.Func.Var.ContainsKey("_UltimaReferenciaBuscar")) SiaWin.Func.Var.Add("_UltimaReferenciaBuscar", ""); //if (!string.IsNullOrEmpty(TxtShear.Text.Trim())) BtnBuscar.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { dt.Clear(); if (TxtShear.Text.Trim() == string.Empty) { TxtShear.Focus(); } if (TxtShear.Text.Trim() == string.Empty) { return; } string bb = TxtShear.Text.Trim(); dataGrid.ItemsSource = null; string www = TxtConvertText(bb); dataGrid.ItemsSource = GetDataTable(" where " + www).DefaultView; if (dataGrid.Items.Count == 0) { return; } //dataGrid.SelectedItem = dataGrid.Items[1]; dataGrid.Focus(); //dataGrid.SelectedIndex = 0; var uiElement = e.OriginalSource as UIElement; dataGrid.SelectedItem = dataGrid.Items[0]; uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down)); dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.Items[dataGrid.SelectedIndex], dataGrid.Columns[0]); dataGrid.CommitEdit(); dataGrid.SelectedIndex = dataGrid.SelectedIndex; dataGrid.Focus(); //dataGrid.ScrollIntoView(dataGrid.SelectedItem, dataGrid.Columns[0]); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.F9) { if (Filtro == false) { Filtro = true; TxtFiltro.Visibility = Visibility.Visible; dt.Clear(); TxtShear.Text = ""; TxtShear.Focus(); } else { Filtro = false; TxtFiltro.Visibility = Visibility.Hidden; TxtShear.Text = ""; dt.Clear(); TxtShear.Focus(); } } return; if (e.Key == Key.F8) { if (TiboBusqueda) { TiboBusqueda = false; TxtTipoBusqueda.Text = "Busqueda por Codigo"; } else { TiboBusqueda = true; TxtTipoBusqueda.Text = "Busqueda por Nombre"; } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { dt.Clear(); try { if (TxtShear.Text.Trim() == string.Empty) { TxtShear.Focus(); } if (TxtShear.Text.Trim() == string.Empty) { return; } string bb = TxtShear.Text.Trim(); dataGrid.ItemsSource = null; string www = string.Empty; if (TiboBusqueda) { www = TxtConvertTextSinFiltro(bb); } if (!TiboBusqueda) { www = bb; } if (Filtro == false) { www = TxtConvertTextSinFiltro(bb); } if (Filtro == true) { www = TxtConvertText(bb); } dt = GetDataTable(" where " + www); foreach (System.Data.DataColumn col in dt.Columns) { col.ReadOnly = false; } //dv = new DataView(dt); // dv.Sort = "nom_ref ASC,cod_ant ASC"; //dv.Sort = "nombre ASC"; dataGrid.ItemsSource = dt.DefaultView;; //dataGrid.ItemsSource = GetDataTable(" where " + www).DefaultView; if (dataGrid.Items.Count == 0) { return; } //dataGrid.SelectedItem = dataGrid.Items[1]; dataGrid.Focus(); //dataGrid.SelectedIndex = 0; var uiElement = e.OriginalSource as UIElement; dataGrid.SelectedItem = dataGrid.Items[0]; uiElement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down)); dataGrid.CurrentCell = new DataGridCellInfo(dataGrid.Items[dataGrid.SelectedIndex], dataGrid.Columns[0]); dataGrid.CommitEdit(); dataGrid.UpdateLayout(); dataGrid.SelectedIndex = dataGrid.SelectedIndex; dataGrid.Focus(); //foreach (System.Data.DataColumn col in dt.Columns) col.ReadOnly = false; //dataGrid.ScrollIntoView(dataGrid.SelectedItem, dataGrid.Columns[0]); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void dataGrid_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Escape) { SelectItem(); e.Handled = true; } if (e.Key == Key.Left) { if (mostrartodo == false) { TxtShear.SelectAll(); TxtShear.Focus(); TxtShear.SelectAll(); e.Handled = true; } } if (e.Key == Key.F2) { DataRowView row = (DataRowView)dataGrid.SelectedItems[0]; if (row != null) { // int nPnt = Int32.Parse(row[0].ToString()); this.Codigo = row[1].ToString(); this.Nombre = row[0].ToString(); //this.IdRowReturn = nPnt; /// valida si hay saldos en bodega DataTable dtcnd = LoadBodega(codigo, idBod, 1); //cnd if (dtcnd == null) { return; } DataTable dtpv = LoadBodega(codigo, idBod, 2); //cnd if (dtpv == null) { return; } //DataTable dtcnd = LoadBodega(codigo, idBod, 21); //cnd //DataSet ds1 = LoadData(codigo, idBod); //cnd if (dtcnd.Rows.Count + dtpv.Rows.Count == 0) { MessageBox.Show("Producto:" + codigo + "-" + Nombre.Trim() + " Sin saldos en bodegas.."); return; } //MessageBox.Show(ds1.Tables[0].Rows.Count.ToString()); SaldosBodegas xx = new SaldosBodegas(this.Codigo, this.Nombre, 0, Conexion, idbod, idemp); xx.TxtLinea.Text = row["cod_tip"].ToString(); xx.TxtProveedor.Text = row["cod_prv"].ToString(); xx.dataGrid.ItemsSource = dtcnd.DefaultView; xx.dataGridPV.ItemsSource = dtpv.DefaultView; xx.TxtFecCrea.Text = fechaCreacion.ToShortDateString(); decimal sumInv = 0; decimal sumImp = 0; //foreach (System.Data.DataColumn col in ds1.Tables[0].Columns) col.ReadOnly = false; foreach (DataRow dr in dtcnd.Rows) // search whole table { decimal saldoin = Convert.ToDecimal(dr["saldo"]); //decimal saldoinImp = Convert.ToDecimal(dr["importacion"]); //dr["saldo"] = saldoin; //change the name sumInv = sumInv + saldoin; //sumImp = sumImp + saldoinImp; } xx.TotalCndExit.Text = sumInv.ToString("N2"); //xx.TotalCndImpor.Text = sumImp.ToString("N2"); xx.TotalCnd.Text = (sumInv + sumImp).ToString("N2"); decimal sumInvPv = 0; decimal sumImpPv = 0; //foreach (System.Data.DataColumn col in ds1.Tables[0].Columns) col.ReadOnly = false; foreach (DataRow dr in dtpv.Rows) // search whole table { decimal saldoinPv = Convert.ToDecimal(dr["saldo"]); //decimal saldoinImpPv = Convert.ToDecimal(dr["importacion"]); //dr["saldo"] = saldoin; //change the name sumInvPv = sumInvPv + saldoinPv; //sumImpPv = sumImpPv; //+ saldoinImpPv; } xx.TotalPvExit.Text = sumInvPv.ToString("N2"); //xx.TotalPvImpor.Text = sumImpPv.ToString("N2"); xx.TotalPv.Text = (sumInvPv + sumImpPv).ToString("N2"); xx.TotalExit.Text = (sumInv + sumInvPv).ToString("N2"); //xx.TotalImpor.Text =(sumImp+sumImpPv).ToString("N2"); xx.Total.Text = (sumInv + sumInvPv).ToString("N2"); //xx.dataGrid.ItemsSource = ds1.Tables[0].DefaultView; xx.ShowInTaskbar = false; xx.Owner = Application.Current.MainWindow; xx.dataGrid.Focus(); xx.dataGrid.SelectedItem = dataGrid.Items[0]; xx.dataGrid.SelectedIndex = 0; xx.dataGrid.Focus(); xx.dataGrid.SelectedIndex = 0; xx.ShowDialog(); e.Handled = true; } } }