📄 favoriteform.cs
字号:
KnowledgeBLL kbll=new KnowledgeBLL();
dsf=new DataSet();
dsf=kbll.getFavoriteByCId_DataSet(ShareClass.Operator,"favor");
this.dgFavor.DataSource=dsf.Tables["favor"].DefaultView;
this.dgFavor.TableStyles.Clear();
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = dsf.Tables["favor"].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;
gs0.Alignment=HorizontalAlignment.Left;
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.dgFavor.TableStyles.Add(ts);
//如果指定了DataGridTableStyle,则gridDataFilter1会加载它的标题
this.gridDataFilter1.DataGridTableStyle = this.dgFavor.TableStyles[0];
if (this.dgFavor.DataSource != null)
{
this.gridDataFilter1.Enabled = true;
}
else
{
this.gridDataFilter1.Enabled = false;
}
this.gridDataFilter1.DataSource=this.dgFavor.DataSource;
this.gridDataFilter1.Begin();
}
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
{
node=e.Node.GetDisplayText(2);
DataView dv=new DataView(dsf.Tables["favor"],"ktype like '%,"+e.Node.GetDisplayText(2)+",%'","camount",DataViewRowState.CurrentRows);
this.dgFavor.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 FavoriteForm());
// }
private void menuItem1_Click(object sender, System.EventArgs e)
{
try
{
if(this.dgFavor[this.dgFavor.CurrentCell.RowNumber,0].ToString()=="")
{
MessageBox.Show(this,"此行数据不存在,请重新选择!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
KnowledgeBLL kbll=new KnowledgeBLL();
kbll.delFavorite(ShareClass.Operator,Convert.ToInt32(this.dgFavor[this.dgFavor.CurrentCell.RowNumber,0]));
dsf=new DataSet();
dsf=kbll.getFavoriteByCId_DataSet(ShareClass.Operator,"favor");
if(i==1)
{
this.dgFavor.DataSource=dsf.Tables["favor"].DefaultView;
}
else
{
DataView dv=new DataView(dsf.Tables["favor"],"ktype like '%,"+node+",%'","camount",DataViewRowState.CurrentRows);
this.dgFavor.DataSource=dv;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
try
{
if(this.dgFavor[this.dgFavor.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.dgFavor[this.dgFavor.CurrentCell.RowNumber,0]));
// KnowledgeManage_Dialog km=new KnowledgeManage_Dialog(kinfo);
CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm km = new CallCenter.BusinessInterfaces.BaseForms.KnowledgeDetailForm(kinfo);
km.ShowDialog();
// km.ShowDialog();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -