/// <summary> /// Создает запись о меню на день /// </summary> /// <param name="numb_queue"></param> /// <returns></returns> public string add_menu_in_day(string day, int menu_id) { try { class_menu_in_day[] menu = new class_menu_in_day[512]; string query = "select date_menu From Menu_in_day where ID_menu ='" + menu_id + "'"; SqlCommand com = Program.data_module._conn.CreateCommand(); com.CommandText = query; SqlDataReader rd = com.ExecuteReader(); int i = 0; while (rd.Read()) { i++; menu[i] = new class_menu_in_day(); menu[i].result = "OK"; menu[i].day = rd.GetDateTime(0).ToShortDateString(); if (menu[i].day == Convert.ToString(day)) { rd.Close(); rd.Dispose(); com.Dispose(); } } rd.Close(); rd.Dispose(); com.Dispose(); } catch (Exception) { return null; } return SQL_Exec(string.Format("insert into Menu_in_day (date_menu, ID_menu) values('{0}',{1})", ((day.Length == 0) ? "NULL" : day), ((menu_id.ToString().Length == 0) ? "NULL" : menu_id.ToString()))); }
/// <summary> /// возвращает список меню-дней для очереди /// </summary> /// <param name="numb_queue"></param> /// <returns></returns> public class_menu_in_day get_menu_in_day(int day_id, string day) { class_menu_in_day menu = new class_menu_in_day(); string query = "select day_id, day " + "from Menu_in_day " + "where day_id = '" + day_id + "'"; try { SqlCommand com = Program.data_module._conn.CreateCommand(); com.CommandText = query; SqlDataReader rd = com.ExecuteReader(); if (rd.Read()) { menu.result = "OK"; menu.day_id = rd.GetString(0); if (rd.IsDBNull(1)) { menu.day = ""; } else { menu.day = rd.GetString(1); } } rd.Close(); rd.Dispose(); com.Dispose(); } catch (Exception ex) { menu.result = "ERROR_" + ex.Data + " " + ex.Message; } return menu; }