コード例 #1
0
        public List <SchedulerDataModel> searchEventByTime(SchedulerDataModel obj)
        {
            List <SchedulerDataModel> filteredData = new List <SchedulerDataModel>();

            using (MySqlConnection con = new MySqlConnection(constr))
            {
                string query = "SELECT Id,  Attendees   FROM schedulerdb.tbleventlist where Id=" + obj.Id + " ";
                using (MySqlCommand cmd = new MySqlCommand(query))
                {
                    cmd.Connection = con;
                    con.Open();
                    using (MySqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            filteredData.Add(new SchedulerDataModel
                            {
                                Id = Convert.ToInt32(sdr["Id"]),
                                attendeesAsString = sdr["Attendees"].ToString(),
                            });
                        }
                    }
                    con.Close();
                }
            }

            return(filteredData);
        }
コード例 #2
0
        public string updateByDrop(SchedulerDataModel modelObj)
        {
            MySqlConnection conn = new MySqlConnection(constr);

            try
            {
                string m_att = string.Empty;
                if (modelObj.attendeesAsString != null)
                {
                    string[] _Arr = modelObj.attendeesAsString.Split(',');
                    foreach (string s in _Arr)
                    {
                        if (string.IsNullOrEmpty(m_att))
                        {
                            m_att = s;
                        }
                        else
                        {
                            m_att += "," + s;
                        }
                    }
                }

                conn.Open();
                MySqlCommand cmd = new MySqlCommand("update  schedulerdb.tbleventlist set  Attendees='" + m_att + "'  where Id=" + modelObj.Id + "  ", conn);

                //cmd.Parameters.AddWithValue("@ResourceId", modelObj.ResourceId);
                //cmd.Parameters.AddWithValue("@Attendees", m_att);

                //cmd.Parameters.AddWithValue("@StartTime", modelObj.StartTime);
                //cmd.Parameters.AddWithValue("@EndTime", modelObj.EndTime);

                int i = cmd.ExecuteNonQuery();
                cmd.Dispose();
                if (i > 0)
                {
                    return("updated successfully");
                }
                else
                {
                    return("not updated");
                }
            }
            catch (MySqlException ex)
            {
                return("exception found");
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #3
0
        public string UpdateEvent(SchedulerDataModel modelObj)
        {
            MySqlConnection conn = new MySqlConnection(constr);

            try
            {
                if (string.IsNullOrEmpty(modelObj.StartTimezone))
                {
                    modelObj.StartTimezone = "";
                }
                if (string.IsNullOrEmpty(modelObj.EndTimezone))
                {
                    modelObj.EndTimezone = "";
                }
                if (string.IsNullOrEmpty(modelObj.RecurrenceRule))
                {
                    modelObj.RecurrenceRule = "";
                }
                if (modelObj.RecurrenceID == null)
                {
                    modelObj.RecurrenceID = 0;
                }
                if (string.IsNullOrEmpty(modelObj.RecurrenceException))
                {
                    modelObj.RecurrenceException = "";
                }
                string m_att = string.Empty;
                if (modelObj.Attendees != null)
                {
                    foreach (string s in modelObj.Attendees)
                    {
                        if (string.IsNullOrEmpty(m_att))
                        {
                            m_att = s;
                        }
                        else
                        {
                            m_att += "," + s;
                        }
                    }
                }

                conn.Open();
                MySqlCommand cmd = new MySqlCommand("update  schedulerdb.tbleventlist set  Job=@Job, Event=@Event,Attendees=@Attendees ,StartTime=@StartTime,EndTime=@EndTime,IsAllDay=@IsAllDay,RecurrenceException=@RecurrenceException where Id=" + modelObj.Id + "   ", conn);
                cmd.Parameters.AddWithValue("@Job", modelObj.Subject);
                cmd.Parameters.AddWithValue("@ResourceId", modelObj.ResourceId);
                cmd.Parameters.AddWithValue("@Attendees", m_att);
                cmd.Parameters.AddWithValue("@Event", modelObj.Event);

                cmd.Parameters.AddWithValue("@StartTime", modelObj.StartTime);
                cmd.Parameters.AddWithValue("@EndTime", modelObj.EndTime);
                cmd.Parameters.AddWithValue("@StartTimezone", modelObj.StartTimezone);
                cmd.Parameters.AddWithValue("@EndTimezone", modelObj.EndTimezone);
                cmd.Parameters.AddWithValue("@IsAllDay", modelObj.IsAllDay);
                cmd.Parameters.AddWithValue("@RecurrenceRule", modelObj.RecurrenceRule);
                cmd.Parameters.AddWithValue("@RecurrenceID", modelObj.RecurrenceID);
                cmd.Parameters.AddWithValue("@RecurrenceException", modelObj.RecurrenceException);
                int i = cmd.ExecuteNonQuery();
                cmd.Dispose();
                if (i > 0)
                {
                    return("updated successfully");
                }
                else
                {
                    return("not updated");
                }
            }
            catch (MySqlException ex)
            {
                return("exception found");
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #4
0
        public string AddEvent(SchedulerDataModel modelObj)
        {
            MySqlConnection conn = new MySqlConnection(constr);

            try
            {
                if (string.IsNullOrEmpty(modelObj.StartTimezone))
                {
                    modelObj.StartTimezone = "";
                }
                if (string.IsNullOrEmpty(modelObj.EndTimezone))
                {
                    modelObj.EndTimezone = "";
                }
                if (string.IsNullOrEmpty(modelObj.RecurrenceRule))
                {
                    modelObj.RecurrenceRule = "";
                }
                if (modelObj.RecurrenceID == null)
                {
                    modelObj.RecurrenceID = 0;
                }
                if (string.IsNullOrEmpty(modelObj.RecurrenceException))
                {
                    modelObj.RecurrenceException = "";
                }
                string m_att = string.Empty;
                if (modelObj.Attendees != null)
                {
                    foreach (string s in modelObj.Attendees)
                    {
                        if (string.IsNullOrEmpty(m_att))
                        {
                            m_att = s;
                        }
                        else
                        {
                            m_att += "," + s;
                        }
                    }
                }

                conn.Open();
                MySqlCommand cmd = new MySqlCommand("Insert into schedulerdb.tbleventlist (Job,ResourceId,Attendees,Event,StartTime,EndTime,StartTimezone,EndTimezone,IsAllDay,RecurrenceRule,RecurrenceID,RecurrenceException )  " + "values(@Job,@ResourceId,@Attendees,@Event, @StartTime, @EndTime, @StartTimezone,@EndTimezone,@IsAllDay,@RecurrenceRule,@RecurrenceID,@RecurrenceException)", conn);
                cmd.Parameters.AddWithValue("@Job", modelObj.Job);
                cmd.Parameters.AddWithValue("@ResourceId", modelObj.ResourceId);
                cmd.Parameters.AddWithValue("@Attendees", m_att);
                cmd.Parameters.AddWithValue("@Event", modelObj.Event);

                cmd.Parameters.AddWithValue("@StartTime", modelObj.StartTime);
                cmd.Parameters.AddWithValue("@EndTime", modelObj.EndTime);
                cmd.Parameters.AddWithValue("@StartTimezone", modelObj.StartTimezone);
                cmd.Parameters.AddWithValue("@EndTimezone", modelObj.EndTimezone);
                cmd.Parameters.AddWithValue("@IsAllDay", modelObj.IsAllDay);
                cmd.Parameters.AddWithValue("@RecurrenceRule", modelObj.RecurrenceRule);
                cmd.Parameters.AddWithValue("@RecurrenceID", modelObj.RecurrenceID);
                cmd.Parameters.AddWithValue("@RecurrenceException", modelObj.RecurrenceException);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                return("registed successfully");
            }
            catch (MySqlException ex)
            {
                return("exception found");
            }
            finally
            {
                conn.Close();
            }
        }