private void InitializeLazyVariables() { _years = new Lazy <int>(() => CalcYears(), true); _quarters = new Lazy <int>(() => CalcQuarters(), true); _months = new Lazy <int>(() => CalcMonths(), true); _weeks = new Lazy <int>(() => CalcWeeks(), true); _elapsedYears = new Lazy <int>(() => Years, true); _elapsedQuarters = new Lazy <int>(() => Quarters, true); _elapsedMonths = new Lazy <int>(() => Months - (ElapsedYears * TimeSpec.MonthsPerYear), true); _elapsedDays = new Lazy <int>(() => (int)Date2.Subtract(Date1.AddYears(ElapsedYears).AddMonths(ElapsedMonths)).TotalDays, true); _elapsedHours = new Lazy <int>( () => (int)Date2.Subtract(Date1.AddYears(ElapsedYears).AddMonths(ElapsedMonths).AddDays(ElapsedDays)).TotalHours, true); _elapsedMinutes = new Lazy <int>( () => (int) Date2.Subtract(Date1.AddYears(ElapsedYears).AddMonths(ElapsedMonths).AddDays(ElapsedDays).AddHours(ElapsedHours)). TotalMinutes, true); _elapsedSeconds = new Lazy <int>( () => (int) Date2.Subtract( Date1.AddYears(ElapsedYears).AddMonths(ElapsedMonths).AddDays(ElapsedDays).AddHours(ElapsedHours).AddMinutes( ElapsedMinutes)).TotalSeconds, true); }
private void UserDialog_Closing(object sender, MaterialDesignThemes.Wpf.DialogClosingEventArgs eventArgs) { string command = (string)eventArgs.Parameter; switch (command) { case "reset": txtName.Text = ""; Date1.Date = ""; Date2.Date = ""; Date1.Clear(); Date2.Clear(); Time1.Text = ""; Time2.Text = ""; InRadioButton.IsChecked = OutRadioButton.IsChecked = false; RefreshGrid(); break; case "confirm": RefreshGrid(); break; case "cancel": Dynamics.LastEscapeTime = DateTime.Now; break; default: break; } }
public void setDate2(DateTime Date) { if (Date.ToString().Length == 22) { Date2 = Date.ToString().Substring(0, 10); } else if (Date.ToString().Length == 20) { Date2 = Date.ToString().Substring(0, 8); } else { Date2 = Date.ToString().Substring(0, 9); } String[] datearray = Date2.Split('/'); Date2 = datearray[2] + "-"; if (datearray[0].Length == 1) { Date2 += "0" + datearray[0] + "-"; } else { Date2 += datearray[0] + "-"; } if (datearray[1].Length == 1) { Date2 += "0" + datearray[1]; } else { Date2 += datearray[1]; } }
private void UserDialog_Closing(object sender, MaterialDesignThemes.Wpf.DialogClosingEventArgs eventArgs) { string command = (string)eventArgs.Parameter; switch (command) { case "reset": txtAmount1.Text = ""; txtAmount2.Text = ""; Date1.Date = ""; Date2.Date = ""; Date1.Clear(); Date2.Clear(); txtInfo.Text = ""; cmbUsers.SelectedIndex = -1; rdCard.IsChecked = rdCash.IsChecked = rdCheque.IsChecked = rdPos.IsChecked = false; RefreshGrid(); break; case "confirm": RefreshGrid(); break; case "cancel": Dynamics.LastEscapeTime = DateTime.Now; break; default: break; } }
private void UserDialog_Closing(object sender, MaterialDesignThemes.Wpf.DialogClosingEventArgs eventArgs) { string command = (string)eventArgs.Parameter; switch (command) { case "reset": Date1.Date = ""; Date2.Date = ""; Date1.Clear(); Date2.Clear(); LoadBarChartData(); break; case "confirm": LoadBarChartData(); break; case "cancel": Dynamics.LastEscapeTime = DateTime.Now; break; default: break; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Date1.SetToday(); Date2.SetToday(); Time1.SelectedTime = DateTime.Today; Time2.SelectedTime = DateTime.Today.AddDays(1).AddSeconds(-1); RefreshGrid(); }
public void Read(IntPtr data, ref int index, ref object result, ReaderContext context) { var date = new Date2(); result = date; baseSerializer.Read(data, ref index, ref result, context); date.Do(); //hack }
private void Window_Loaded(object sender, RoutedEventArgs e) { Date1.SetToday(); Date2.SetToday(); RefreshGrid(); var list = new List <Data.Good>(); list.Add(new Data.Good { Id = 0, Name = "همه" }); list.AddRange(db.Goods.ToList()); cmbItems.DataContext = list; }
public bool IsMatch(Post post) { switch (Operator) { case DateOperator.Before: return(Date1.CompareTo(post.Date) > 0); case DateOperator.Equal: return(Date1.CompareTo(post.Date) == 0); case DateOperator.After: return(Date1.CompareTo(post.Date) < 0); case DateOperator.Range: return(Date1.CompareTo(post.Date) < 0 && Date2.CompareTo(post.Date) > 0); } return(false); }
public override int GetHashCode() { unchecked { var hashCode = Number1.GetHashCode(); hashCode = (hashCode * 397) ^ Number2.GetHashCode(); hashCode = (hashCode * 397) ^ Number3.GetHashCode(); hashCode = (hashCode * 397) ^ (Numbers?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Dec1.GetHashCode(); hashCode = (hashCode * 397) ^ Dec2.GetHashCode(); hashCode = (hashCode * 397) ^ Date1.GetHashCode(); hashCode = (hashCode * 397) ^ Date2.GetHashCode(); return(hashCode); } }
/// <inheritdoc/> public override int GetHashCode() { // Overflow is fine, just wrap. unchecked { int hash = 17; hash *= 23 + DateTime1.GetHashCode(); hash *= 23 + DateTime2.GetHashCode(); hash *= 23 + Date1.GetHashCode(); hash *= 23 + Date2.GetHashCode(); return(hash); } }
public void ToDateTime() { // Arrange const string Date1 = "28/09/2011"; const string Date2 = "28/09/2011 15:35"; // Act var result1 = Date1.ToDateTime(103); var result2 = Date2.ToDateTime(-1); // Assert Assert.IsNotNull(result1); Assert.AreEqual(Date1, result1.ToString("dd/MM/yyyy")); Assert.IsNotNull(result2); Assert.AreEqual(Date2, result2.ToString("dd/MM/yyyy HH:mm")); }
public String DateString() { String dateString = null; if (Date1 != null) { if ((Date2 != null) && !Date2.Julian) { dateString = String.Format("BET {0} AND {1}", Date1.ToString(), Date2.ToString()); } else { dateString = Date1.ToString(); } } return(dateString); }
//双击新增预约 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!ClsBLL.IsPower("新增预约")) { MessageBox.Show("你没有权限新增预约!"); return; } Colindex = e.ColumnIndex; Rowindex = e.RowIndex; if (e.RowIndex < 1) { return; } DateTime Date1 = DateTime.Parse(label1.Text); DateTime Date2; string cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString(); //if (Rowindex == dataGridView1.Rows.Count) //{ // Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30); //} //else //{ // if (dataGridView1.Rows[Rowindex - 1].Cells[0].Value.ToString() == cellval) // { // Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30); // } // else // { Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval); // } //} if (Date2.CompareTo(DateTime.Now) > 0) { frmBookNew fm3 = new frmBookNew(Date2, dataGridView1.Columns[e.ColumnIndex].HeaderText); fm3.AddCarHandle += new frmBookNew.AddCar(AddCarCard); fm3.UpdateCardHoursdHandle += new frmBookNew.UpdateCardHours(SumWorkHours); fm3.Show(); } else { MessageBox.Show("选择的预约时间不能小于当前时间!"); } }
public async void SaveChanges() { if (Date1 < Date2) { bool confirmed = await JsRunTime.InvokeAsync <bool>("confirm", "Are you sure you want to make these changes?"); if (confirmed) { string tasks = ""; foreach (var item in results.Where(i => i.IsJobSelected == true)) { tasks += "'" + item.TASK_ID + "'" + ","; item.ScheduledDownTime = Date1.ToString() + " - " + Date2.ToString(); } tasks = tasks.TrimEnd(','); string insertSql = "update " + OracleTableNames.JobService + " set service_suspend_start = to_date('" + Date1.ToString() + "','MM/DD/YYYY HH:MI:SS AM')," + " service_suspend_stop = to_date('" + Date2.ToString() + "','MM/DD/YYYY HH:MI:SS AM') where task_id in (" + tasks + ")"; var sqlString = new StringContent(insertSql, Encoding.UTF8, "text/plain"); await HttpClient.PostAsync(ServiceEndpoints.EXECUTE_SQL_POST, sqlString); await GetData(); GetStatus(); ClearSelected(); Date1 = DateTime.Now; Date2 = DateTime.Now; } else { GetStatus(); Date1 = DateTime.Now; Date2 = DateTime.Now; } } else { FontColor = "red"; Message = "Start Time must be less than End Time"; GetStatus(); } await GetData(); GetStatus(); StateHasChanged(); }
private void DrawPriceLine(double price) { var idx = zedPrice.GraphPane.CurveList.IndexOf("price"); if (idx != -1) { zedPrice.GraphPane.CurveList.RemoveAt(idx); } var points = new PointPairList(); zedPrice.GraphPane.AddCurve("price", points, Color.Green, SymbolType.None); var dt1 = Date1; var dt2 = Date2.AddDays(1); while (dt1 < dt2) { points.Add(new XDate(dt1), price); dt1 = dt1.AddMinutes(1); } UpdateZedControl(); }
private void bt_MouseUp(object sender, MouseEventArgs e) { if (!ClsBLL.IsPower("更改预约时间")) { MessageBox.Show("你没有权限更改预约时间!"); ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; return; } if (((Control)sender).Tag.ToString() != "预约" && ((Control)sender).Tag.ToString() != "失约") { ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; return; } if (IsMove) { decimal top = decimal.Parse(Convert.ToString(((Control)sender).Top - dataGridView1.ColumnHeadersHeight)); decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString()); Rowindex = int.Parse(decimal.Round(top / height, 0).ToString()); if (Rowindex == -1) { Rowindex = 0; } ((Control)sender).Top = Rowindex * dataGridView1.Rows[0].Height + dataGridView1.ColumnHeadersHeight; try { if (Rowindex > -1) { //拖动完成之后更改数据库 int cols = 0; string servicetype = string.Empty; if (((Control)sender).Left >= dataGridView1.Columns[0].Width + dataGridView1.Columns[1].Width) { cols = 2; servicetype = "车身维修"; ((Control)sender).Left = dataGridView1.Columns[0].Width + dataGridView1.Columns[1].Width + Cards[Rowindex, cols] * ((Control)sender).Width; } else { cols = 1; servicetype = "机电维修"; ((Control)sender).Left = dataGridView1.Columns[0].Width + Cards[Rowindex, cols] * ((Control)sender).Width; } if (PcStartCol == cols && PcStartRow == Rowindex) //如果移动有效 { ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; } else { DateTime Date1 = DateTime.Parse(labDateTime.Text); DateTime Date2; string cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString(); Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval); if (Date2.CompareTo(DateTime.Now) < 0) //拖动之后的时间小于当前时间,不能拖动 { ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; return; } Cards[Rowindex, cols] = Cards[Rowindex, cols] + 1; Cards[PcStartRow, PcStartCol] = Cards[PcStartRow, PcStartCol] - 1; if (((Control)sender).Name != string.Empty) { int recordid = int.Parse(((Control)sender).Name); string sqlstring = "Update Booking Set BookTime='" + Date2.ToString() + "', ServiceType='" + servicetype + "',State='预约' where ID=" + recordid; //,DelayBook='延迟预约' SQLDbHelper.ExecuteSql(sqlstring); ((Control)sender).BackColor = Color.Yellow; ((Control)sender).Tag = "预约"; } Button bt = (Button)((Control)sender); ToolTip tt = new ToolTip(); tt.SetToolTip(bt, bt.ImageKey); } } } catch (Exception Err) { MessageBox.Show(Err.Message); } } IsMove = false; }
public void VerifyDate2() { Date2String = Date2?.ToString("g") ?? "null"; }
// GET: api/CheckBattery public IHttpActionResult Get() { var jsondata = "{\"object1\":{\"Период отсутствия данных\": \"Секция тепловоза\""; //co string _SQL1 = "", _SQL2 = ""; string s = ""; DateTime Date1 = DateTime.Now, Date2; int i = 0, j = 0, h = 0; List <incidentBattery> Rezult = new List <incidentBattery>(); //запрос 1 _SQL1 = "SELECT [A].[ID],[A].[Section],[B].[Number],[C].[Name],[D].[Notation] " + "FROM[diag_lcm].[Lcm].[Sections][A] " + "join[diag_lcm].[Lcm].[Locomotives][B] on[A].[LocomotiveID] = [B].ID " + "join[diag_lcm].[Config].[Configurations][C] on[B].ConfigurationID = [C].ID " + "join[diag_lcm].[Config].[Models][D] on[C].ModelID = [D].ID " + "where[C].[Name] = 'TE25KM_HZM'"; SqlConnection CoNn = new SqlConnection(); CoNn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection2"].ConnectionString; CoNn.Open(); SqlCommand cmd = CoNn.CreateCommand(); cmd.CommandTimeout = 600; //увеличение время выполнения запроса сек cmd.CommandText = _SQL1; SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) // если есть данные { while (reader.Read()) { j++; //запрос 2 _SQL2 = "SELECT [SectionID], [MeasDateTime], [Mpsu_Mess] " + "FROM [diag_lcm].[Res]._TE25KM_HZM " + "WHERE [MeasDateTime]<CONVERT(DATETIME, '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', 102) and [MeasDateTime]>CONVERT(DATETIME, '" + DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd HH:mm:ss") + "', 102) and [SectionID]=" + reader["ID"].ToString() + " ORDER BY MeasDateTime"; SqlConnection CoNn2 = new SqlConnection(); CoNn2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection2"].ConnectionString; CoNn2.Open(); SqlCommand cmd2 = CoNn2.CreateCommand(); cmd2.CommandTimeout = 600; cmd2.CommandText = _SQL2; SqlDataReader reader2 = cmd2.ExecuteReader(); i = 0; if (reader2.HasRows) // если есть данные { while (reader2.Read()) { i++; if (i == 1) { DateTime.TryParse(Convert.ToString(reader2["MeasDateTime"]), out Date1); } else { DateTime.TryParse(Convert.ToString(reader2["MeasDateTime"]), out Date2); h = (Date2.Subtract(Date1)).Hours; if (h == 1) { //jsondata += ", \"" + Convert.ToString(reader2["MeasDateTime"]) + "\":\"2ТЭ25КМ-" + Convert.ToString(reader["Number"]) + Convert.ToString(reader["Section"]) + "\""; DateTime.TryParse(Convert.ToString(reader2["MeasDateTime"]), out Date1); } if (h > 1) { jsondata += ", \"с " + Convert.ToString(Date1) + " до " + Convert.ToString(Date2) + "\":\"2ТЭ25КМ-" + Convert.ToString(reader["Number"]) + Convert.ToString(reader["Section"]) + "\""; DateTime.TryParse(Convert.ToString(reader2["MeasDateTime"]), out Date1); } } //jsondata += ", \"" + Convert.ToString(reader2["MeasDateTime"]) + "\":\"2ТЭ25КМ-" + Convert.ToString(reader["Number"]) + Convert.ToString(reader["Section"])+"\""; } } CoNn2.Close(); //s = s + " _ " + Convert.ToString(reader["Number"]) + " " + Convert.ToString(reader["Section"]) + "\n"; } } CoNn.Close(); jsondata += "}}"; //запись лог файла return(Json(jsondata)); }
private void bt_MouseUp(object sender, MouseEventArgs e) { if (!ClsBLL.IsPower("更改预约时间")) { MessageBox.Show("你没有权限更改预约时间!"); ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; return; } if (((Control)sender).Tag.ToString() != "预约" && ((Control)sender).Tag.ToString() != "失约") { //MessageBox.Show("改预约状态为“" + ((Control)sender).Tag.ToString() + "”,不能移动。"); ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; return; } if (IsMove) { //decimal top = decimal.Parse(Convert.ToString(((Control)sender).Top - PcStartTop)); //decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString()); //Rowindex += int.Parse(decimal.Round(top / height, 0).ToString()); decimal top = decimal.Parse(Convert.ToString(((Control)sender).Top - dataGridView1.ColumnHeadersHeight)); decimal height = decimal.Parse(dataGridView1.Rows[0].Height.ToString()); Rowindex = int.Parse(decimal.Round(top / height, 0).ToString()); if (top == 0)//Math.Abs(top - height) <(height * 3/4) || { return; } if (Rowindex == -1) { Rowindex = 0; } ((Control)sender).Top = Rowindex * dataGridView1.Rows[0].Height + dataGridView1.ColumnHeadersHeight; try { if (Rowindex > 0) { //拖动完成之后更改数据库 int cols = (((Control)sender).Left - dataGridView1.Columns[0].Width) / dataGridView1.Columns[1].Width + 1; DateTime Date1 = DateTime.Parse(label1.Text); DateTime Date2; string cellval = dataGridView1.Rows[Rowindex].Cells[0].Value.ToString(); Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval); //if (Rowindex == dataGridView1.Rows.Count) //{ // Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30); //} //else //{ // if (dataGridView1.Rows[Rowindex + 1].Cells[0].Value.ToString() == cellval) // { // Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval); // } // else // { // Date2 = DateTime.Parse(Date1.ToString("yyyy-MM-dd") + " " + cellval).AddMinutes(30); // } //} if (Date2.CompareTo(DateTime.Now) < 0) //拖动之后的时间小于当前时间,不能拖动 { ((Control)sender).Top = PcStartTop; ((Control)sender).Left = PcStartLeft; } string servicetype = dataGridView1.Columns[cols].HeaderText; if (((Control)sender).Name != string.Empty) { int recordid = int.Parse(((Control)sender).Name); string sqlstring = "Update Booking Set BookTime='" + Date2.ToString() + "', ServiceType='" + servicetype + "',State='预约',DelayBook='延迟预约' where ID=" + recordid; SQLDbHelper.ExecuteSql(sqlstring); ((Control)sender).BackColor = Color.Yellow; ((Control)sender).Tag = "预约"; } Button bt = (Button)((Control)sender); ToolTip tt = new ToolTip(); tt.SetToolTip(bt, bt.ImageKey); } } catch (Exception Err) { MessageBox.Show(Err.Message); } } IsMove = false; }
public Search() { this.InitializeComponent(); resourceLoader = ResourceLoader.GetForCurrentView(); #if WINDOWS_UWP if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) #endif { StatusBar.GetForCurrentView().ForegroundColor = Colors.White; title.Margin = new Thickness(10); } #if WINDOWS_UWP if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) // PC { if (!ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { titlebarName.Visibility = Visibility.Visible; } Background = App.aBrush; var titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ButtonForegroundColor = Colors.White; titleBar.ButtonInactiveForegroundColor = Colors.Gray; if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush")) { AcrylicBrush dark = new AcrylicBrush() { BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintOpacity = 0.8, TintColor = (Application.Current.RequestedTheme == ApplicationTheme.Dark) ? (Color)Resources["SystemAccentColorDark3"] : (Color)Resources["SystemAccentColorLight1"], FallbackColor = (Application.Current.RequestedTheme == ApplicationTheme.Dark) ? (Color)Resources["SystemAccentColorDark3"] : (Color)Resources["SystemAccentColorLight1"] }; Date2.Background = dark; Date2.OutOfScopeBackground = dark; AcrylicBrush light = new AcrylicBrush() { BackgroundSource = AcrylicBackgroundSource.HostBackdrop, TintOpacity = 0.9, TintColor = (Application.Current.RequestedTheme == ApplicationTheme.Dark) ? (Color)Resources["SystemAccentColorDark1"] : (Color)Resources["SystemAccentColor"], FallbackColor = (Application.Current.RequestedTheme == ApplicationTheme.Dark) ? (Color)Resources["SystemAccentColorDark1"] : (Color)Resources["SystemAccentColor"] }; Date2.CalendarItemBackground = light; } } #endif localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; stops1 = new List <Dictionary <string, string> >(); stops2 = new List <Dictionary <string, string> >(); selectedDate = DateTime.Today.Date.ToString("yyyy-MM-dd"); history = new List <string>(); historysid = new List <string>(); historylsid = new List <string>(); string[] h1 = ((string)localSettings.Values["history1"]).Split('#'); string[] h2 = ((string)localSettings.Values["history2"]).Split('#'); string[] h3 = ((string)localSettings.Values["history3"]).Split('#'); string[] h4 = ((string)localSettings.Values["history4"]).Split('#'); if (h1.Length == 3) { history.Add(h1[0]); historysid.Add(h1[1]); historylsid.Add(h1[2]); } if (h2.Length == 3) { history.Add(h2[0]); historysid.Add(h2[1]); historylsid.Add(h2[2]); } if (h3.Length == 3) { history.Add(h3[0]); historysid.Add(h3[1]); historylsid.Add(h3[2]); } if (h4.Length == 3) { history.Add(h4[0]); historysid.Add(h4[1]); historylsid.Add(h4[2]); } From.ItemsSource = history; To.ItemsSource = history; Date.Date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); Date2.SetDisplayDate((DateTimeOffset)Date.Date); Time.Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0); Window.Current.SizeChanged += Resized; Resized(this, null); InputPane.GetForCurrentView().Showing += (s, args) => { try { commandbar.Visibility = Visibility.Collapsed; } catch { } }; InputPane.GetForCurrentView().Hiding += (s, args) => { if (commandbar.Visibility == Visibility.Collapsed) { commandbar.Visibility = Visibility.Visible; } }; Loaded += (s, ev) => { From.Focus(FocusState.Programmatic); }; }
private void button2_Click(object sender, EventArgs e) { Excel.Application ex = new Microsoft.Office.Interop.Excel.Application(); ex.Visible = true; ex.SheetsInNewWorkbook = 12; Excel.Workbook workBook = ex.Workbooks.Add(Type.Missing); ex.DisplayAlerts = false; var currentYear1 = DateTime.Now.Year; for (int i = 0; i < 12; i++) { Excel.Worksheet sheet = (Excel.Worksheet)ex.Worksheets.get_Item(i + 1); sheet.StandardWidth = 3; sheet.Name = months[i]; sheet.Cells[1, 1] = String.Format("Номер отеля | День"); if (months[i] == "01" || months[i] == "03" || months[i] == "05" || months[i] == "07" || months[i] == "08" || months[i] == "10" || months[i] == "12") { for (int j = 2; j < 33; j++) { sheet.Cells[j] = String.Format("{0}", j - 1); } for (int j = 2; j < 17; j++) { sheet.Cells[j, 1] = String.Format("{0}", j - 1); } } if (months[i] == "02") { for (int j = 2; j < 31; j++) { sheet.Cells[j] = String.Format("{0}", j - 1); } for (int j = 2; j < 17; j++) { sheet.Cells[j, 1] = String.Format("{0}", j - 1); } } if (months[i] == "04" || months[i] == "06" || months[i] == "09" || months[i] == "11") { for (int j = 2; j < 32; j++) { sheet.Cells[j] = String.Format("{0}", j - 1); } for (int j = 2; j < 17; j++) { sheet.Cells[j, 1] = String.Format("{0}", j - 1); } } } SQLiteConnection sql = new SQLiteConnection(@"Data Source=D:\VS\Diplom\Guest.sqlite"); sql.Open(); int count = 0; SQLiteCommand sc4 = new SQLiteCommand("select count (*) as '" + count + "'from Гости", sql); //кол-во строк в таблице count = Convert.ToInt32(sc4.ExecuteScalar()); int[] b = new int[count]; //получение id int o = 0; SQLiteCommand sc3 = new SQLiteCommand("select id from Гости", sql); var mas1 = sc3.ExecuteReader(); while (mas1.Read()) { b[o] = Convert.ToInt32(mas1["id"]); o++; } string Date1, Date2, Number = ""; for (int j = 0; j < count; j++) { SQLiteCommand sc = new SQLiteCommand("select Дата_Заезда from Гости where id='" + b[j] + "'", sql); SQLiteCommand sc1 = new SQLiteCommand("select Дата_Выезда from Гости where id='" + b[j] + "'", sql); SQLiteCommand sc2 = new SQLiteCommand("select Номер_Комнаты from Гости where id= '" + b[j] + "'", sql); Date1 = sc.ExecuteScalar().ToString(); Date2 = sc1.ExecuteScalar().ToString(); Number = sc2.ExecuteScalar().ToString(); var currentYear = DateTime.Now.Date; string[] words = Date1.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); //разделение даты string Day = words[0]; string Month = words[1]; string Year = words[2]; words = Date2.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); string Day1 = words[0]; string Month1 = words[1]; string Year1 = words[2]; Excel.Worksheet sheet = (Excel.Worksheet)ex.Worksheets.get_Item(Month); if (listBox2.SelectedItem.ToString() == currentYear1.ToString()) { if (Month == Month1) { ((Excel.Worksheet)ex.Application.ActiveWorkbook.Sheets[Month]).Select(); Excel.Range range2 = ex.get_Range(ex.Cells[Convert.ToInt32(Number) + 1, Convert.ToInt32(Day) + 1], ex.Cells[Convert.ToInt32(Number) + 1, Convert.ToInt32(Day1) + 1]); range2.Interior.Color = ColorTranslator.ToOle(Color.Blue); } else { string h = Day1; for (int a = Convert.ToInt32(Month); a <= Convert.ToInt32(Month1); a++) { if (a != Convert.ToInt32(Month1)) { if (a == 01 || a == 03 || a == 05 || a == 07 || a == 08 || a == 10 || a == 12) { Day1 = "31"; } else if (a == 02) { Day1 = "29"; } else if (a == 04 || a == 06 || a == 09 || a == 11) { Day1 = "30"; } } ((Excel.Worksheet)ex.Application.ActiveWorkbook.Sheets[a]).Select(); Excel.Range range2 = ex.get_Range(ex.Cells[Convert.ToInt32(Number) + 1, Convert.ToInt32(Day) + 1], ex.Cells[Convert.ToInt32(Number) + 1, Convert.ToInt32(Day1) + 1]); range2.Interior.Color = ColorTranslator.ToOle(Color.Blue); Day1 = h; } } } } sql.Close(); }
protected bool Equals(CultureSample other) { if (Numbers.Where((t, i) => !t.Equals(other.Numbers[i])).Any()) { return(false); } return(Number1.Equals(other.Number1) && Number2.Equals(other.Number2) && Number3.Equals(other.Number3) && Dec1 == other.Dec1 && Dec2 == other.Dec2 && Date1.Equals(other.Date1) && Date2.Equals(other.Date2)); }