Exemple #1
0
        private static List <Notes> SqlGetNotesByDate(DateTime start, DateTime end, int accountid)
        {
            List <Notes> notesList = new List <Notes>();
            SqlCommand   cmd       = new SqlCommand();

            cmd.Parameters.Add(Params.Start, SqlDbType.DateTime).Value = start;
            cmd.Parameters.Add(Params.End, SqlDbType.DateTime).Value   = end;
            cmd.Parameters.Add(Params.AccountID, SqlDbType.Int).Value  = accountid;

            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetNotesByDate", cmd))
            {
                while (sdr.Read())
                {
                    Notes notes = new Notes();
                    notes.PKID    = Convert.ToInt32(sdr[Params.DBPKID]);
                    notes.Content = sdr[Params.DBContent].ToString();
                    notes.End     = Convert.ToDateTime(sdr[Params.DBEnd]);
                    notes.Start   = Convert.ToDateTime(sdr[Params.DBStart]);
                    notes.Owner   =
                        BllInstance.AccountBllInstance.GetAccountById(Convert.ToInt32(sdr[Params.DBAccountID]));
                    notes.RepeatType = RepeatUtility.GetRepeatType(Convert.ToInt32(sdr[Params.DBType])).SqlGetByID(sdr);
                    notes.IsMine     = notes.Owner.Id == accountid;
                    notes.FindMine   = accountid == Utility.LoginUser.Id;
                    notesList.Add(notes);
                }
            }
            return(notesList);
        }
Exemple #2
0
        private void SqlUpdate()
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(Params.PKID, SqlDbType.Int).Value = PKID;
            cmd.Parameters.Add(Params.Content, SqlDbType.NVarChar, 2000).Value = Content;
            cmd.Parameters.Add(Params.Type, SqlDbType.Int).Value       = RepeatUtility.GetTypeIndex(RepeatType);
            cmd.Parameters.Add(Params.Start, SqlDbType.DateTime).Value = Start;
            cmd.Parameters.Add(Params.End, SqlDbType.DateTime).Value   = End;
            RepeatType.SqlUpdate(cmd);
            SqlHelper.ExecuteNonQuery("NotesUpdate", cmd);
        }
Exemple #3
0
        private void SqlSave()
        {
            int        pkid;
            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(Params.PKID, SqlDbType.Int).Direction           = ParameterDirection.Output;
            cmd.Parameters.Add(Params.Content, SqlDbType.NVarChar, 2000).Value = Content;
            cmd.Parameters.Add(Params.Type, SqlDbType.Int).Value       = RepeatUtility.GetTypeIndex(RepeatType);
            cmd.Parameters.Add(Params.Start, SqlDbType.DateTime).Value = Start;
            cmd.Parameters.Add(Params.End, SqlDbType.DateTime).Value   = End;
            cmd.Parameters.Add(Params.AccountID, SqlDbType.Int).Value  = Owner.Id;
            RepeatType.SqlSave(cmd);
            SqlHelper.ExecuteNonQueryReturnPKID("NotesInsert", cmd, out pkid);
            _PKID = pkid;
            if (ShareSet != null)
            {
                ShareSet.NoteID = pkid;
            }
        }
Exemple #4
0
        private static Notes SqlGetByID(int pkid)
        {
            Notes      notes = null;
            SqlCommand cmd   = new SqlCommand();

            cmd.Parameters.Add(Params.PKID, SqlDbType.Int).Value = pkid;

            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetNoteByID", cmd))
            {
                while (sdr.Read())
                {
                    notes          = new Notes();
                    notes.ShareSet = Share.GetShare(pkid);
                    notes.PKID     = pkid;
                    notes.Content  = sdr[Params.DBContent].ToString();
                    notes.End      = Convert.ToDateTime(sdr[Params.DBEnd]);
                    notes.Start    = Convert.ToDateTime(sdr[Params.DBStart]);
                    notes.Owner    =
                        BllInstance.AccountBllInstance.GetAccountById(Convert.ToInt32(sdr[Params.DBAccountID]));
                    notes.RepeatType = RepeatUtility.GetRepeatType(Convert.ToInt32(sdr[Params.DBType])).SqlGetByID(sdr);
                }
            }
            return(notes);
        }