public void AddListView() { Form2 form2 = new Form2(); if (form1.listViewWorkList.Items.Count > 0)//listview에 아이템 있으면 지우고 로드 { form1.listViewWorkList.Items.Clear(); } List <WorkCategory> worklist = form2.LoadWork(); form1.listViewWorkList.BeginUpdate(); ListViewItem item; int i = 0; while (i < worklist.Count)//listview에 삽입 { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(workcategory.day); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(workcategory.MainCategory); item.SubItems.Add(workcategory.MiddleCategory); item.SubItems.Add(workcategory.SubCategory); form1.listViewWorkList.Items.Add(item); i++; } form1.listViewWorkList.EndUpdate(); }
private void buttonLoadWorkList_Click(object sender, EventArgs e) { FrmDailyAdd form2 = new FrmDailyAdd(); int i = 0; List <WorkCategory> worklist = form2.LoadWork(); if (listViewWorkList.Items.Count > 0) { listViewWorkList.Items.Clear(); } listViewWorkList.BeginUpdate(); ListViewItem item; while (i < worklist.Count) { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(Convert.ToString(workcategory.day.ToString("yyyy-MM-dd"))); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(AddTaskName(workcategory.maindcategory_id, 1)); item.SubItems.Add(AddTaskName(workcategory.middlecategory_id, 2)); item.SubItems.Add(AddTaskName(workcategory.subcategory_id, 3)); listViewWorkList.Items.Add(item); i++; } listViewWorkList.EndUpdate(); }
public List <WorkCategory> SearchLoad() { List <WorkCategory> worklist = new List <WorkCategory>(); string keyword = textBoxInputKeyword.Text; string query = "SELECT * FROM dailywork WHERE Day LIKE'%" + keyword + "%' " + "OR MainCategory LIKE'%" + keyword + "%' OR MiddleCategory LIKE'%" + keyword + "%' OR SubCategory LIKE'%" + keyword + "%'"; //OR WHERE MiddleCategory = '" + keyword + "' OR WHERE SubCategory = '" + keyword + "' MySqlDataReader rdr = DBManager.GetInstace().Select(query); while (rdr.Read()) { WorkCategory workcategory = new WorkCategory(); workcategory.id = (int)rdr["id"]; workcategory.day = (string)rdr["Day"]; workcategory.start_time = (string)rdr["StartTime"]; workcategory.end_time = (string)rdr["EndTime"]; workcategory.MainCategory = (string)rdr["MainCategory"]; workcategory.MiddleCategory = (string)rdr["MiddleCategory"]; workcategory.SubCategory = (string)rdr["SubCategory"]; worklist.Add(workcategory); } rdr.Close(); return(worklist); }
public void AddListView() { FrmDailyAdd form2 = new FrmDailyAdd(); if (form1.listViewWorkList.Items.Count > 0)//listview에 아이템 있으면 지우고 로드 { form1.listViewWorkList.Items.Clear(); } List <WorkCategory> worklist = form2.LoadWork(); form1.listViewWorkList.BeginUpdate(); ListViewItem item; int i = 0; while (i < worklist.Count)//listview에 삽입 { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(Convert.ToString(workcategory.day.ToString("yyyy-MM-dd"))); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(AddTaskName(workcategory.maindcategory_id, 1)); item.SubItems.Add(AddTaskName(workcategory.middlecategory_id, 2)); item.SubItems.Add(AddTaskName(workcategory.subcategory_id, 3)); form1.listViewWorkList.Items.Add(item); i++; } form1.listViewWorkList.EndUpdate(); }
private void buttonLoadWorkList_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); int i = 0; List <WorkCategory> worklist = form2.LoadWork(); if (listViewWorkList.Items.Count > 0) { listViewWorkList.Items.Clear(); } listViewWorkList.BeginUpdate(); ListViewItem item; while (i < worklist.Count) { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(workcategory.day); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(workcategory.MainCategory); item.SubItems.Add(workcategory.MiddleCategory); item.SubItems.Add(workcategory.SubCategory); listViewWorkList.Items.Add(item); i++; } listViewWorkList.EndUpdate(); }
public void SearchWork() { if (form1.listViewWorkList.Items.Count > 0) { form1.listViewWorkList.Items.Clear(); } FrmDailyAdd form2 = new FrmDailyAdd(); int i = 0; List <WorkCategory> worklist = SearchLoad(); form1.listViewWorkList.BeginUpdate(); ListViewItem item; while (i < worklist.Count) { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(Convert.ToString(workcategory.day.ToString("yyyy-MM-dd"))); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(AddTaskName(workcategory.maindcategory_id, 1)); item.SubItems.Add(AddTaskName(workcategory.middlecategory_id, 2)); item.SubItems.Add(AddTaskName(workcategory.subcategory_id, 3)); form1.listViewWorkList.Items.Add(item); i++; } form1.listViewWorkList.EndUpdate(); if (form1.listViewWorkList.Items.Count == 0) { MessageBox.Show("검색결과가 없습니다."); } else { this.Close(); } }
public void SearchWork() { if (form1.listViewWorkList.Items.Count > 0) { form1.listViewWorkList.Items.Clear(); } Form2 form2 = new Form2(); int i = 0; List <WorkCategory> worklist = SearchLoad(); form1.listViewWorkList.BeginUpdate(); ListViewItem item; while (i < worklist.Count) { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; item = new ListViewItem(Convert.ToString(workcategory.id)); item.SubItems.Add(workcategory.day); item.SubItems.Add(workcategory.start_time); item.SubItems.Add(workcategory.end_time); item.SubItems.Add(workcategory.MainCategory); item.SubItems.Add(workcategory.MiddleCategory); item.SubItems.Add(workcategory.SubCategory); form1.listViewWorkList.Items.Add(item); i++; } form1.listViewWorkList.EndUpdate(); if (form1.listViewWorkList.Items.Count == 0) { MessageBox.Show("검색결과가 없습니다."); } else { this.Close(); } }
public List <WorkCategory> LoadWork() { List <WorkCategory> worklist = new List <WorkCategory>(); string query = "SELECT * FROM dailywork"; MySqlDataReader rdr = DBManager.GetInstace().Select(query); while (rdr.Read()) { WorkCategory workcategory = new WorkCategory(); workcategory.id = (int)rdr["id"]; workcategory.day = (string)rdr["Day"]; workcategory.start_time = (string)rdr["StartTime"]; workcategory.end_time = (string)rdr["EndTime"]; workcategory.MainCategory = (string)rdr["MainCategory"]; workcategory.MiddleCategory = (string)rdr["MiddleCategory"]; workcategory.SubCategory = (string)rdr["SubCategory"]; worklist.Add(workcategory); } rdr.Close(); return(worklist); }
public List <WorkCategory> SearchLoad() { List <WorkCategory> worklist = new List <WorkCategory>(); string search_date = dateTimePickerSearchWork.Value.ToString("yyyy-MM-dd"); string keyword = textBoxInputKeyword.Text; string query = ""; if (keyword == "") { query = "SELECT * FROM Task WHERE date LIKE'%" + search_date + "%'"; } else { query = "SELECT * FROM Task WHERE date LIKE'%" + search_date + "%'" + "AND Task_maincategory_id IN (SELECT id FROM MainCategory WHERE name LIKE '%" + keyword + "%') " + "OR Task_middlecategory_id IN (SELECT id FROM MiddleCategory WHERE name LIKE '%" + keyword + "%') " + "OR Task_subcategory_id IN (SELECT id FROM SubCategory WHERE name LIKE '%" + keyword + "%') "; } MySqlDataReader rdr = DailyTaskDBManager.GetInstace().Select(query); while (rdr.Read()) { WorkCategory workcategory = new WorkCategory(); workcategory.id = (int)rdr["id"]; workcategory.maindcategory_id = (int)rdr["Task_maincategory_id"]; workcategory.middlecategory_id = (int)rdr["Task_middlecategory_id"]; workcategory.subcategory_id = (int)rdr["Task_subcategory_id"]; workcategory.start_time = (string)rdr["taskstarttime"]; workcategory.end_time = (string)rdr["taskendtime"]; workcategory.day = (DateTime)rdr["date"]; worklist.Add(workcategory); } rdr.Close(); return(worklist); }
public List <WorkCategory> LoadWork() { List <WorkCategory> worklist = new List <WorkCategory>(); string query = "SELECT * FROM Task"; MySqlDataReader rdr = DailyTaskDBManager.GetInstace().Select(query); while (rdr.Read()) { WorkCategory workcategory = new WorkCategory(); workcategory.id = (int)rdr["id"]; workcategory.maindcategory_id = (int)rdr["Task_maincategory_id"]; workcategory.middlecategory_id = (int)rdr["Task_middlecategory_id"]; workcategory.subcategory_id = (int)rdr["Task_subcategory_id"]; workcategory.start_time = (string)rdr["taskstarttime"]; workcategory.end_time = (string)rdr["taskendtime"]; workcategory.day = (DateTime)rdr["date"]; //workcategory.day = (string)rdr["date"]; worklist.Add(workcategory); } rdr.Close(); return(worklist); }
public void TimeOverlap(string query) { int start_hour = dateTimePickerStartTime.Value.Hour; int end_hour = dateTimePickerEndTime.Value.Hour; int start_minute = dateTimePickerStartTime.Value.Minute; int end_minute = dateTimePickerEndTime.Value.Minute; List <WorkCategory> worklist = LoadWork(); int i = 0; int j = 0; while (i < worklist.Count)//listview에 삽입 { WorkCategory workcategory = new WorkCategory(); workcategory = worklist[i]; DateTime work_start_time = Convert.ToDateTime(workcategory.start_time); DateTime work_end_time = Convert.ToDateTime(workcategory.end_time); //등록 시간이 시작 시간과 종료시간 사이일때 if (start_hour > work_start_time.Hour && start_hour < work_end_time.Hour) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (end_hour > work_start_time.Hour && end_hour < work_end_time.Hour) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour >= work_start_time.Hour && start_hour < work_end_time.Hour && start_minute > work_start_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour > work_start_time.Hour && start_hour <= work_end_time.Hour && start_minute < work_end_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (end_hour >= work_start_time.Hour && end_hour < work_end_time.Hour && end_minute > work_start_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (end_hour > work_start_time.Hour && end_hour <= work_end_time.Hour && end_minute < work_end_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour == work_start_time.Hour && start_minute >= work_start_time.Minute && start_hour != work_end_time.Hour) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour == work_end_time.Hour && start_minute <= work_end_time.Minute && start_hour != work_start_time.Hour) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour == work_start_time.Hour && start_hour == work_end_time.Hour && start_minute >= work_start_time.Minute && start_minute <= work_end_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } else if (start_hour == work_start_time.Hour && start_hour == work_end_time.Hour && end_hour == work_end_time.Hour && end_minute <= work_end_time.Minute) { MessageBox.Show("다른 업무가 있습니다! 등록 할 수 없습니다."); j = 1; this.Close(); break; } i++; } if (j == 1) { this.Close(); } else { DBManager.GetInstace().DBquery(query); this.Close(); } }