private void handlePay() { if (lista.Rows.Count == 0) { return; } pagar.Enabled = false; foreach (DataGridViewRow row in lista.Rows) { int id = int.Parse(row.Cells["ID"].Value.ToString()); string product = row.Cells["Productos"].Value.ToString(); int cantidad = int.Parse(row.Cells["Cantidad"].Value.ToString()); decimal precio = decimal.Parse(row.Cells["Import"].Value.ToString()); int stock = 0; int.TryParse(row.Cells["Inv"].Value.ToString(), out stock); bool isService = bool.Parse(row.Cells["Servicio"].Value.ToString()); string observation = ""; if (row.Cells["Observacion"].Value != null) { observation = row.Cells["Observacion"].Value.ToString(); } string shamppo = ""; int knife = 0; if (row.Cells["Navaja"].Value != null) { if (!int.TryParse(row.Cells["Navaja"].Value.ToString(), out knife)) { shamppo = row.Cells["Navaja"].Value.ToString(); } } if (!isService) { ProductItem productItem = new ProductItem(id, product, precio, cantidad, stock, isService, isService); products.Add(productItem); } else { Service service = new Service(id, product, CurrentPet.GetID().HasValue ? CurrentPet.GetID().Value : 0, CurrentClient.GetID(), precio); if (observation.Length > 0) { if (knife > 0) { var hairCut = new HairCut(knife, observation); service.SetHairCutInformation(hairCut); } else if (shamppo.Length > 0) { var hairCut = new HairCut(0, observation); service.SetHairCutInformation(hairCut); service.setShampoo(shamppo); } } services.Add(service); } } printTicket(); }
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { int id = int.Parse(mascotas.Rows[mascotas.SelectedRows[0].Index].Cells["MascotaID"].Value.ToString()); string name = mascotas.Rows[mascotas.SelectedRows[0].Index].Cells["Mascota"].Value.ToString(); CurrentPet.SetCurrentPet(new CurrentPet(id, name, 0, "")); handlePetRegister(); PetNote.Enabled = true; } catch (Exception ex) { NotificationsCenter.ShowErrorMessageForException(ex); } }
private async void MoveRight() { int distance = (int)(New_Position_X - (CurrentPet.X + (CurrentPet.Width / 2))); if (CurrentPet.X + CurrentPet.Width / 2 < BoxWidth) //Check if image does not exceed right edge { if (New_Position_X > BoxWidth - CurrentPet.Width / 2) { await CurrentPet.TranslateTo(distance - CurrentPet.Width / 2, 0, 500, Easing.Linear); } else { await CurrentPet.TranslateTo(distance, 0, 500, Easing.Linear); } } }
private async void MoveLeft() { int distance = (int)-(CurrentPet.X + CurrentPet.Width / 2) + New_Position_X; if (CurrentPet.X + CurrentPet.Width / 2 > 0) //Check if image does not exceed left edge { if (New_Position_X < CurrentPet.Width / 2) { await CurrentPet.TranslateTo(distance + CurrentPet.Width / 2, 0, 500, Easing.Linear); } else { await CurrentPet.TranslateTo(distance, 0, 500, Easing.Linear); } } }
private void MoveToPosition() { //This code will trigger upon either idle state or when user touches the screen if (CurrentPet.PetStateValue == Pet.PetState.Alive) { if (CurrentPet.X + CurrentPet.Width / 2 > New_Position_X) //Cursor is left of pet { CurrentPet.RotateYTo(360, 1); MoveLeft(); } else if (CurrentPet.X + CurrentPet.Width / 2 < New_Position_X) //Cursor is right of pet { CurrentPet.RotateYTo(180, 1); MoveRight(); } } }
private void handlePetRegister() { if (CurrentPet.GetID() != null) { if ((DataTable)registro.DataSource != null) { registro.DataSource = null; registro.Rows.Clear(); } else { registro.Rows.Clear(); } sqlHelper.FillPetRegister(CurrentPet.GetID().Value, registro); DangerPetIndicator.Enabled = true; DangerPetIndicator.Checked = sqlHelper.IsDangerousPet(CurrentPet.GetID().Value); } }
//---------------------------------------STATES------------------------------------------------------------------------------------------------- public void Step(object source, ElapsedEventArgs e) { /* This code triggers every 5 seconds blah blah blah * It will simulate idle movement when going without user interaction * 1. Generate an x coordinate within the bounds of the size of the window * 2. Act as if the player were to control the pet using that coordinate * */ Random random = new Random(); int i = random.Next(0, 4); switch (i) { case (0): //Random Movement (LEFT/RIGHT) IdleMove(); break; case (1): //Bounce High CurrentPet.BounceHigh(); break; case (2): //Bounce Low CurrentPet.BounceLow(); break; //case (3): // //Bounce High with a jump // CurrentPet.BounceJump(); // break; case (3): //Bounce High with a jump CurrentPet.BounceMicro(); break; } PetTimer.Stop(); //Having this here keeps the pet from lagging during opening idle animations PetTimer.Interval = 6 * 1000; //3 seconds, shorter time for idle state PetTimer.Start(); }
private void DangerPetIndicator_OnChange(object sender, EventArgs e) { try { var petRegister = new PetRegister(CurrentClient.GetID(), CurrentPet.GetID().Value, DangerPetIndicator.Checked ? "Mascota marcada como peligrosa" : "Mascota marcada como no peligrosa", DateTime.Now, "Rojo"); if (sqlHelper.SavePetRegister(petRegister)) { NotificationsCenter.ShowSucessMessage("Registro guardado", DangerPetIndicator.Checked ? "Mascota marcada como peligrosa" : "Mascota marcada como no peligrosa"); } else { NotificationsCenter.ShowErrorMessage("Error intentando guardar el registro."); } handlePetRegister(); } catch (Exception exception) { NotificationsCenter.ShowErrorMessageForException(exception); } }
private void petAddRegister_Click(object sender, EventArgs e) { if (PetNote.Text.Length == 0) { NotificationsCenter.ShowWarningMessage("Ingrese texto para el registo."); } try { var petRegister = new PetRegister(CurrentClient.GetID(), CurrentPet.GetID().Value, PetNote.Text, DateTime.Now, "Verde"); if (sqlHelper.SavePetRegister(petRegister)) { NotificationsCenter.ShowSucessMessage("Registro guardado", "Los registros están actualizados en la base de datos."); } else { NotificationsCenter.ShowErrorMessage("Error intentando guardar el registro."); } } catch (Exception exception) { NotificationsCenter.ShowErrorMessageForException(exception); } }
public void UpdateStatus() { //This code triggers every 30 minutes CurrentPet.UpdateStatus(1); CurrentPet.ChangePet(); }
public void UpdatePetStates() { CurrentPet.UpdateAllStates(); }
private void handlePetsWithNoRegister() { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConnectionString.connectionString; conn.Open(); try { SqlCommand command = new SqlCommand("insert into tblPetsRegistro values('" + CurrentPet.GetID() + "', 'Primer registro creado', 'Esta mascota ya empezó a generar historial.', 0, 'blanco', GETDATE(), GETDATE(), '" + CurrentClient.GetID() + "')", conn); statusLabel.Text = "Registro comenzado"; command.ExecuteNonQuery(); //notificationsCenter.CreateDesktopNotification(title: "Primer registro creado", message: "Esta mascota ya empezó a generar historial."); } catch (Exception ex) { MessageBox.Show(ex.Message); statusLabel.Text = "Error en el Registro"; } } }