예제 #1
0
        private void FormStoringJob_Load(object sender, EventArgs e)
        {
            InsertSQL StoringJob = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text   = sj1.Description;
                cbHarvest.Text  = sj1.Harvest_id.ToString();
                cbCrop.Text     = sj1.Crop_id.ToString();
                cbBox.Text      = sj1.Box_id.ToString();
                textBox5.Text   = sj1.Quantity.ToString();
                cbVehicle.Text  = sj1.Vehicle_id.ToString();
                cbEmployee.Text = sj1.Employee_id.ToString();
                dtpStart.Value  = sj1.Date_start;
                dtpEnd.Value    = sj1.Date_end;

                TestSQL ts = new TestSQL();
                cropLists    = ts.GetCropList();
                employeeList = ts.GetEmployeeList();
                vehicleList  = ts.GetVehicleList();
                boxList      = ts.GetBoxList();
                harvestLists = ts.GetHarvestingJobList();

                SowingJob sj11 = new SowingJob();

                foreach (HarvestingJob harvest in harvestLists)
                {
                    string showText = harvest.Id + ". " + harvest.Description;
                    cbCrop.Items.Add(showText);
                }

                foreach (Box box in boxList)
                {
                    string showText = box.Id + ". " + box.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }
            }
        }
예제 #2
0
        private void testSQLConnection()
        {
            bool test = TestSQL.testConnection();

            if (test == false)
            {
                MessageBox.Show("Connection Error: SQL Database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
        }
예제 #3
0
        public void checkAsignJobandAdd()
        {
            //string tableName = "sowingJob";
            //string query = "SELECT * FROM " + tableName;
            //MySqlCommand cmd = new MySqlCommand(query, MysqlDbc.Instance.getConn());
            TestSQL ts = new TestSQL();

            cropLists    = ts.GetCropList();
            employeeList = ts.GetEmployeeList();
            farmLists    = ts.GetFarmList();
            vehicleList  = ts.GetVehicleList();
            sowingLists  = ts.GetSowingJobList();

            DateTime start_date = dtpDate.Value;
            DateTime end_date = dtpDateEnd.Value;
            DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToString("MMM/dd/yyyy"));
            int      duration = 0; int todayduration = 0;

            foreach (Employee employee1 in employeeList)
            {
                var sowing_list = sowingLists.Where(employee => employee.Id == employee1.Id);

                foreach (SowingJob sowing in sowingLists)
                {
                    start_date = Convert.ToDateTime(sowing.Date_start.ToString());
                    //start_date = DateTime.ParseExact(, "MM/dd/yyyy", null);
                    end_date = Convert.ToDateTime(sowing.Date_end.ToString());
                    //end_date = DateTime.ParseExact(this.dtpDateEnd.ToString(), "MM/dd/yyyy", null);
                    duration      = Convert.ToInt32((end_date - start_date).TotalDays);
                    todayduration = Convert.ToInt32((currentDate - start_date).TotalDays);
                    if (duration < todayduration)
                    {
                        //cbEmployee.Items.Add(employee.Id.ToString());
                        //add();
                        MessageBox.Show("yes");
                    }
                    else
                    {
                        MessageBox.Show("no");
                    }
                }
            }
        }
예제 #4
0
        public void checkAssignJobandAdd()
        {
            TestSQL ts = new TestSQL();

            cropLists      = ts.GetCropList();
            employeeList   = ts.GetEmployeeList();
            farmLists      = ts.GetFarmList();
            vehicleList    = ts.GetVehicleList();
            pesticideLists = ts.GetPesticideJobList();

            DateTime start_date = Convert.ToDateTime("12/12/2018");
            DateTime end_date = Convert.ToDateTime("12/12/2018");
            DateTime currentDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"));
            int      duration = 0; int todayduration = 0;

            foreach (Employee employee in employeeList)
            {
                foreach (PesticideJob pesticide in pesticideLists)
                {
                    start_date    = Convert.ToDateTime(pesticide.Date_start.ToString());
                    end_date      = Convert.ToDateTime(pesticide.Date_end.ToString());
                    duration      = Convert.ToInt32((end_date - start_date).TotalDays);
                    todayduration = Convert.ToInt32((currentDate - start_date).TotalDays);
                    if (duration < todayduration)
                    {
                        cbEmployee.Items.Add(employee.Id.ToString());
                        //add();
                        MessageBox.Show("yes");
                    }
                    else
                    {
                        MessageBox.Show("no");
                    }
                }
            }
        }
예제 #5
0
파일: TestSQL.cs 프로젝트: ExJoker/CCBHouse
 private void Awake()
 {
     Instance = this;
 }
예제 #6
0
        private void FormPesticideJob_Load(object sender, EventArgs e)
        {
            InsertSQL pesticideJob = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text    = pjj11.Description;
                cbPesticide.Text = pjj11.Pesticide_id.ToString();
                textBox3.Text    = pjj11.Quantity_kg.ToString();
                cbSoj.Text       = pjj11.SowingJob_id.ToString();
                cbFarm.Text      = pjj11.Farm_id.ToString();
                cbCrop.Text      = pjj11.Crop_id.ToString();
                cbVehicle.Text   = pjj11.Vehicle_id.ToString();
                cbEmployee.Text  = pjj11.Employee_id.ToString();
                dtpStart.Value   = pjj11.Date_start;
                dtpEnd.Value     = pjj11.Date_end;

                TestSQL ts = new TestSQL();
                cropLists     = ts.GetCropList();
                employeeList  = ts.GetEmployeeList();
                farmLists     = ts.GetFarmList();
                vehicleList   = ts.GetVehicleList();
                pesticideList = ts.GetPesticideList();
                sowingLists   = ts.GetSowingJobList();
                employeeList  = ts.GetEmployeeList();

                SowingJob sj11 = new SowingJob();

                foreach (SowingJob sow in sowingLists)
                {
                    cbSoj.Items.Add(sow.Id);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Pesticide pest in pesticideList)
                {
                    string showText = pest.Id + ". " + pest.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }

                foreach (Farm farm in farmLists)
                {
                    string showText = farm.Id + ". " + farm.Description;
                    cbFarm.Items.Add(showText);
                }
            }
        }
예제 #7
0
        private void FormSowingJob_Load(object sender, EventArgs e)
        {
            InsertSQL sowing = new InsertSQL();

            if (state == "Edit")
            {
                tbDescription.Text = sowj.Description;
                cbCrop.Text        = sowj.Crop_id.ToString();
                nUDQty.Text        = sowj.Quantity_prop.ToString();
                cbFarm.Text        = sowj.Farm_id.ToString();
                textBox1.Text      = sowj.Used_area.ToString();
                cbVehicle.Text     = sowj.Vehicle_id.ToString();
                cbEmployee.Text    = sowj.Employee_id.ToString();
                dtpDate.Value      = sowj.Date_start;
                dtpDateEnd.Value   = sowj.Date_end;
            }


            // when form loads, get all fields data from mysql
            // then store to a bunch of list<class>
            // then all combo boxes gets data from the list<class>

            // mysql :
            // 1. get crop list from crop table
            // 2. get farm list from farm table
            // 3. get vehicle list from vehicle table
            // 4. get employee list from employee table

            // combo box
            // 5. load crop list to combo box
            // 6. load farm list to combo box
            // 7. load vehicle list to combo box
            // 8. load employee list to combo box

            // 1.
            TestSQL ts = new TestSQL();

            cropLists    = ts.GetCropList();
            employeeList = ts.GetEmployeeList();
            farmLists    = ts.GetFarmList();
            vehicleList  = ts.GetVehicleList();
            SowingJob sj11 = new SowingJob();

            //    // 5.
            foreach (Crop crop in cropLists)
            {
                string showText = crop.Id + ". " + crop.Name;
                cbCrop.Items.Add(showText);
            }

            foreach (Vehicle vehicle in vehicleList)
            {
                string showText = vehicle.Id + ". " + vehicle.Name;
                cbVehicle.Items.Add(showText);
            }

            foreach (Employee employee in employeeList)
            {
                if (employee.Admin == false)
                {
                    string showText = employee.Id + ". " + employee.Username;
                    cbEmployee.Items.Add(showText);
                }
            }

            foreach (Farm farm in farmLists)
            {
                string showText = farm.Id + ". " + farm.Description;
                cbFarm.Items.Add(showText);
            }
        }
예제 #8
0
        private void FormHarvestingJob_Load(object sender, EventArgs e)
        {
            InsertSQL crop = new InsertSQL();

            if (state == "Edit")
            {
                textBox1.Text       = hj11.Description;
                cbSoj.Text          = hj11.SowingJob_id.ToString();
                cbFarm.Text         = hj11.Farm_id.ToString();
                cbCrop.Text         = hj11.Crop_id.ToString();
                cbVehicle.Text      = hj11.Vehicle_id.ToString();
                numericUpDown1.Text = hj11.Est_quantity.ToString();
                numericUpDown2.Text = hj11.Harvested_quantity.ToString();
                cbEmployee.Text     = hj11.Employee_id.ToString();
                dtpStart1.Text      = hj11.Date_start.ToString();
                dtpEnd.Text         = hj11.Date_end.ToString();


                TestSQL ts = new TestSQL();
                cropLists    = ts.GetCropList();
                employeeList = ts.GetEmployeeList();
                farmLists    = ts.GetFarmList();
                vehicleList  = ts.GetVehicleList();
                sowingLists  = ts.GetSowingJobList();

                SowingJob sj11 = new SowingJob();

                foreach (SowingJob sow in sowingLists)
                {
                    cbSoj.Items.Add(sow.Id);
                }

                foreach (Crop crop1 in cropLists)
                {
                    string showText = crop1.Id + ". " + crop1.Name;
                    cbCrop.Items.Add(showText);
                }

                foreach (Vehicle vehicle in vehicleList)
                {
                    string showText = vehicle.Id + ". " + vehicle.Name;
                    cbVehicle.Items.Add(showText);
                }

                foreach (Employee employee in employeeList)
                {
                    if (employee.Admin == false)
                    {
                        string showText = employee.Id + ". " + employee.Username;
                        cbEmployee.Items.Add(showText);
                    }
                }

                foreach (Farm farm in farmLists)
                {
                    string showText = farm.Id + ". " + farm.Description;
                    cbFarm.Items.Add(showText);
                    //cbFarm.Items.Add(farm.Id);
                    //cbFarm.Items.Add(farm.Description);
                }
            }
        }