private void BTN_Editar_Click(object sender, RoutedEventArgs e) { string RPT = ""; try { if (TXT_ID.Text == "" || TXT_numero.Text == "" || CBX_Estado.SelectedItem.ToString() == "" || TXT_ID_Cliente.Text == "") { Point relativePoint = IMG_Info.PointToScreen(new Point(0d, 0d)); TXT_ID.Focus(); System.Windows.Forms.Cursor.Position = new System.Drawing.Point(Convert.ToInt32(relativePoint.X), Convert.ToInt32(relativePoint.Y)); } else { RPT = N_Habitaciones.Editar(Convert.ToInt32(TXT_ID.Text), 0, Convert.ToInt32(CBX_Costo.Text), Convert.ToInt32(TXT_numero.Text), CBX_Estado.Text); if (RPT.Equals("OK")) { System.Windows.MessageBox.Show("Se edito la habitacion", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { System.Windows.MessageBox.Show(RPT, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } Limpiar(); TXT_numero.Focus(); } catch (Exception err) { System.Windows.MessageBox.Show(err.Message, err.Source, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BTN_Insertar_Click(object sender, RoutedEventArgs e) { Random random = new Random(); try { string RPT = ""; if (TXT_numero.Text == "" || CBX_Estado.SelectedItem.ToString() == "") { System.Windows.MessageBox.Show("Por favor, llene la informacion solicitada", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); TXT_ID.Focus(); } else { A: int id = random.Next(1, 100000); DataTable exist = N_Random.Random_Exist("HABITACIONES", id); if (exist.Rows.Count >= 1) { goto A; } else { if (TXT_numero.Text == "" || CBX_Estado.SelectedItem.ToString() == "" || CBX_Costo.SelectedItem.ToString() == "") { System.Windows.MessageBox.Show("Por favor, llenar los datos solicitados", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { RPT = N_Habitaciones.Insertar(id, 0, Convert.ToInt32(CBX_Costo.Text), Convert.ToInt32(TXT_numero.Text), Convert.ToString(CBX_Estado.Text)); } if (RPT.Equals("OK")) { System.Windows.MessageBox.Show("Se inserto la habitacion", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { System.Windows.MessageBox.Show(RPT, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Limpiar(); TXT_numero.Focus(); } } } catch (Exception err) { System.Windows.MessageBox.Show(err.Message, err.Source, MessageBoxButton.OK, MessageBoxImage.Error); } }