Пример #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);
        }
Пример #2
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);
        }