Example #1
0
        public bool AddProjectNote(ProjectNotes note)
        {
            DatabaseHelper dh            = new DatabaseHelper();
            var            CompletedDate = "0000-00-00";

            try
            {
                dh.RunUpdateQuery($"INSERT INTO ProjectNote (projectId, message, sentDate, [from], [to]) VALUES('{note.ProjectId}', '{note.Message.Replace("'", "''")}', " +
                                  $"'{note.SentDate}', '{note.From}', '{note.To}');");

                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return(false);
            }
        }
Example #2
0
        public ProjectNotes getSelectEditProjectNotes(int projectNoteId)
        {
            ProjectNotes modelList = new ProjectNotes();

            using (SqlConnection connection = new SqlConnection(connString))
                using (SqlCommand command = new SqlCommand("", connection))
                {
                    // Query with vals
                    command.CommandText = "SELECT * FROM ProjectNote WHERE projectNoteId = @projectNoteId;";
                    command.Parameters.AddWithValue("@projectNoteId", projectNoteId);


                    // Open connection
                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    // Multiple rows
                    while (reader.Read())
                    {
                        var model = new ProjectPageViewModel();

                        modelList.ProjectNoteId = Convert.ToInt32(reader["projectNoteId"]);
                        modelList.ProjectId     = Convert.ToInt32(reader["projectId"]);
                        modelList.Message       = reader["message"].ToString();
                        modelList.SentDate      = Convert.ToDateTime(reader["sentDate"]);
                        modelList.From          = reader["from"].ToString();
                        modelList.To            = reader["to"].ToString();

                        if (reader["completedDate"] != DBNull.Value)
                        {
                            modelList.CompletedDate = Convert.ToDateTime(reader["completedDate"]);
                        }
                        else
                        {
                            modelList.CompletedDate = DateTime.MinValue;
                        }
                    }

                    reader.Close();
                    connection.Close();
                }
            return(modelList);
        }
Example #3
0
        public ProjectNotes getProjectNotesDetails(int myNoteID)
        {
            ProjectNotes modelList = new ProjectNotes();

            using (SqlConnection connection = new SqlConnection(connString))
                using (SqlCommand command = new SqlCommand("", connection))
                {
                    try
                    {
                        // Query with vals
                        command.CommandText = "SELECT * FROM ProjectNote WHERE projectNoteId = @projectNoteId;";
                        command.Parameters.AddWithValue("@projectNoteId", myNoteID);


                        // Open connection
                        connection.Open();

                        SqlDataReader reader = command.ExecuteReader();

                        // Multiple rows
                        while (reader.Read())
                        {
                            var model = new ProjectPageViewModel();

                            modelList.ProjectId = model.ProjectNotes.ProjectNoteId = Convert.ToInt32(reader["projectNoteId"]);
                            modelList.Message   = model.ProjectNotes.Message = reader["message"].ToString();
                            modelList.SentDate  = model.ProjectNotes.SentDate = (DateTime)reader["sentDate"];
                            modelList.From      = model.ProjectNotes.From = reader["from"].ToString();
                            modelList.To        = model.ProjectNotes.To = reader["to"].ToString();
                            //modelList.CompletedDate = model.ProjectNotes.CompletedDate = (DateTime)reader["completedDate"];
                        }

                        reader.Close();
                        connection.Close();
                    }
                    catch (Exception e)
                    {
                    }
                }
            return(modelList);
        }
Example #4
0
        public bool updateProjectNotes(int projectNotesId, ProjectNotes projectNotes)
        {
            DatabaseHelper dh = new DatabaseHelper();

            try
            {
                var message        = projectNotes.Message;
                var completionDate = projectNotes.CompletedDate;
                var to             = projectNotes.To;

                ///dh.RunUpdateQuery($"DELETE FROM ProjectNote WHERE projectNoteId='{projectNoteId}'");
                dh.RunUpdateQuery($"UPDATE ProjectNote set message='{message.Replace("'", "''")}', completedDate='{completionDate}', [to]='{to}' WHERE projectNoteId = '{projectNotesId}'");

                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return(false);
            }
        }