static public List <Dictionary <String, String> > updateFreeDays(String _id, DateTime _startDate, DateTime _endDate, String _Comment) { ResultCheckBlockDays blockDays = checkBlockDays(_startDate, _endDate); if (blockDays.flag == false) { String startDate = _startDate.ToString("yyyy-MM-dd HH:mm:ss"); String endDate = _endDate.ToString("yyyy-MM-dd HH:mm:ss"); String dateNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); using (MySqlConnection Conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["customersConnectionString"].ConnectionString)) { MySqlCommand Command = new MySqlCommand(@"UPDATE fortigate.FreeDayEmployee SET startDate = '" + startDate + "', endDate = '" + endDate + "', comment = '" + _Comment + "', initialDate = '" + dateNow + "' WHERE id like '" + _id + "';", Conn); Conn.Open(); try { Command.ExecuteNonQuery(); } catch { } finally { Conn.Close(); } } return(null); } else { return(blockDays.BlockDays); } }
static public List <Dictionary <String, String> > insertFreeDay(String fullName, DateTime _startDate, DateTime _endDate, String _Comment) { ResultCheckBlockDays blockDays = checkBlockDays(_startDate, _endDate); if (blockDays.flag == false) { ActiveDirectory activeDirectory = new ActiveDirectory(); String _id = activeDirectory.Get_Fixed_Name(fullName); if (_id != "Cant Get Fixed Name" && _id != "Get Multiple Fixed Name") { String employeeName = activeDirectory.Get_Fixed_Name_id(_id); String manager_id = activeDirectory.Get_Name(_id, "manager").Split('=').ToArray <String>()[1].Substring(0, 8); String manager_name = activeDirectory.Get_Fixed_Name_id(manager_id); employeeName = employeeName.Replace("'", "''"); String startDate = _startDate.ToString("yyyy-MM-dd HH:mm:ss"); String endDate = _endDate.ToString("yyyy-MM-dd HH:mm:ss"); String dateNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); using (MySqlConnection Conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["customersConnectionString"].ConnectionString)) { MySqlCommand Command = new MySqlCommand(@"Insert into fortigate.FreeDayEmployee (employee_id, employee_name, manager_name, startDate, endDate, comment, initialDate) Values('" + _id + "','" + employeeName + "','" + manager_name + "','" + startDate + "','" + endDate + "','" + _Comment + "','" + dateNow + "');", Conn); Conn.Open(); try { Command.ExecuteNonQuery(); } catch { } finally { Conn.Close(); } } return(null); } else if (_id == "Cant Get Fixed Name") { List <Dictionary <String, String> > error_message_list = new List <Dictionary <String, String> >(); Dictionary <String, String> error_message = new Dictionary <String, String>(); error_message.Add("error_message", "Cant Get Fixed Name"); error_message_list.Add(error_message); return(error_message_list); } else if (_id == "Get Multiple Fixed Name") { List <Dictionary <String, String> > error_message_list = new List <Dictionary <String, String> >(); Dictionary <String, String> error_message = new Dictionary <String, String>(); error_message.Add("error_message", "Get Multiple Fixed Name"); error_message_list.Add(error_message); return(error_message_list); } return(null); } else { return(blockDays.BlockDays); } }