Exemple #1
0
        private void TSMI_Save_Click(object sender, EventArgs e)
        {
            var sql = this.RichText.Text;

            if (string.IsNullOrEmpty(sql))
            {
                return;
            }

            var nameinput = new SubForm.InputStringDlg("备注");

            if (nameinput.ShowDialog() == DialogResult.OK)
            {
                if (LJC.FrameWorkV3.Data.EntityDataBase.BigEntityTableEngine.LocalEngine.Insert <SqlSaveEntity>("SqlSave", new SqlSaveEntity
                {
                    Desc = nameinput.InputString,
                    MDate = DateTime.Now,
                    Sql = sql
                }))
                {
                    MessageBox.Show("保存成功");
                }
                else
                {
                    MessageBox.Show("保存失败");
                }
            }
        }
Exemple #2
0
        private void ContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Text == "复制")
            {
                var cells = GVLog.SelectedCells;
                if (cells.Count > 0)
                {
                    List <string> list = new List <string>();
                    foreach (DataGridViewCell cell in cells)
                    {
                        list.Add(cell.Value?.ToString());
                    }
                    Clipboard.SetText(string.Join("\t", list));
                }
            }
            else if (e.ClickedItem.Text == "备注")
            {
                var rows = GVLog.SelectedRows;
                if (rows.Count > 0)
                {
                    SubForm.InputStringDlg dlg = new SubForm.InputStringDlg("备注");

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        var id     = (int)rows[0].Cells["编号"].Value;
                        var entity = LJC.FrameWorkV3.Data.EntityDataBase.BigEntityTableEngine.LocalEngine.Find <Entity.SqlSaveEntity>("SqlSave", id);
                        if (entity != null)
                        {
                            entity.Desc = dlg.InputString;
                            LJC.FrameWorkV3.Data.EntityDataBase.BigEntityTableEngine.LocalEngine.Update <Entity.SqlSaveEntity>("SqlSave", entity);
                            BindData();
                        }
                    }
                }
            }
            else if (e.ClickedItem.Text == "自动换行")
            {
                if (this.GVLog.Columns.Count > 0)
                {
                    if (e.ClickedItem.Tag == null)
                    {
                        e.ClickedItem.Tag = 1;

                        this.GVLog.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;
                        //this.GVLog.Columns[GVLog.Columns.Count - 1].CellTemplate.Style.WrapMode = DataGridViewTriState.True;
                        e.ClickedItem.Image = Resources.Resource1.bullet_tick;
                    }
                    else
                    {
                        e.ClickedItem.Tag = null;

                        this.GVLog.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.False;
                        //this.GVLog.Columns[GVLog.Columns.Count - 1].CellTemplate.Style.WrapMode = DataGridViewTriState.False;
                        e.ClickedItem.Image = null;
                    }
                }
            }
        }
Exemple #3
0
 public void Export()
 {
     foreach (var ctl in tabControl1.SelectedTab.Controls)
     {
         if (ctl is DataGridView)
         {
             var gv  = (DataGridView)ctl;
             var dir = Application.StartupPath + "\\temp\\";
             if (gv.DataSource != null && gv.DataSource is DataTable)
             {
                 if (!Directory.Exists(dir))
                 {
                     Directory.CreateDirectory(dir);
                 }
                 SubForm.InputStringDlg dlg = new SubForm.InputStringDlg("导出文件名");
                 if (dlg.ShowDialog() == DialogResult.OK)
                 {
                     using (StreamWriter fs = new StreamWriter($"{dir}\\{dlg.InputString}.csv", false, Encoding.UTF8))
                     {
                         var table = (DataTable)gv.DataSource;
                         if (table != null)
                         {
                             var str = table.ToCsv();
                             if (!string.IsNullOrWhiteSpace(str))
                             {
                                 fs.Write(str);
                             }
                         }
                     }
                     System.Diagnostics.Process.Start("explorer.exe", dir);
                 }
                 break;
             }
         }
     }
 }