Example #1
0
        /// <summary>
        /// 新增便签
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmNode_Click(object sender, EventArgs e)
        {
            KHNode node = null;

            try
            {
                IKHNodeService service = new KHNodeService();
                var            lst     = service.GetList();
                if (lst.Count >= 10)
                {
                    MessageBox.Show("最多只能建10个");
                }

                node            = new KHNode();
                node.FontName   = "微软雅黑";
                node.Bold       = 0;
                node.FontSize   = 12;
                node.FontColor  = "white";
                node.Content    = "";
                node.Enabled    = 1;
                node.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                node.UpdateDate = node.CreateDate;
                node.ID         = service.Add(node);
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
            frmNode frmNode = new frmNode(node);

            frmNode.Show();
        }
Example #2
0
 /// <summary>
 /// 删除便签
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tmsDel_Click(object sender, EventArgs e)
 {
     try
     {
         new KHNodeService().Delete(this._KHNode.ID);
     }
     catch (Exception ex)
     {
         CommonMethod.WriteLogErr(ex.Message);
     }
     this.Close();
 }
Example #3
0
 /// <summary>
 /// 字体选中
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MenuItem0_Click(object sender, EventArgs e)
 {
     try
     {
         string sel = (sender as ToolStripMenuItem).Tag.ToString();
         if (this._KHNode.FontName != sel)
         {
             this._KHNode.FontName   = sel;
             this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             new KHNodeService().Update(this._KHNode);
             //改变选中对象
             ToolStripMenuItem item = null;
             for (int i = 0; i < this.tsmName.DropDownItems.Count; i++)
             {
                 item = this.tsmName.DropDownItems[i] as ToolStripMenuItem;
                 if (item.Name == "FontNameMenuItem" + sel)
                 {
                     item.Checked    = true;
                     item.CheckState = System.Windows.Forms.CheckState.Checked;
                 }
                 else
                 {
                     item.Checked    = false;
                     item.CheckState = System.Windows.Forms.CheckState.Unchecked;
                 }
             }
             //设置字体
             DuiTextBox txtBox = this.lblContent.DUIControls[0] as DuiTextBox;
             if (txtBox != null)
             {
                 FontStyle fontStyle = FontStyle.Italic;
                 if (this._KHNode.Bold == 1)
                 {
                     fontStyle = FontStyle.Bold;
                 }
                 txtBox.Font = new System.Drawing.Font(this._KHNode.FontName, 18F, fontStyle, GraphicsUnit.Point);
             }
         }
     }
     catch (Exception ex)
     {
         CommonMethod.WriteLogErr(ex.Message);
     }
 }
Example #4
0
 private void TxtBox_FocusedChanged(object sender, EventArgs e)
 {
     try
     {
         string txt = (sender as DuiTextBox).Text;
         if (!this._KHNode.Content.Equals(txt))
         {
             this._KHNode.Width      = this.Size.Width;
             this._KHNode.Height     = this.Size.Height;
             this._KHNode.LocationX  = this.Location.X;
             this._KHNode.LocationY  = this.Location.Y;
             this._KHNode.Content    = txt;
             this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             new KHNodeService().Update(this._KHNode);
         }
     }
     catch (Exception ex)
     {
         CommonMethod.WriteLogErr(ex.Message);
     }
 }
Example #5
0
        /// <summary>
        /// 加载便签
        /// </summary>
        public void LoadNodeList()
        {
            try
            {
                List <KHNode> lst = new KHNodeService().GetList();
                foreach (KHNode node in lst)
                {
                    if (string.IsNullOrEmpty(node.Content))
                    {
                        continue;
                    }

                    frmNode fmNode = new frmNode(node);
                    fmNode.Show();
                }
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
        }
Example #6
0
        /// <summary>
        /// 颜色选中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem3_Click(object sender, EventArgs e)
        {
            try
            {
                string sel = (sender as ToolStripMenuItem).Tag.ToString();
                if (sel != this._KHNode.FontColor)
                {
                    this._KHNode.FontColor  = sel;
                    this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    new KHNodeService().Update(this._KHNode);
                    //改变选中对象
                    ToolStripMenuItem item = null;
                    for (int i = 0; i < this.tmsColor.DropDownItems.Count; i++)
                    {
                        item = this.tmsColor.DropDownItems[i] as ToolStripMenuItem;
                        if (item.Name == "FontColorMenuItem" + sel)
                        {
                            item.Checked    = true;
                            item.CheckState = System.Windows.Forms.CheckState.Checked;
                        }
                        else
                        {
                            item.Checked    = false;
                            item.CheckState = System.Windows.Forms.CheckState.Unchecked;
                        }
                    }

                    //设置
                    DuiTextBox txtBox = this.lblContent.DUIControls[0] as DuiTextBox;
                    if (txtBox != null)
                    {
                        txtBox.ForeColor = Color.FromName(sel);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
        }
Example #7
0
        public SQLiteConnection GetSQLiteConnection()
        {
            SQLiteConnection mySQLiteConnection = new SQLiteConnection();

            try
            {
                string file = AppDomain.CurrentDomain.BaseDirectory + "khope.db";
                if (!Directory.Exists(file.Substring(0, file.LastIndexOf("\\"))))
                {
                    Directory.CreateDirectory(file.Substring(0, file.LastIndexOf("\\")));
                }
                if (!File.Exists(file)) //判断数据库文件是否存在
                {
                    SQLiteConnection.CreateFile(file);
                }

                mySQLiteConnection = new SQLiteConnection("Data Source = " + file + ";Pooling=true;FailIfMissing=false;Version=3;");
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
            return(mySQLiteConnection);
        }
Example #8
0
        /// <summary>
        /// 创建表
        /// </summary>
        public void Create()
        {
            SQLiteHelper     sqliteHelper = new SQLiteHelper();
            SQLiteConnection conn         = sqliteHelper.GetSQLiteConnection();

            try
            {
                conn.Open();
                bool          isExists = false;
                StringBuilder sbSql    = new StringBuilder();

                #region kh_user

                isExists = TableExists(sqliteHelper, conn, "kh_user");
                if (!isExists)
                {
                    sbSql.Append("create table kh_user([id] integer not null,[user_id] nvarchar(50),[user_name] nvarchar(50),[pass_word] nvarchar(50),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region kh_node

                isExists = TableExists(sqliteHelper, conn, "kh_node");
                if (!isExists)
                {
                    sbSql.Append("create table kh_node([id] integer not null,[width] int,[height] int,[location_x] int,[location_y] int,[font_name] nvarchar(50),[bold] int,[font_size] int,[font_color] nvarchar(50),[content] nvarchar(500),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region kh_param

                isExists = TableExists(sqliteHelper, conn, "kh_param");
                if (!isExists)
                {
                    sbSql.Append("create table kh_param([id] integer not null,[name] nvarchar(50),[value] nvarchar(200),[description] nvarchar(200),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region 事务提交脚本
                if (sbSql.Length > 0)
                {
                    SQLiteTransaction transaction = null;
                    try
                    {
                        transaction = conn.BeginTransaction();
                        sqliteHelper.ExecuteSql(conn, sbSql.ToString());
                        transaction.Commit(); //提交
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        CommonMethod.WriteLogErr(ex.Message);
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Dispose();
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Example #9
0
 /// <summary>
 /// 非UI线程异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     CommonMethod.WriteLogErr(e.Exception.Message + "\r\n" + e.Exception.StackTrace);
 }
Example #10
0
 /// <summary>
 /// UI线程异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     CommonMethod.WriteLogErr(e.ExceptionObject.ToString());
 }