public FormManageGS(ref GasStation gs) { InitializeComponent(); GasStation = gs; ContextMenuStrip cmsGS = new ContextMenuStrip(); cmsGS.Items.Add("Добавити АЗС"); cmsGS.Items[0].Click += AddGS_Click; dgvGS.ContextMenuStrip = cmsGS; ContextMenuStrip cmsGasDel = new ContextMenuStrip(); cmsGasDel.Items.Add("Добавити колонку"); cmsGasDel.Items[0].Click += AddGasDeliver_Click; dgvGasDeliveries.ContextMenuStrip = cmsGasDel; //ContextMenuStrip cmsEmp = new ContextMenuStrip(); //cmsEmp.Items.Add("Добавити співробітника"); //cmsEmp.Items[0].Click += AddEmployee_Click; //dgvStaff.ContextMenuStrip = cmsEmp; //_isInsertNeeded = false; }
public FormAnalysis(GasStation gs, List <Car> cars_) { InitializeComponent(); Cars = cars_; GasStation = gs; n = gs.GasDeliverys.Count; m = gs.MaxQueueCount; }
private void FormManageGS_FormClosing(object sender, FormClosingEventArgs e) { GasStation = GetSelectedGasStation(); //if (GasStation.GasDeliverys.Count == 0) //{ // MessageBox.Show("На станції повинна бути хоча б одна колонка"); // e.Cancel = true; // return; //} MainForm.GasStation = GasStation; //GS = new List<GasStation>(); //for (int i = 0; i < dgvGS.RowCount; i++) //{ // GS.Add(new GasStation(Convert.ToInt32(dgvGS.Rows[i].Cells[0].Value), // Convert.ToString(dgvGS.Rows[i].Cells[1].Value), // Convert.ToString(dgvGS.Rows[i].Cells[2].Value))); //} }
private GasStation GetSelectedGasStation() { int rowNum = GetRowNumFromGSID(); if (rowNum == -1) { return(null); } GasStation GS = new GasStation(selectedGSID, dgvGS.Rows[rowNum].Cells[1].Value.ToString(), dgvGS.Rows[rowNum].Cells[2].Value.ToString()); List <GasDeliver> GDList = new List <GasDeliver>(); List <object[]> tmpGDList = GlobalConnection.ExecReaderToList("select * from gas_deliver where gas_deliver.gas_station_id = " + selectedGSID); for (int i = 0; i < tmpGDList.Count; i++) { GDList.Add(new GasDeliver(Convert.ToInt32(tmpGDList[i][0]), tmpGDList[i][1].ToString())); // 0 - id, 1 - type, 2 - gas_station_id } GS.GasDeliverys = GDList; //GS.Employees = employeeList; return(GS); }
private void MainForm_Load(object sender, EventArgs e) { //List<Car> cars = new List<Car>(); //cars.Add(new Car(1)); //cars.Add(new Car(2)); //cars.Add(new Car(3)); //List<Car> tmp = cars.Where(car => car.LeaveTime != DateTime.MinValue).ToList(); //Car res = tmp.Find(car => car.LeaveTime == tmp.Min(c => c.LeaveTime)); ////Car cc = cars.Find(c => c.LeaveTime == cars.Min(car => car.LeaveTime)); //dgvServicing.Rows.Add(); SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.IntegratedSecurity = true; builder.DataSource = "localhost"; builder.InitialCatalog = "AZS"; GlobalConnection.SetSQLConnection(new SqlConnection(builder.ConnectionString)); GlobalConnection.Connection.Open(); SqlCommand cmd = new SqlCommand("delete from servicing where car_leave_time is null", GlobalConnection.Connection); cmd.ExecuteNonQuery(); try { //get id from file int gsID; using (StreamReader sr = new StreamReader("Help.txt")) { gsID = Convert.ToInt32(sr.ReadLine().Split('=')[1]); } // create gas station (select) string loc = ""; string brand = ""; string selectGS = "select * from gas_station where id = " + gsID; GlobalConnection.ExecReader(selectGS); if (GlobalConnection.Reader.HasRows) { for (int i = 0; GlobalConnection.Reader.Read(); i++) { loc = GlobalConnection.Reader.GetValue(1).ToString(); brand = GlobalConnection.Reader.GetValue(2).ToString(); } } GlobalConnection.CloseReader(); GasStation = new GasStation(gsID, loc, brand); List <GasDeliver> GDList = new List <GasDeliver>(); List <object[]> tmpGDList = GlobalConnection.ExecReaderToList("select * from gas_deliver where gas_deliver.gas_station_id = " + gsID); for (int i = 0; i < tmpGDList.Count; i++) { GDList.Add(new GasDeliver(Convert.ToInt32(tmpGDList[i][0]), tmpGDList[i][1].ToString())); // 0 - id, 1 - type, 2 - gas_station_id } GasStation.GasDeliverys = GDList; GasStationSelectedEvent(); RefreshDgvServicing(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public FormShowServicing(GasStation gs) { InitializeComponent(); GS = gs; }