private void btn_back_Click(object sender, EventArgs e) { AroundForm form = new AroundForm(maniForm, cpoint_id); form.Show(); this.Close(); }
private void btn_around_Click(object sender, EventArgs e) { check_conn(); if (btn_around.Text == "เปิดกะ") { string around = ""; if (DateTime.Now.TimeOfDay >= DateTime.ParseExact("06:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("14:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay) { around = "2"; } if (DateTime.Now.TimeOfDay >= DateTime.ParseExact("14:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("22:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay) { around = "3"; } if ((DateTime.Now.TimeOfDay >= DateTime.ParseExact("22:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("23:59:59", "HH:mm:ss", CultureInfo.InvariantCulture).TimeOfDay)) { around = "1"; //MessageBox.Show(around); } if ((DateTime.Now.TimeOfDay >= DateTime.ParseExact("00:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("06:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay)) { around = "1"; //MessageBox.Show(around); } //IndexForm formMain = new IndexForm(); string check_around_open = "SELECT* FROM tbl_status_around WHERE tbl_status_around_aid = '" + around + "' AND `tbl_status_around_date` = '" + script.GetDateAround(int.Parse(around)).ToString("dd-MM-yyyy") + "' AND `tbl_status_around_cpoint_id` = '" + cpoint_id + "' AND `tbl_status_around_cpoint_sub_id` = '" + sub_cpoint + "' "; MySqlDataReader rs = script.Select_SQL(check_around_open); if (rs.Read()) { MessageBox.Show("ขณะนี้เวลา " + DateTime.Now.ToString("HH:mm") + " น. มีข้อมูลเปิดกะที่ " + around + " ด่าน" + script.GetCpoint(cpoint_id) + " " + sub_cpoint + " ในระบบแล้ว ไม่อนุญาติให้มีการเปิดกะซ้ำ", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { AroundForm form = new AroundForm(this, cpoint_id); form.ShowDialog(); } } else { string around = ""; if (DateTime.Now.TimeOfDay >= DateTime.ParseExact("06:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("14:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay) { around = "2"; } if (DateTime.Now.TimeOfDay >= DateTime.ParseExact("14:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("22:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay) { around = "3"; } if ((DateTime.Now.TimeOfDay >= DateTime.ParseExact("22:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("00:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay) || (DateTime.Now.TimeOfDay >= DateTime.ParseExact("00:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay&& DateTime.Now.TimeOfDay < DateTime.ParseExact("06:00", "HH:mm", CultureInfo.InvariantCulture).TimeOfDay)) { around = "1"; } if (around_num != around) { string sql = "SELECT * FROM tbl_income JOIN tbl_status_around ON tbl_income_around_id = tbl_status_around_id WHERE tbl_status_around_emp_open_id = '" + emp_control_id + "' AND tbl_income_status_job = '0'"; MySqlDataReader rs = script.Select_SQL(sql); if (!rs.Read()) { rs.Close(); string date = DateTime.Now.ToString("dd-MM-yyyy"); bool check_status = true; string sql_check = "SELECT * FROM tbl_incom_other WHERE tbl_incom_other_date_send ='" + date + "' AND (tbl_incom_other_list_incom_id = 3 OR tbl_incom_other_list_incom_id = 2)"; MySqlDataReader reader = script.Select_SQL(sql_check); if (reader.Read()) { if (!reader.IsDBNull(0)) { check_status = false; } } reader.Close(); script.conn.Close(); if (check_status) { ConfirmCloseAroundForm confirmClose = new ConfirmCloseAroundForm(); confirmClose.ShowDialog(); if (confirmClose.comfirmClose) { AroundCloseForm closeAround = new AroundCloseForm(this); closeAround.ShowDialog(); } } } else { MessageBox.Show("ยังมีพนักงานปฏิบัติงานอยู่ไม่สามารถปิดกะได้", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("ยังถึงเวลาปิดกะ" /*+around+" "+around_num*/, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }