Example #1
0
        private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e)
        {
            isAdding = true;

            Ucl_NoteItem noteitem = null;

            #region 保存到数据库
            if (Cache.GetCache("uid") != null)
            {
                string           id;
                string           title;
                int              types;
                DateTime         addTime;
                bool             isNew;
                DBUtil.Note_Main main = new DBUtil.Note_Main();
                noteitem = e.Control as Ucl_NoteItem;
                if (noteitem != null)
                {
                    id      = noteitem.ID;
                    title   = noteitem.Title;
                    types   = noteitem.Types;
                    addTime = noteitem.AddTime;
                    isNew   = noteitem.IsNew;


                    main.ID       = id;
                    main.AddRenID = Cache.GetCache("uid").ToString();
                    main.State    = types;
                    main.Content  = title;
                    main.AddTime  = addTime.ToString("yyyy-MM-dd HH:mm:ss");

                    if (isNew)
                    {
                        main.Add();
                    }
                }
            }
            #endregion

            AbleFlowLayout();

            if (layoutAdded != null)
            {
                layoutAdded(e.Control.Height);
            }

            isAdding = false;
        }
Example #2
0
 private void InitData()
 {
     if (Process.GetCurrentProcess().ProcessName != "devenv")
     {
         flowLayoutPanel1.ControlRemoved -= flowLayoutPanel1_ControlRemoved;
         flowLayoutPanel1.ControlAdded   -= flowLayoutPanel1_ControlAdded;
         this.flowLayoutPanel1.Controls.Clear();
         DBUtil.Note_Main main = new DBUtil.Note_Main();
         DataSet          ds   = main.GetList("State=0 order by addtime desc");
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
             {
                 Ucl_NoteItem item = new Ucl_NoteItem(ds.Tables[0].Rows[i]["ID"].ToString(), ds.Tables[0].Rows[i]["Content"].ToString(), Convert.ToInt32(ds.Tables[0].Rows[i]["State"]), Convert.ToDateTime(ds.Tables[0].Rows[i]["AddTime"]), false);
                 this.flowLayoutPanel1.Controls.Add(item);
             }
         }
         flowLayoutPanel1.ControlRemoved += flowLayoutPanel1_ControlRemoved;
         flowLayoutPanel1.ControlAdded   += flowLayoutPanel1_ControlAdded;
     }
 }
Example #3
0
        private void flowLayoutPanel1_ControlRemoved(object sender, ControlEventArgs e)
        {
            isRemoving = true;

            #region 保存到数据库
            DBUtil.Note_Main main     = new DBUtil.Note_Main();
            Ucl_NoteItem     noteitem = e.Control as Ucl_NoteItem;
            if (noteitem != null)
            {
                main.GetModel(noteitem.ID);
                if (main.ID == noteitem.ID)
                {
                    main.State = 2;
                    main.Update();
                }
            }
            #endregion

            AbleFlowLayout();

            isRemoving = false;
        }