private void ManagerForm_Load(object sender, EventArgs e) { ExtensionMethods.DoubleBuffered(this.usersDataGridView, true); selectedRow = 0; SqlManipulator sql = new SqlManipulator(); try { makeTableUsers(sql.getDataLogin()); //usersDataGridView.Columns[0].Visible = false; var cities = sql.queryCities(); cityComboBox.DataSource = cities; // this.cityTableTableAdapter.Fill(this.daftarDataSet1.CityTable); makeTable(sql.getDataCity()); makeTableUsers(sql.getDataLogin()); makeValidationTable(sql.getValidationData()); startendDate = sql.findMaxminMonthDay(0); this.versionTextBox.Text = global.currentVersion.ToString(); this.versionTextBox.Enabled = false; DGV_SetStyle(this.cityDataGridView); changeCityDGVname(); changeColumnName(); selectedRow = 0; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public MaxMinClass findMaxminMonthDay(long cityID) { MaxMinClass minmax = new MaxMinClass(); try { if (cityID == 0) { DaftarModelDataContext db = new DaftarModelDataContext(cn); var q = from row in db.DaftarTables group row by true into r select new { min = r.Min(z => z.RealDate), max = r.Max(z => z.RealDate) }; foreach (var a in q) { minmax.max = a.max.Value; minmax.min = a.min.Value; } return(minmax); } else { DaftarModelDataContext db = new DaftarModelDataContext(cn); var p = from row in db.DaftarTables.Where(z => z.CityID == cityID) group row by true into r select new { min = r.Min(z => z.RealDate), max = r.Max(z => z.RealDate) }; foreach (var a in p) { minmax.max = a.max.Value; minmax.min = a.min.Value; } return(minmax); } }catch (Exception) { throw; } }