Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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";
                }
            }
        }