public IActionResult UpdateNote(Model.Note note) { var username = HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Upn).Value; remarkService.UpdateNote(username, note.Id, GeometryPoint.Create(note.X, note.Y), note.Body); return(Ok()); }
public ActionResult Create(Model.Note note) { ////取得请求参数并封装成一个实体对象 //var note = new Model.Note { // NoteTypeId = Convert.ToInt32(Request["NoteTypeId"]), // Title = Convert.ToString(Request["Title"]), // Content = Convert.ToString(Request["Content"]), // CreateDate = DateTime.Now //}; note.CreateDate = DateTime.Now; int i = this.NoteService.Insert(note); if (i > 0) { //添加成功,重定向到显示页面 return(RedirectToAction("Index", "Home")); } //失败 ViewBag.NoteTypes = this.NoteTypeService.GetAll(); //转发到添加页面 return(View()); }
private string Save(Model.Note model) { string result = ""; if (model == null || model.Title.Length == 0 || model.Content.Length == 0) { result = "标题或内容不能为空!"; return(result); } try { if (model.Id == 0)//新增 { model.CreateDate = DateTime.Now; _bllNote.Add(model); return("添加成功!"); } model.ModifyDate = DateTime.Now; _bllNote.Update(model, " Id=" + model.Id); result = "修改成功!"; } catch (Exception ex) { Log.SaveLog("NoteListModule btnOK_Click", ex.ToString()); result = "系统异常,操作失败!"; } this.cboType.SelectedIndex = 0; return(result); }
public int Insert(Model.Note note) { using (var db = new Model.NoteContext()) { db.Notes.Add(note); return(db.SaveChanges()); } }
internal void OnSaveNoteButtonClick() { if (view.TextBoxComment != string.Empty) { var note = new Model.Note() { note1 = view.TextBoxComment, note_date = DateTime.Now, note_seen = false, student_id = view.SelectedStudentID, subject_id = view.SelectedSubjectID }; data.Notes.Add(note); try { data.SaveChanges(); } catch (Exception) { view.Message("В момента изпитваме технически затруднения. Възможно е вашите промени да не са запазени. Моля, опитайте отново по-късно. Съжаляваме за причененото неудобство.", "Грешка", Views.MessageIcon.Error); return; } view.HideAll(); view.Message("Забележката е добавена.", "Успешен запис", Views.MessageIcon.Information); } else { view.Message("Не можете да добавите празна забележка.", "Грешка", Views.MessageIcon.Error); } }
private void newButton_Click(object sender, EventArgs e) { Model.Note newNote = new Model.Note(); newNote.CreateDateTime = DateTime.Now; //独立标记每一个note this.Tag = newNote; noteList.Add(newNote); refreshMainTextBox(); }
/*成为active状态时*/ private void refreshMainTextBox() { if (this.Tag != null && this.Tag is Model.Note) { Model.Note currentNote = (Model.Note) this.Tag; this.mainTextBox.Text = currentNote.Content; this.mainTextBox.BackColor = currentNote.BackColor; this.mainTextBox.ForeColor = currentNote.ForeColor; this.mainTextBox.Font = currentNote.Font; } this.Text = "记事本(" + (this.noteList.IndexOf(this.Tag) + 1) + "/" + this.noteList.Count + ")"; }
public int Update(Model.Note note) { using (var db = new Model.NoteContext()) { //1.查询出要修改的对象 var noteOld = db.Notes.Find(note.Id); //2.设置新的属性值 noteOld.Title = note.Title; noteOld.Content = note.Content; noteOld.NoteTypeId = note.NoteTypeId; return(db.SaveChanges()); } }
public int Delete(int id) { using (var db = new Model.NoteContext()) { var note = new Model.Note { Id = id }; db.Notes.Attach(note); db.Notes.Remove(note); return(db.SaveChanges()); } }
/* * 取消active状态时; * 暂存note的属性 */ private void saveCurrentNote() { if (this.Tag != null && this.Tag is Model.Note) { Model.Note currentNote = (Model.Note) this.Tag; //此时currentNote指的就是要不active的note currentNote.Content = this.mainTextBox.Text; currentNote.BackColor = this.mainTextBox.BackColor; currentNote.ForeColor = this.mainTextBox.ForeColor; currentNote.Font = this.mainTextBox.Font; currentNote.ModifyDateTime = DateTime.Now; } }
public Result AddNote([FromForm] Model.Note model, [FromForm] List <Model.User> UserList, [FromForm] List <Model.Dep> DepList, [FromForm] List <Model.Com> ComList, [FromForm] List <Model.Position> PositionList) { if (model.Id == 0) { model.CreateDate = DateTime.Now; return(_business.Add(model, UserList, DepList, ComList, PositionList)); } else { model.CreateDate = DateTime.Now; return(_business.Update(model, UserList, DepList, ComList, PositionList)); } }
void writeNewNote(List <String> tags) { RealmConfigurationBase config = new RealmConfiguration("xnotes.1.realm"); Realm realm = Realm.GetInstance(config); Model.Note note = new Model.Note(title, message, tags); note.tagLine = note.createTagLabel(tags); Console.WriteLine($"TAGLINE{note.tagLine}"); realm.Write(() => { realm.Add(note); }); }
/// <summary> /// Deletes a note /// </summary> /// <param name="noteId">The given note id</param> /// <returns>Success status</returns> public bool Delete(int noteId) { using (var dbContext = new AllocationContext(_dbContextOptions)) { Model.Note note = dbContext.Notes.Find(noteId); if (note == null) { return(false); } dbContext.Notes.Remove(note); dbContext.SaveChanges(); return(true); } }
private void loadNoteFromXML() { noteList.Clear(); XmlTextReader textReader = null; try { textReader = new XmlTextReader(Application.StartupPath + "\\Notes.xml"); while (textReader.Read()) { if (textReader.LocalName.Equals("Note") && textReader.NodeType == XmlNodeType.Element) { Model.Note note = new Model.Note(); textReader.Read(); note.Content = textReader.ReadElementString("Content"); textReader.Read(); note.BackColor = Color.FromArgb(Convert.ToInt32(textReader.ReadElementString("BackColor"))); textReader.Read(); note.CreateDateTime = DateTime.Parse(textReader.ReadElementString("CreateDateTime")); textReader.Read(); note.Font = new Font(textReader.ReadElementString("Font"), this.Font.Size, this.Font.Style); textReader.Read(); note.ForeColor = Color.FromArgb(Convert.ToInt32(textReader.ReadElementString("ForeColor"))); textReader.Read(); note.ModifyDateTime = DateTime.Parse(textReader.ReadElementString("ModifyDateTime")); noteList.Add(note); } } } catch (Exception ex) { MessageBox.Show("载入异常:" + ex.Message); } finally { if (textReader != null) { textReader.Close(); } } if (noteList.Count != 0) { this.Tag = noteList[0]; } else { newButton_Click(null, null); } this.refreshMainTextBox(); }
/// <summary> /// Updates an existing note /// </summary> /// <param name="noteId">Id of the existing note</param> /// <param name="newNote">The new note</param> /// <returns>Success status</returns> public bool Update(int noteId, KnownNote newNote) { using (var dbContext = new AllocationContext(_dbContextOptions)) { Model.Note note = dbContext.Notes.Find(noteId); if (note == null) { return(false); } note.Contents = newNote.Contents; note.LastModificationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); dbContext.SaveChanges(); return(true); } }
public ActionResult Edit(Model.Note note) { //查询出要修该的对象 var i = this.NoteService.Update(note); if (i > 0) { return(RedirectToAction("Index", "Home")); } //传递到页面进行显示 ViewBag.NoteTypes = this.NoteTypeService.GetAll(); ViewBag.Note = note; return(View()); }
public static void AddToNote(Model.Note Note) { var allNotes = SQLData.SQLDataContext.Notes; Random rnd = new Random(); Note.Id = rnd.Next(30000); foreach (var note in allNotes) { if (note.Id.Equals(Note.Id)) { Note.Id = rnd.Next(30000); } } SQLData.SQLDataContext.Notes.InsertOnSubmit(Note); SQLData.SQLDataContext.Database.SubmitChanges(); }
/// <summary> /// Gets a note /// </summary> /// <param name="noteId">The given note id</param> /// <returns>The note matching the id</returns> public KnownNote GetNote(int noteId) { using (var dbContext = new AllocationContext(_dbContextOptions)) { Model.Note note = dbContext.Notes.Find(noteId); if (note == null) { return(null); } return(new KnownNote( note.NoteId, note.StaffMemberId, note.Contents, note.CreationTime, note.LastModificationTime)); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { Model.Note model = new Model.Note(); if ((sender as Button).CommandParameter != null) { model.Id = Int64.Parse((sender as Button).CommandParameter.ToString()); } model.Title = this.txtTitle.Text; model.Content = this.txtContent.Text; if (model.Title.Length == 0 || model.Content.Length == 0) { MessageBox.Show("标题或内容不能为空!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } model.ModifyDate = DateTime.Now; model.TypeId = Int64.Parse(this.cboType.SelectedValue.ToString()); string result = Save(model); MessageBox.Show(result); }
private void DisplayNote() { try { Model.Note Note = Controllers.NoteController.GetNote(Date); if (Note != null) { NoteName = Note.Content.Split('$')[0]; NoteContent = Note.Content.Split('$')[1]; } else if (Note == null) { NoteName = null; NoteContent = null; } } catch (Exception exc) { } }
/// <summary> /// Creates a new note /// </summary> /// <param name="newNote">The new note supplied</param> /// <returns>The database identifier key of the newly created note</returns> public int Create(KnownNote newNote) { var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var modelNote = new Model.Note() { StaffMemberId = newNote.StaffId, Contents = newNote.Contents, CreationTime = now, LastModificationTime = now }; using (var dbContext = new AllocationContext(_dbContextOptions)) { if (dbContext.StaffMembers.Find(modelNote.StaffMemberId) != null) { dbContext.Notes.Add(modelNote); dbContext.SaveChanges(); return(modelNote.NoteId); } return(0); } }
private void OkButton() { if (NoteName != null && NoteContent != null) { try { var note = new Model.Note() { Content = NoteName + "$" + noteContent, Date = NoteDate }; Controllers.NoteController.AddToNote(note); OnNoteClosed(true); } catch (Exception exc) { } } else { OnNoteClosed(false); } }
void preformRealmWrite(List <String> tags) { RealmConfigurationBase config = new RealmConfiguration("xnotes.1.realm"); Realm realm = Realm.GetInstance(config); Model.Note note = new Model.Note(title, message, tags); note.tagLine = note.createTagLabel(tags); if (selectedNote == null) { realm.Write(() => { realm.Add(note); }); } else { note.id = selectedNote.id; realm.Write(() => { realm.Add(note, update: true); }); } }
private void 载入文本文件ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "文本文件|*.txt"; if (ofd.ShowDialog() == DialogResult.OK) { // TextReader tr = null; if (this.Tag == null) { this.newButton_Click(null, null); } Model.Note currentNote = (Model.Note) this.Tag; try { //把从ofg.FileName读到的内容先放入StreamReader tr = new StreamReader(ofd.FileName, Encoding.Default); //然后将tr的内容写入当前的活跃的文本框里 currentNote.Content = tr.ReadToEnd(); this.refreshMainTextBox(); } catch (Exception ex) { MessageBox.Show("出现打开异常:" + ex.Message); } finally { if (tr != null) { tr.Close(); } } } }
public void CleanUp() { meinote = null; convertedNote = null; }
public void Init() { meinote = new mei.Note(); convertedNote = new Model.Note(); }
public void Delete(Model.Note N) { _dbContext.Notes.Remove(N); _dbContext.SaveChanges(); MainWindow.titleDict.Remove(N.Title); }
public void AddNote(Model.Note N) { _dbContext.Notes.Add(N); _dbContext.SaveChanges(); }
public void BuildSequence_checkConversion() { foreach (Sequence testSequence in testList) { foreach (ObjectInSequence obj in testSequence.ObjectsInSequence) { Assert.AreNotEqual(obj.Evidence, Evidence.Invalid); switch (obj.Type) { case ObjectType.Accidental: Accidental accid = (Accidental)obj; Assert.AreNotEqual(Model.AccidType.Null, accid.AccidentalType); break; case ObjectType.Barline: Barline bl = (Barline)obj; Assert.AreNotEqual(Model.BarlineType.Null, bl.BarlineType); break; case ObjectType.Clef: Model.Clef clef = (Model.Clef)obj; Assert.AreNotEqual(Model.Clefshape.Null, clef.Shape); break; case ObjectType.KeyAccidental: KeyAccidental keyacc = (KeyAccidental)obj; Assert.AreNotEqual(Model.AccidType.Null, keyacc.AccidentalType); break; case ObjectType.Mensur: Model.Mensur mens = (Model.Mensur)obj; Assert.AreNotEqual(0, mens.Tempus); break; case ObjectType.Note: Model.Note note = (Model.Note)obj; Assert.AreNotEqual(0, note.WrittenPitch); Assert.AreNotEqual(Model.Duration.Null, note.Duration); break; case ObjectType.Proportion: Proportion prop = (Proportion)obj; Assert.AreNotEqual(0, prop.Num); Assert.AreNotEqual(0, prop.Numbase); break; case ObjectType.Rest: Model.Rest rest = (Model.Rest)obj; Assert.AreNotEqual(Model.Duration.Null, rest.Duration); break; case ObjectType.Custos: break; case ObjectType.Dot: break; case ObjectType.Gap: Model.Gap gap = (Model.Gap)obj; Assert.AreNotEqual(Model.GapType.Null, gap.GapType); break; default: Assert.Fail($"Test of {obj.Type} {obj.ID} failed!"); break; } } } }