示例#1
0
        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;
        }
示例#2
0
 public FormAnalysis(GasStation gs, List <Car> cars_)
 {
     InitializeComponent();
     Cars       = cars_;
     GasStation = gs;
     n          = gs.GasDeliverys.Count;
     m          = gs.MaxQueueCount;
 }
示例#3
0
        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)));
            //}
        }
示例#4
0
        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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
 public FormShowServicing(GasStation gs)
 {
     InitializeComponent();
     GS = gs;
 }