public Film(Film film) { this.FilmId = film.FilmId; this.FilmType = new Type(film.FilmType.typeName);; this.FilmName = film.FilmName; this.Status = film.Status; }
public Transaction(Customer customer, Film film, int days) { Calculator calc = new Calculator(); this.customer = customer; this.film = film; this.days = days; this.price = calc.PerformOperation("useMoney", film.FilmType, days); int bonusCost = (int)calc.PerformOperation("useBonus", film.FilmType, days); this.bonusable = this.customer.bonusPoints >= bonusCost; this.bonusPoints = (this.bonusable) ? bonusCost : 0; }
private void RetrivingInfoFromBusyFilmCopy(ViewClientCard clientCard, int clientId) { string queryString = "SELECT Film.Жанр, Film.Id, Film.Название, Film.[Тип носителя], BusyFilmCopy.CopyId, BusyFilmCopy.DistrDate FROM Film, BusyFilmCopy WHERE BusyFilmCopy.ClientId='" + clientId + "' AND BusyFilmCopy.FilmId=Film.Id;"; cmd.CommandText = queryString; cmd.Connection = connection; try { connection.Open(); SqlCeResultSet rs = cmd.ExecuteResultSet(ResultSetOptions.Scrollable); string filmInvNum = ""; short flag = 0; if (rs.HasRows) { while (rs.Read()) { int FilmId = Convert.ToInt32(rs["Id"]); int CopyId = Convert.ToInt32(rs["CopyId"]); if (FilmId >= 1 && FilmId < 10) { if (CopyId >= 1 && CopyId < 10) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "00" + FilmId + "0" + CopyId; } if (CopyId >= 10 && CopyId < 100) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "00" + FilmId + "" + CopyId; } } else if (FilmId >= 10 && FilmId < 100) { if (CopyId >= 1 && CopyId < 10) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "0" + FilmId + "0" + CopyId; } if (CopyId >= 10 && CopyId < 100) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "0" + FilmId + "" + CopyId; } } else if (FilmId >= 100 && FilmId < 1000) { if (CopyId >= 1 && CopyId < 10) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "" + FilmId + "0" + CopyId; } if (CopyId >= 10 && CopyId < 100) { filmInvNum = (rs["Жанр"]).ToString().Substring(0, 2).ToUpper() + "" + FilmId + "" + CopyId; } } string filmPrice = new Film((rs["Тип носителя"]).ToString()).RentalPrice.ToString(); DateTime distributionDate = Convert.ToDateTime(rs["DistrDate"]); //DateTime returnedDate = DateTime.Now; //Convert.ToDateTime(rs["ReturnDate"]); int daysCount = Rental.GetExpireDays(distributionDate, DateTime.Now); if (daysCount != 0) { flag++; clientCard.ClientDataGridView.Rows.Add(new string[] { filmInvNum, (rs["Название"]).ToString(), distributionDate.ToShortDateString(), "-", daysCount.ToString(), filmPrice, Rental.CountOfPenny(distributionDate, DateTime.Now).ToString(), Rental.GetTotalRentalAmount(filmPrice, distributionDate, DateTime.Now).ToString() }); } else { clientCard.ClientDataGridView.Rows.Add(new string[] { filmInvNum, (rs["Название"]).ToString(), distributionDate.ToShortDateString(), "-", daysCount.ToString(), filmPrice, "-", Rental.GetTotalRentalAmount(filmPrice, distributionDate, DateTime.Now).ToString() }); } if (flag != 0) { clientCard.DebtTextBox.Text = "Да"; } else { clientCard.DebtTextBox.Text = "Нет"; } } } rs.Close(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }