public void Init() { if (!File.Exists(StopPath)) { File.CreateText(StopPath); } Stop = File.ReadAllText(StopPath, Encoding.Default).ToEntity <StopModel>(); if (Stop.LastDateTime == null) { SetStopTimer(); } else { LastDate = Stop.LastDateTime; LastDateStr = LastDate?.ToString("yyyy-MM-dd HH:mm:ss"); OnPropertyChanged(nameof(LastDate)); } BeginTimer(); if (Stop.StopType != null) { StopMsgStr = Stop.Codes[Stop.StopType ?? 0].Text; OnPropertyChanged(nameof(StopMsgStr)); } else { if (Stop.LastDateTime != null && (DateTime.Now - Stop.LastDateTime).Value.TotalSeconds > App.Config.StopDelay) { ShowStop(); } } }
public MainWindow() { InitializeComponent(); _vm = (MainWindowViewModel)DataContext; var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ConfigFile = location + @"\start.cfg"; var line = File.Exists(ConfigFile) ? File.ReadLines(ConfigFile)?.FirstOrDefault(p => !string.IsNullOrWhiteSpace(p))?.Trim() : string.Empty; if (string.IsNullOrWhiteSpace(line)) { StartDate = DateTime.Now; LastDate = DateTime.Now; Shift = 0; SaveConfig(); } else { StartDate = Convert.ToDateTime(ConfigValue(@"Start", DateTime.Now.ToString())); LastDate = Convert.ToDateTime(ConfigValue(@"Last", DateTime.Now.ToString())); Shift = ulong.Parse(ConfigValue(@"Shift", @"0")); SetDate(LastDate); } _vm.StartDate = StartDate.ToString(@"yyyy/MM/dd HH:mm:ss"); _vm.LastDate = LastDate.ToString(@"yyyy/MM/dd HH:mm:ss"); _vm.Shift = Shift; DateSet += (sender, args) => SaveConfig(); }
private void ShiftButton_Click(object sender, RoutedEventArgs e) { var tag = ((sender as Button)?.Tag ?? null)?.ToString()?.Trim(); if (string.IsNullOrWhiteSpace(tag)) { return; } if (!byte.TryParse(tag, out var value) || value < 0 || value > 1) { return; } if (value == 0) { if (Shift == 0) { return; } --Shift; } else { if (Shift == ulong.MaxValue) { return; } ++Shift; } _vm.Shift = Shift; LastDate = StartDate.AddDays(Shift); _vm.LastDate = LastDate.ToString(@"yyyy/MM/dd HH:mm:ss"); SetDate(LastDate); }
protected override string RequestUrl() { string sUrl = "/common/arenaDetails.asp?outputType=XML&actionType=view"; if (ArenaId != 0) { sUrl += "&arenaID=" + ArenaId; } if (StatsType != ArenaDetailsRequest.StatsTypeEnum.MyArena) { sUrl += "&StatsType=" + StatsType.ToString(); } if (MatchType != ArenaDetailsRequest.MatchTypeEnum.All) { sUrl += "&MatchType=" + MatchType.ToString(); } if (FirstDate != DateTime.MinValue) { sUrl += "&FirstDate=" + FirstDate.ToString("yyyy-MM-dd HH:mm:ss"); } if (LastDate != DateTime.MinValue) { sUrl += "&LastDate=" + LastDate.ToString("yyyy-MM-dd HH:mm:ss"); } if (StatsLeagueID != 0) { sUrl += "&StatsLeagueID=" + StatsLeagueID; } return(sUrl); }
public void SetStopTimer() { LastDate = DateTime.Now; LastDateStr = LastDate?.ToString("yyyy-MM-dd HH:mm:ss"); Stop.LastDateTime = LastDate; StopMsgStr = ""; OnPropertyChanged(nameof(StopMsgStr)); OnPropertyChanged(nameof(LastDate)); SaveStop(); }
// Override ToString() public override string ToString() { CultureInfo gr = new CultureInfo("el-GR"); if (LastBalance == -1) { return("Unable to retrieve summary for " + UserName + ". Possible connection Error."); } return("User name: " + UserName + " / Last transaction date: " + LastDate.ToString("d", gr) + " / Account Balance: " + LastBalance.ToString("c", gr)); }
private void SaveConfig() { var lines = new List <string> { $"Start\t{StartDate.ToString(@"yyyy/MM/dd HH:mm:ss")}", //$"Start\t{_vm.StartDate}", $"Last\t{LastDate.ToString(@"yyyy/MM/dd HH:mm:ss")}", //$"Last\t{_vm.LastDate}", $"Shift\t{Shift}", }; File.WriteAllLines(ConfigFile, lines); }
public void Add() { Description = Description.Replace("'", "''"); string sql = @"INSERT INTO Listings (ListingCode, Title, CategoryId, SellerId, Price, Location, Description, AddedDate, LastDate, ImageUrl) VALUES (" + ListingCode + ", '" + Title + "', " + Category.Id + "," + User.Id + ", " + Price + ", '" + Location + "','" + Description + "', '" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + LastDate.ToString("yyyy-MM-dd") + "','" + ImageUrl + "')"; Db.execute(sql); }
static void Main() { ResearchTeam researchTeam = new ResearchTeam(); Console.WriteLine(researchTeam.ToShortString()); Console.WriteLine(researchTeam[ResearchTeam.TimeFrame.Long]); Console.WriteLine(researchTeam[ResearchTeam.TimeFrame.TwoYears]); Console.WriteLine(researchTeam[ResearchTeam.TimeFrame.Year]); Paper[] papers = new Paper[1]; papers[0] = new Paper(); researchTeam.ResearcTopic = "Ideal Coffee"; researchTeam.Organization = "World best Barista"; researchTeam.Number = 5; researchTeam.Time = ResearchTeam.TimeFrame.Long; researchTeam.List = papers; Console.WriteLine(researchTeam.ToString()); Paper LastDate; LastDate = researchTeam.Lastdate; Console.WriteLine(LastDate.ToString()); //Чистим консоль Console.WriteLine("\nPress any key to continue"); Console.ReadKey(); Console.Clear(); researchTeam.List = new Paper[0]; //Чистка журнала Console.WriteLine("Enter number of articles (rows, coloumns) (You can choose separators between:\n',', '.', '|'): "); string[] size = new string[2]; char[] separators = new char[3]; separators[0] = ','; separators[1] = '|'; separators[2] = '.'; // Массив содержащий символы-разделители string input = Console.ReadLine(); size = input.Split(separators); // Разделяем вводимую строку и записываем по частям в массив size int rows = Convert.ToInt32(size[0]); // int coloumns = Convert.ToInt32(size[1]); // Записываем размеры в переменные типа int Paper[] papers1 = new Paper[rows * coloumns]; Paper[,] papers2matrix = new Paper[rows, coloumns]; Paper[][] papers2stairs = new Paper[rows][]; // Одномерный массив int timerpaper1 = 0; for (int i = 0; i < papers1.Length; ++i) { papers1[i] = new Paper(); } timerpaper1 = Environment.TickCount; researchTeam.AddPapers(papers1); Console.WriteLine($"{researchTeam.ToString()}\n:One-direct array"); timerpaper1 = Environment.TickCount - timerpaper1; //Чистим консоль Console.WriteLine("\nPress any key to continue"); Console.ReadKey(); Console.Clear(); researchTeam.List = new Paper[0]; //Чистка журнала //Двумерный ступенчатый int timerpaper2stairs = 0; int sum = 0; for (int i = 0; i < rows - 1; ++i) { sum += i; papers2stairs[i] = new Paper[i + 1]; } papers2stairs[rows - 1] = new Paper[coloumns * rows - sum]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < papers2stairs[i].Length; ++j) { papers2stairs[i][j] = new Paper(); } } timerpaper2stairs = Environment.TickCount; for (int i = 0; i < rows; ++i) { researchTeam.AddPapers(papers2stairs[i]); } Console.WriteLine($"{researchTeam.ToString()}\n:Two-direct stairs array"); timerpaper2stairs = Environment.TickCount - timerpaper2stairs; //Чистим консоль Console.WriteLine("\nPress any key to continue"); Console.ReadKey(); Console.Clear(); researchTeam.List = new Paper[0]; //Чистка журнала //Двумерная матрица int timerpaper2matrix = 0; for (int i = 0; i < rows; ++i) { for (int j = 0; j < coloumns; ++j) { papers2matrix[i, j] = new Paper(); } } timerpaper2matrix = Environment.TickCount; for (int i = 0; i < rows; ++i) { for (int j = 0; j < coloumns; ++j) { researchTeam.AddPapers(papers2matrix[i, j]); } } Console.WriteLine($"{researchTeam.ToString()}\n:Two-direct matrix"); timerpaper2matrix = Environment.TickCount - timerpaper2matrix; //Чистим консоль Console.WriteLine("\nPress any key to continue"); Console.ReadKey(); Console.Clear(); Console.WriteLine($"Time for One-Directional array: {timerpaper1}\n" + $"Time for Two-Directional stairs array: {timerpaper2stairs}\n" + $"Time for Two-Directional matrix array: {timerpaper2matrix}"); }
public Product Add() { string sql = @"INSERT INTO Product (Title, Description, Price, PublishDate, LastDate, SellerId, Image) VALUES ('" + Title + "', '" + Description + "', " + Price + ", " + PublishDate.ToString("dd-mm-yyyy") + ", " + LastDate.ToString("dd-mm-yyyy") + ", " + SellerId + ", '" + Image + "')"; var _id = Db.executeandGetId(sql); Id = int.Parse(_id); return(this); }
private void button1_Click(object sender, EventArgs e) { string StartDate; string LastDate; int i = 0; StartDate = dateTimePicker1.Value.ToString("dd-MM-yyyy"); LastDate = dateTimePicker2.Value.ToString("dd-MM-yyyy"); SqlCommand cmd = con.CreateCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from tblPurchaseInfo where ProductPurchaseDate >='" + StartDate.ToString() + "' AND ProductPurchaseDate <='" + LastDate.ToString() + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.Fill(dt); dataGridView1.DataSource = dt; foreach (DataRow dr in dt.Rows) { i = i + Convert.ToInt32(dr["ProductTotal"].ToString()); } label5.Text = i.ToString(); query = "select * from tblPurchaseInfo where ProductPurchaseDate >='" + StartDate.ToString() + "' AND ProductPurchaseDate <='" + LastDate.ToString() + "'"; int j = 0; j = Convert.ToInt32(dataGridView1.Rows.Count.ToString()); label8.Text = j.ToString(); }