?? hotspotform.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using CallCenter.BusinessLayer;
using CallCenter.DALFactory;
using CallCenter.IDAL;
using CallCenter.Modules;
using CallCenter.OracleDAL;
using System.Data;
namespace CallCenter.BusinessInterfaces.MainForms
{
/// <summary>
/// HotsPotForm 的摘要說明。
/// </summary>
public class HotsPotForm : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Panel panel1;
private DevExpress.XtraTreeList.TreeList treeList1;
private DevExpress.XtraTreeList.Columns.TreeListColumn colTNAME;
private DevExpress.XtraTreeList.Columns.TreeListColumn colOAMARK;
private DevExpress.XtraTreeList.Columns.TreeListColumn colID;
private DevExpress.XtraTreeList.Columns.TreeListColumn colPARENTID;
private System.Data.DataSet ds;
private System.Data.DataSet dsh;
private KnowledgeTypeBLL bll = new KnowledgeTypeBLL();
private System.Windows.Forms.Splitter splitter1;
private int i=0;
private System.Windows.Forms.DataGrid dgHot;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
/// <summary>
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public HotsPotForm()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.treeList1 = new DevExpress.XtraTreeList.TreeList();
this.dgHot = new System.Windows.Forms.DataGrid();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgHot)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.treeList1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 525);
this.panel1.TabIndex = 0;
//
// treeList1
//
this.treeList1.Appearance.Empty.BackColor = System.Drawing.Color.White;
this.treeList1.Appearance.Empty.Options.UseBackColor = true;
this.treeList1.Appearance.GroupButton.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.treeList1.Appearance.GroupButton.Options.UseBackColor = true;
this.treeList1.Appearance.GroupFooter.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
this.treeList1.Appearance.GroupFooter.Options.UseBackColor = true;
this.treeList1.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(219)), ((System.Byte)(233)), ((System.Byte)(244)));
this.treeList1.Appearance.HeaderPanel.Options.UseBackColor = true;
this.treeList1.Appearance.Row.BackColor = System.Drawing.Color.White;
this.treeList1.Appearance.Row.Options.UseBackColor = true;
this.treeList1.Appearance.TreeLine.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(90)), ((System.Byte)(180)), ((System.Byte)(232)));
this.treeList1.Appearance.TreeLine.Options.UseBackColor = true;
this.treeList1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeList1.Location = new System.Drawing.Point(0, 0);
this.treeList1.Name = "treeList1";
this.treeList1.OptionsMenu.EnableColumnMenu = false;
this.treeList1.Size = new System.Drawing.Size(200, 525);
this.treeList1.TabIndex = 0;
//
// dgHot
//
this.dgHot.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.dgHot.BackColor = System.Drawing.Color.GhostWhite;
this.dgHot.BackgroundColor = System.Drawing.Color.Lavender;
this.dgHot.CaptionBackColor = System.Drawing.Color.FromArgb(((System.Byte)(90)), ((System.Byte)(180)), ((System.Byte)(232)));
this.dgHot.CaptionForeColor = System.Drawing.Color.Black;
this.dgHot.CaptionText = "熱點列表";
this.dgHot.ContextMenu = this.contextMenu1;
this.dgHot.DataMember = "";
this.dgHot.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgHot.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgHot.Location = new System.Drawing.Point(200, 0);
this.dgHot.Name = "dgHot";
this.dgHot.ReadOnly = true;
this.dgHot.Size = new System.Drawing.Size(512, 525);
this.dgHot.TabIndex = 2;
this.dgHot.DoubleClick += new System.EventHandler(this.dgHot_DoubleClick);
this.dgHot.CurrentCellChanged += new System.EventHandler(this.dgHot_CurrentCellChanged);
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "添加到收藏夾";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "查看詳細";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.Color.LightSkyBlue;
this.splitter1.Location = new System.Drawing.Point(200, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 525);
this.splitter1.TabIndex = 3;
this.splitter1.TabStop = false;
//
// HotsPotForm
//
this.AutoScroll = true;
this.Controls.Add(this.splitter1);
this.Controls.Add(this.dgHot);
this.Controls.Add(this.panel1);
this.Name = "HotsPotForm";
this.Size = new System.Drawing.Size(712, 525);
this.Load += new System.EventHandler(this.HotsPotForm_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgHot)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void HotsPotForm_Load(object sender, System.EventArgs e)
{
ds = bll.getKnowledgeType("KNOWLEDGETYPE");
initTreeList();
paintTreeList();
getHot();
}
private void getHot()
{
this.dgHot.CaptionBackColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
this.dgHot.BackgroundColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
KnowledgeBLL kbll=new KnowledgeBLL();
dsh=new DataSet();
dsh=kbll.getHotspotKnowledge_DataSet(30,"hot");
this.dgHot.DataSource=dsh.Tables["hot"].DefaultView;
this.dgHot.TableStyles.Clear();
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = dsh.Tables["hot"].TableName;
ts.GridLineColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
ts.HeaderBackColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
DataGridColumnStyle gs0 = new DataGridTextBoxColumn();
gs0.MappingName = "id";
gs0.HeaderText = "編號";
gs0.ReadOnly=true;
gs0.Width=0;
ts.GridColumnStyles.Add(gs0);
DataGridColumnStyle gs1 = new DataGridTextBoxColumn();
gs1.MappingName = "ktitle";
gs1.HeaderText = "標題";
gs1.ReadOnly=true;
gs1.Width=360;
gs1.Alignment = HorizontalAlignment.Left;
ts.GridColumnStyles.Add(gs1);
DataGridColumnStyle gs2 = new DataGridTextBoxColumn();
gs2.MappingName = "kkeywords";
gs2.HeaderText = "關鍵字";
gs2.ReadOnly=true;
gs2.Width=200;
gs2.Alignment = HorizontalAlignment.Left;
ts.GridColumnStyles.Add(gs2);
this.dgHot.TableStyles.Add(ts);
}
private void initTreeList()
{
this.colTNAME = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colOAMARK = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
this.colPARENTID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
//
// treeList1
//
this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] {
this.colTNAME,
this.colOAMARK,
this.colID,
this.colPARENTID});
this.treeList1.Location = new System.Drawing.Point(16, 48);
this.treeList1.Name = "treeList1";
this.treeList1.Size = new System.Drawing.Size(280, 464);
this.treeList1.TabIndex = 0;
this.treeList1.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(this.treeList1_FocusedNodeChanged);
//
// colTNAME
//
this.colTNAME.Caption = "分類名稱";
this.colTNAME.FieldName = "TNAME";
this.colTNAME.Name = "colTNAME";
this.colTNAME.OptionsColumn.AllowEdit = false;
this.colTNAME.OptionsColumn.FixedWidth = true;
this.colTNAME.VisibleIndex = 0;
this.colTNAME.Width = 160;
//
// colOAMARK
//
this.colOAMARK.FieldName = "OAMARK";
this.colOAMARK.Name = "colOAMARK";
this.colOAMARK.OptionsColumn.AllowEdit = false;
this.colOAMARK.Width = 20;
//
// colID
//
this.colID.Caption = "ID";
this.colID.FieldName = "ID";
this.colID.Name = "colID";
this.colID.OptionsColumn.AllowEdit = false;
//
// colPARENTID
//
this.colPARENTID.Caption = "PARENTID";
this.colPARENTID.FieldName = "PARENTID";
this.colPARENTID.Name = "colPARENTID";
this.colPARENTID.OptionsColumn.AllowEdit = false;
}
private void treeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
{
if(i==0)
{
i++;
}
else
{
// MessageBox.Show(this,e.Node.GetDisplayText(0)+" ; "+e.Node.GetDisplayText(2));
// DataRow[] drp=dsh.Tables["hot"].Select("ktype like '%,"+e.Node.GetDisplayText(2)+",%'");
//
DataSet dsc=new DataSet();
dsc.Tables.Add("child");
DataView dv=new DataView(dsh.Tables["hot"],"ktype like '%,"+e.Node.GetDisplayText(2)+",%'","camount",DataViewRowState.CurrentRows);
this.dgHot.DataSource=dv;//
}
}
private void paintTreeList()
{
TreeListNode node;
string strexp="id="+1;
DataRow[] funrow= ds.Tables[0].Select(strexp,"");
DataRow dr = funrow[0];
node = this.treeList1.AppendNode(new Object[]{dr["TNAME"],dr["OAMARK"],dr["ID"],dr["PARENTID"]},null);
string strsel = "parentid="+dr["ID"];
DataRow[] chdr = ds.Tables[0].Select(strsel);
if(chdr.Length>0)
{
digui(node,chdr);
}
this.treeList1.ExpandAll();
}
private void digui(TreeListNode pnode,DataRow[] chdr)
{
TreeListNode node;
for(int i=0;i<chdr.Length;i++)
{
node = this.treeList1.AppendNode(new Object[]{chdr[i]["TNAME"],chdr[i]["OAMARK"],chdr[i]["ID"],chdr[i]["PARENTID"]},pnode);
string strsel = "parentid="+chdr[i]["ID"];
DataRow[] dgdr = ds.Tables[0].Select(strsel);
if(dgdr.Length>0)
{
digui(node,dgdr);
}
}
}
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
// static void Main()
// {
// Application.Run(new HotsPotForm());
// }
private void menuItem1_Click(object sender, System.EventArgs e)
{
try
{
if(this.dgHot[this.dgHot.CurrentCell.RowNumber,0].ToString()=="")
{
MessageBox.Show(this,"此行數據不存在,請重新輸入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
KnowledgeBLL kbll=new KnowledgeBLL();
int flag;
flag=kbll.addFavorite(ShareClass.Operator,Convert.ToInt32(this.dsh.Tables[0].Rows[this.dgHot.CurrentCell.RowNumber]["id"]));
if(flag>0)
{
MessageBox.Show(this,"添加成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else if(flag==-1)
{
MessageBox.Show(this,"該知識已存在當前操作員的收藏夾中,不可再次添加!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dgHot_CurrentCellChanged(object sender, System.EventArgs e)
{
this.dgHot.Select(this.dgHot.CurrentCell.RowNumber);
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
try
{
if(this.dgHot[this.dgHot.CurrentCell.RowNumber,0].ToString()=="")
{
MessageBox.Show(this,"此行數據不存在,請重新輸入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
KnowledgeBLL kbll=new KnowledgeBLL();
KnowledgeInfo kinfo=new KnowledgeInfo();
kinfo=kbll.getKnowledgeById(Convert.ToInt32(this.dsh.Tables["hot"].Rows[this.dgHot.CurrentCell.RowNumber]["id"]));
// KnowledgeManage_Dialog km=new KnowledgeManage_Dialog(kinfo);
CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm km = new CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm(kinfo);
km.ShowDialog();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dgHot_DoubleClick(object sender, System.EventArgs e)
{
try
{
if(this.dgHot[this.dgHot.CurrentCell.RowNumber,0].ToString()=="")
{
MessageBox.Show(this,"此行數據不存在,請重新輸入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
KnowledgeBLL kbll=new KnowledgeBLL();
KnowledgeInfo kinfo=new KnowledgeInfo();
kinfo=kbll.getKnowledgeById(Convert.ToInt32(this.dgHot[this.dgHot.CurrentCell.RowNumber,0]));
// KnowledgeManage_Dialog km=new KnowledgeManage_Dialog(kinfo);
CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm km = new CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm(kinfo);
km.ShowDialog();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -