public void AddData(string name, object value) { switch (name) { case "КодКонтента": ID.Add((int)value); break; case "Название": ContentName.Add((string)value); break; case "Рейтинг": Rating.Add(double.Parse(value.ToString())); break; case "Год": Year.Add((int)value); break; case "Сюжет": Story.Add((string)value); break; case "Продолжительность": Duration.Add((int)value); break; case "ЦенаПокупки": PurchasePrice.Add(double.Parse(value.ToString())); break; case "ЦенаПроката": RentalPrice.Add(double.Parse(value.ToString())); break; case "Постер": Poster.Add((string)value); break; default: MessageBox.Show($"Поле {name} отсутствует!"); break; } }
private void PopulateDateCollection() { //populate months for (int i = 1; i < 13; i++) { if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3))) { Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)); } //populate year for (int i = 1990; i < 2050; i++) { Year.Add(i.ToString()); } //populate Days for (int i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++) { if (i < 10) { Day.Add("0" + i); } else { Day.Add(i.ToString()); } } Date.Add(Month); Date.Add(Day); Date.Add(Year); }
private void showBrowsedMovies(string movieName) { SqlConnection connection = new SqlConnection(ConnectionString); connection.Open(); if (connection.State == ConnectionState.Open) { string CoverQuery = "Select MediumCover From MovieSource Where Title='" + movieName + "'"; SqlCommand command = new SqlCommand(CoverQuery, connection); MPosterLinks.Add(command.ExecuteScalar().ToString()); string yearQuery = "Select Year From MovieSource Where Title='" + movieName + "'"; SqlCommand YearCommand = new SqlCommand(yearQuery, connection); Year.Add(YearCommand.ExecuteScalar().ToString()); string RuntimeQuery = "Select RunTime From MovieSource Where Title='" + movieName + "'"; SqlCommand RuntimeCommand = new SqlCommand(RuntimeQuery, connection); Runtime.Add(RuntimeCommand.ExecuteScalar().ToString()); string SevenQuery = "Select sevenHdMovie From MovieSource Where Title='" + movieName + "'"; SqlCommand SevenCommand = new SqlCommand(SevenQuery, connection); Sevenp.Add(SevenCommand.ExecuteScalar().ToString()); string TenQuery = "Select TenHdMovie From MovieSource Where Title='" + movieName + "'"; SqlCommand TenCommand = new SqlCommand(TenQuery, connection); Tenp.Add(TenCommand.ExecuteScalar().ToString()); string ThreedQuery = "Select ThreedMovie From MovieSource Where Title='" + movieName + "'"; SqlCommand ThreedCommand = new SqlCommand(ThreedQuery, connection); Threed.Add(ThreedCommand.ExecuteScalar().ToString()); } }
// Populates months, years and days which will be available in the picker private void PopulateDateCollection() { for (var i = 1; i <= 12; i++) { if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3))) { Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)); } // Available years = 2000-2025 for (var i = 2000; i < 2025; i++) { Year.Add(i.ToString()); } for (var i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++) { if (i < 10) { Day.Add("0" + i); } else { Day.Add(i.ToString()); } } Date.Add(Month); Date.Add(Day); Date.Add(Year); }
/// <summary> /// Initializes a new instance of the <see cref="ReportAnalysisViewModel"/> class. /// </summary> public ReportAnalysisViewModel() { int thisYear = DateTime.Now.Year; //显示最近10年 for (int i = 0; i < 10; i++) { Year.Add(thisYear - i); } for (int i = 0; i < 12; i++) { Month.Add(i + 1); } Initialize(); }
private void PopulateMonthAndYear() { // Populate Year for (int i = 2018; i < 2100; i++) { Year.Add(i.ToString()); } // Populate Month for (int i = 1; i < 13; i++) { Month.Add(DateTimeFormatInfo.CurrentInfo.GetMonthName(i)); } MonthAndYear.Add(Month); MonthAndYear.Add(Year); }
protected void dgYear_ItemCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Year year = new Year(); if (e.CommandName == "AddYear") { TextBox txtTempYear = (TextBox)e.Item.Cells[0].FindControl("txtYearNew"); //Validation for year Regex yearRegex = new Regex(@"^\d{4}$"); Match checkYear = yearRegex.Match(txtTempYear.Text); if (txtTempYear.Text.Trim() == "") { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Please fill in the Year!', 'error')</script>'"); } else if (!checkYear.Success) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Year must be 4 digit number!', 'error')</script>'"); } else { if (year.Add(txtTempYear.Text) == false) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'This year is existed already, try another year!', 'error')</script>'"); } else { ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Added!', text: 'Year " + txtTempYear.Text + " is added successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpYear.aspx'; }});</script>'"); } } } else if (e.CommandName == "DeleteYear") { Label rowYearID = (Label)e.Item.Cells[0].FindControl("lblID"); if (year.DeleteYear(rowYearID.Text) == false) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type='text/javascript'>swal('Error!', 'Deleted unsuccessfully', 'error')</script>'"); } else { ClientScript.RegisterStartupScript(this.GetType(), "Success", "<script type='text/javascript'>swal({title: 'Deleted!', text: 'Deleted successfully', type : 'success', confirmButtonText : 'OK'}, function (isConfirm) { if (isConfirm) { window.location.href = 'cpYear.aspx'; }});</script>'"); } } }
public TransactionSummaryViewModel() { int thisYear = DateTime.Now.Year; //显示最近10年 for (int i = 0; i < 10; i++) { Year.Add(thisYear - i); } for (int i = 0; i < 12; i++) { Month.Add(i + 1); } if (CanExecuteQueryCommand()) { ExecuteQueryCommand(); } }
private void populateDateCollection() { int startYear = 1990; int endYear = DateTime.Now.Date.Year + 20; //populate months for (int i = 1; i < 13; i++) { Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } //populate year for (int i = startYear; i < endYear; i++) { Year.Add(i.ToString()); } Date.Add(Year); Date.Add(Month); }