예제 #1
0
파일: MainForm.cs 프로젝트: TibsHub/FarmDBS
        //TT add new treatment button
        private void addNewTratmentBTN_Click(object sender, EventArgs e)
        {
            string treatmentStart          = TreatmentStartDateTextBox.Text; //yyyy-MM-dd
            string treatmentEnd            = TreatmentEndDateTextBox.Text;
            string treatmentCropName       = TreatmentCropNameTextBox.Text;
            int    treatmentEmployeeID     = Convert.ToInt16(employeeTreatmentTextBox.Text);
            string treatmentFertiliserType = FertiliserToUseTextBox.Text;

            Treatment treatment = new Treatment(treatmentStart, treatmentEnd, treatmentCropName, treatmentEmployeeID, treatmentFertiliserType);
            int       rows      = dbCon.addNewTreatment(treatment);

            if (rows == DBConnection.errorNoRowInserted)
            {
                MessageBox.Show(DBConnection.errorInsertTreatment);
            }
            else
            {
                dbCon.showAllTreatments(treatmentDGV);
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: TibsHub/FarmDBS
        // TT update treatment button
        private void UpdateTratmentBTN_Click(object sender, EventArgs e)
        {
            //id for update
            int ID = Convert.ToInt16(treatmentDGV.SelectedRows[0].Cells[0].Value.ToString());

            // creating object treatment
            string tStart      = TreatmentStartDateTextBox.Text;
            string tEnd        = TreatmentEndDateTextBox.Text;
            string tCrop       = TreatmentCropNameTextBox.Text;
            int    tEmployee   = Convert.ToInt16(employeeTreatmentTextBox.Text);
            string tFertiliser = FertiliserToUseTextBox.Text;

            Treatment treatment = new Treatment(tStart, tEnd, tCrop, tEmployee, tFertiliser);

            //testing  MessageBox.Show(ID.ToString() + tStart + tEnd + tCrop + tEmployee.ToString() + tFertiliser);

            //updating database
            dbCon.updateTreatment(ID, treatment);

            dbCon.showAllTreatments(treatmentDGV);
        }