private void tlGuardar_Click(object sender, RoutedEventArgs e) { if (dtgrdcam.SelectedIndex < 0) { MessageBox.Show("Debe elegir una camarera", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } bool hb_ds = false; hb_ds = hab_distintas();//Método para corroborar si hay cambios en habitaciones seleccionadas Clases.C_Asignacion asg = new Clases.C_Asignacion(); string txtdescbit = ""; if (dtgrdhabsel.Items.Count == 0)//Para eliminar todas las habitaciones asignadas a una camarera { asg.EliminarAsignPorCamarera(cm_act.idCamarera); if (sp_act != null) { txtdescbit = "ELIMINACIÓN (NOMBRE CAM.='" + cm_act.nombre + " " + cm_act.apellido + "', CÉD CAM.='" + cm_act.cedula + "'; NOMBRE SUP.='" + sp_act.nombre + " " + sp_act.apellido + "', CÉD SUP.='" + sp_act.cedula + "'; "; } else { txtdescbit = "ELIMINACIÓN (NOMBRE CAM.='" + cm_act.nombre + " " + cm_act.apellido + "', CÉD CAM.='" + cm_act.cedula + "'; NOMBRE SUP.='-SIN ASIGNAR-'; "; } txtdescbit += "HABS.="; foreach (Clases.habitacionIqware h2 in hb_act) { txtdescbit += "'" + h2.RoomNo + "',"; } txtdescbit = txtdescbit.Remove(txtdescbit.Length - 1); txtdescbit += ")"; Clases.Bitacora bitc = new Clases.Bitacora(1, 3, txtdescbit, user.login); if (bitc.Guardar() == 1) { Console.WriteLine("Eliminación de asignación guardada en la bitácora"); } //----------------------------------------------------// MessageBox.Show("Asignación modificada satisfactoriamente", "Completado", MessageBoxButton.OK, MessageBoxImage.Information); DialogResult = true; Close(); return; } Clases.C_Camarera cam = dtgrdcam.SelectedItem as Clases.C_Camarera; Clases.C_Supervisor sup = dtgrdsup.SelectedItem as Clases.C_Supervisor; //------------- Bitácora ------------------------------------------// txtdescbit = "MODIFICACIÓN ("; asg.idcamarera = cam.idCamarera; asg.idUsuario = user.idUsuario; if (dtgrdsup.SelectedIndex < 0) { asg.idsupervisor = -1; } else { asg.idsupervisor = sup.idSupervisor; } if (habaux.Count > 0) { if (cm_act.idSupervisor != -1 && dtgrdsup.Items.Count != 0) //Si hay supervisores asignados en la base de datos (Viejo y Nuevo) { if (sp_act.idSupervisor != sup.idSupervisor) //Supervisores distinitos (anterior y nuevo) { txtdescbit += "NOMBRE SUP. ANT.='" + sp_act.nombre + " " + sp_act.apellido + "', CÉD SUP. ANT.='" + sp_act.cedula + "', NOMBRE SUP. NVO.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP. NVO.='" + sup.cedula + "'; "; } else { txtdescbit += "NOMBRE SUP.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP.='" + sup.cedula + "'; "; } } else if (cm_act.idSupervisor == -1 && dtgrdsup.SelectedIndex >= 0) {//Si no hay en viejo y hay en nuevo txtdescbit += "NOMBRE SUP. ANT.='SIN ASIGNAR', NOMBRE SUP. NVO.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP. NVO.='" + sup.cedula + "'; "; } else if (cm_act.idSupervisor != -1 && dtgrdsup.Items.Count == 0)//Si hay viejo y no hay en nuevo { txtdescbit += "NOMBRE SUP. ANT.='" + sp_act.nombre + " " + sp_act.apellido + "', CÉD SUP. ANT.='" + sp_act.cedula + "', NOMBRE SUP. NVO.='SIN ASIGNAR'; "; } Clases.C_Movimiento mov = new Clases.C_Movimiento(); mov.idsupervisor = dtgrdsup.SelectedIndex != -1?sup.idSupervisor:-1; mov.idCamarera = cam.idCamarera; mov.fecha = DateTime.Today; if (mov.EditarMovSup() == 1) { Console.WriteLine("Se modificó el supervisor"); } } else { asg.EliminarAsignPorCamarera(cm_act.idCamarera); if (cm_act.idCamarera != cam.idCamarera)//Camareras distintas (anterior y nueva) { txtdescbit += "NOMBRE CAM. ANT.='" + cm_act.nombre + " " + cm_act.apellido + "', CÉD CAM. ANT.='" + cm_act.cedula + "', NOMBRE CAM. NVA.='" + cam.nombre + " " + cam.apellido + "', CÉD CAM. NVA.='" + cam.cedula + "'; "; } else { txtdescbit += "NOMBRE CAM.='" + cam.nombre + " " + cam.apellido + "', CÉD CAM.='" + cam.cedula + "'; "; } if (cm_act.idSupervisor != -1 && dtgrdsup.Items.Count != 0) //Si hay supervisores asignados en la base de datos (Viejo y Nuevo) { if (sp_act.idSupervisor != sup.idSupervisor) //Supervisores distinitos (anterior y nuevo) { txtdescbit += "NOMBRE SUP. ANT.='" + sp_act.nombre + " " + sp_act.apellido + "', CÉD SUP. ANT.='" + sp_act.cedula + "', NOMBRE SUP. NVO.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP. NVO.='" + sup.cedula + "'; "; } else { txtdescbit += "NOMBRE SUP.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP.='" + sup.cedula + "'; "; } } else if (cm_act.idSupervisor == -1 && dtgrdsup.SelectedIndex >= 0) {//Si no hay en viejo y hay en nuevo txtdescbit += "NOMBRE SUP. ANT.='SIN ASIGNAR', NOMBRE SUP. NVO.='" + sup.nombre + " " + sup.apellido + "', CÉD SUP. NVO.='" + sup.cedula + "'; "; } else if (cm_act.idSupervisor != -1 && dtgrdsup.Items.Count == 0)//Si hay viejo y no hay en nuevo { txtdescbit += "NOMBRE SUP. ANT.='" + sp_act.nombre + " " + sp_act.apellido + "', CÉD SUP. ANT.='" + sp_act.cedula + "', NOMBRE SUP. NVO.='SIN ASIGNAR'; "; } if (hb_ds) { txtdescbit += "HABS. ANT.="; foreach (Clases.habitacionIqware h2 in hb_act) { txtdescbit += "'" + h2.RoomNo + "',"; } txtdescbit = txtdescbit.Remove(txtdescbit.Length - 1); txtdescbit += "; "; } //----------------------------------------------------------------------------------// txtdescbit += "HABS. NVAS.=";//Bitácora foreach (Clases.habitacionIqware h in dtgrdhabsel.ItemsSource) { txtdescbit += "'" + h.RoomNo + "',";//Bitácora asg.idhabitacion = h.ID_Room; asg.num_hab = h.RoomNo; asg.status_hab = h.status; asg.num_pax = h.GuestTotal; asg.modulo_hab = h.modulo; asg.tipo_hab = h.RoomTypeShortName; asg.idUsuario = user.idUsuario; asg.llegada = h.llegada; asg.salida = h.salida; asg.piso = h.ID_Floor; asg.Section = h.Section; asg.Guardar(); } } asg.Modificar(); //---------Bitácora -------------------------------------------// txtdescbit = txtdescbit.Remove(txtdescbit.Length - 1); txtdescbit += ")"; if (cm_act.idCamarera != cam.idCamarera || cm_act.idSupervisor != asg.idsupervisor || hb_ds) { Clases.Bitacora bit = new Clases.Bitacora(1, 2, txtdescbit, user.login); if (bit.Guardar() == 1) { Console.WriteLine("Modificación de asignación guardada en la bitácora"); } } //----------------------------------------------------// MessageBox.Show("Asignación modificada satisfactoriamente", "Completado", MessageBoxButton.OK, MessageBoxImage.Information); DialogResult = true; Close(); }
private void tlGuardar_Click(object sender, RoutedEventArgs e) { if (dtgrdcam.SelectedIndex < 0) { MessageBox.Show("Debe elegir una camarera", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (dtgrdhabsel.Items.Count == 0) { MessageBox.Show("Debe asignar por lo menos una habitación", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Clases.C_Asignacion asg = new Clases.C_Asignacion(); Clases.C_Camarera cam = dtgrdcam.SelectedItem as Clases.C_Camarera; Clases.C_Supervisor sup = dtgrdsup.SelectedItem as Clases.C_Supervisor; asg.idcamarera = cam.idCamarera; if (dtgrdsup.SelectedIndex < 0) { asg.idsupervisor = -1; } else { asg.idsupervisor = sup.idSupervisor; } #region Bitácora string txtdescbit = ""; if (dtgrdsup.SelectedIndex >= 0) { txtdescbit = "INSERCIÓN (NOM. CAM.='" + cam.nombre + " " + cam.apellido + "', CÉD. CAM.='" + cam.cedula + "'; NOM. SUP.='" + sup.nombre + " " + sup.apellido + "', CÉD. SUP.='" + sup.cedula + "'; HABS.="; } else { txtdescbit = "INSERCIÓN (NOM. CAM.='" + cam.nombre + " " + cam.apellido + "', CÉD. CAM.='" + cam.cedula + "'; -SUPERVISOR SIN ASIGNAR-; HABS.="; } foreach (Clases.habitacionIqware h in dtgrdhabsel.ItemsSource) { txtdescbit += "'" + h.RoomNo + "',"; asg.idhabitacion = h.ID_Room; asg.num_hab = h.RoomNo; asg.status_hab = h.status; asg.num_pax = h.GuestTotal; asg.modulo_hab = h.modulo; asg.tipo_hab = h.RoomTypeShortName; asg.idUsuario = user.idUsuario; asg.llegada = h.llegada; asg.salida = h.salida; asg.piso = h.ID_Floor; asg.Section = h.Section; if (asg.Guardar() == 1) { Console.WriteLine("Guardado"); } } txtdescbit = txtdescbit.Remove(txtdescbit.Length - 1); txtdescbit += ")"; Clases.Bitacora bit = new Clases.Bitacora(1, 1, txtdescbit, user.login); if (bit.Guardar() == 1) { Console.WriteLine("Inserción de asignación guardada en la bitácora"); } #endregion if (MessageBox.Show("Asignación guardada satisfactoriamente, ¿Desea imprimir el reporte de camarera?", "Confirmación", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { reporteCamarera rc = new reporteCamarera(); rc.camarera = cam; rc.supervisor = sup; rc.todos = false; rc.fecha = DateTime.Today; rc.ShowDialog(); } no_supervisor = true; Page_Loaded(sender, e); }