private void btnSave_Click(object sender, EventArgs e) { int person = 1; // validate try { person = Int32.Parse(txtPerson.Text); if (person < 1) { person = 1; } if (dateStart.Value.Date > dateEnd.Value.Date) { MessageBox.Show("Data is date incorrect. Please edit and again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("Data is person incorrect. Please edit and again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } tblTasks task = new tblTasks(); task.re_plan_date_start = dateStart.Value.Date; task.re_plan_date_end = dateEnd.Value.Date; task.person = person; task.must_date_finish = dateMustFinish.Value.Date; task.status = cboStatus.SelectedValue; task.note = txtNote.Text; // update task.id = id; Tasks.updateRePlanById(task); MessageBox.Show("Save success!"); this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { int person = 1; // validate try { person = Int32.Parse(txtPerson.Text); if (person < 1) { person = 1; } if (dateStart.Value.Date > dateEnd.Value.Date) { MessageBox.Show("Data is date incorrect. Please edit and again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("Data is person incorrect. Please edit and again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } tblTasks task = new tblTasks(); task.task_name = txtTaskName.Text; task.task_name_en = txtTaskNameEn.Text; task.task_type = cboTaskType.SelectedValue; task.areas = cboAreas.SelectedValue; task.location = txtLocations.Text; task.plan_date_start = dateStart.Value.Date; task.plan_date_end = dateEnd.Value.Date; task.plan_person = person; task.re_plan_date_start = dateStart.Value.Date; task.re_plan_date_end = dateEnd.Value.Date; task.person = person; task.must_date_finish = dateEnd.Value.Date; task.status = 0; task.note = txtNote.Text; if (copyFlag.Checked) { task.copy_f = 1; } else { task.copy_f = 0; } task.del_f = 0; if (modeForm == 0) { // add new Tasks.insert(task); MessageBox.Show("Save success!"); refreshForm(); } else if (modeForm == 2) { // delete } else { // update task.id = id; Tasks.updateById(task); MessageBox.Show("Save success!"); this.Close(); } this.Close(); }