📄 knowledgemanage.cs
字号:
{
if(i==0)
{
i++;
return;
}
else
{
// MessageBox.Show(this,e.Node.GetDisplayText(0)+" ; "+e.Node.GetDisplayText(2));
string strtype="";
string strpoint="";
string strnopoint="";
strtype=this.txtktype.Text.Trim();
strpoint=e.Node.GetDisplayText(0)+",";
strnopoint=e.Node.GetDisplayText(2)+",";
if (strtype.IndexOf(strpoint)==-1)
{
this.txtktype.Text+=strpoint;
strnumber+=strnopoint;
}
else
{
strtype=strtype.Replace(strpoint,"");
this.txtktype.Text=strtype;
strnumber=strnumber.Replace(strnopoint,"");
}
}
}
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);
}
}
}
private int isLength()
{
// if(ShareClass.checkoutLength(50,this.txtktitle,"知识标题")==1)
// {
// return 1;
// }
// else if(ShareClass.checkoutLength(100,this.txtkkeywords,"关键字")==1)
// {
// return 1;
// }
return 0;
}
private void btAdd_Click(object sender, System.EventArgs e)
{
try
{
if(isLength()==1)
{
return;
}
else
{
insertData();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void insertData()
{
if(!this.checkValidate())
{
return;
}
KnowledgeInfo kinfo=new KnowledgeInfo();
kinfo=setData("添加");
KnowledgeBLL kbll=new KnowledgeBLL();
// MessageBox.Show(kinfo.kcontent);
if(kbll.addKnowledge(kinfo)>=0)
{
MessageBox.Show(this,"添加成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
// getDataBind();
ClearData();
}
else
{
MessageBox.Show(this,"添加失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private KnowledgeInfo setData(string tag)
{
KnowledgeInfo kinfo=new KnowledgeInfo();
try
{
if(tag=="修改")
{
kinfo.id=knowledgeinfo.id;
}
kinfo.ktitle=this.txtktitle.Text;
kinfo.ktype=","+strnumber;//this.txtktype.Text;
kinfo.kkeywords=this.txtkkeywords.Text;
kinfo.kwid=ShareClass.Operator;
kinfo.kwname=ShareClass.OperatorChinese;
kinfo.kwdate=DateTime.Today.ToString();
if(this.cboamark.Text=="不可访问")
{
kinfo.oamark=0;
}
else
{
kinfo.oamark=1;
}
kinfo.kaid=ShareClass.Operator;
kinfo.kaname=ShareClass.OperatorChinese;
if(tag=="添加")
{
kinfo.oamount=0;//Convert.ToInt32(this.txtoamount.Text);
kinfo.iamount=0;//Convert.ToInt32(this.txtiamount.Text);
kinfo.camount=0;//Convert.ToInt32(this.txtcamount.Text);
}
else if(tag=="修改")
{
kinfo.oamount=Convert.ToInt32(this.txtoamount.Text);
kinfo.iamount=Convert.ToInt32(this.txtiamount.Text);
kinfo.camount=Convert.ToInt32(this.txtcamount.Text);
}
kinfo.kcontent=this.hRichTextBox1.RtfText;//this.txtkcontent.Rtf;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
return kinfo;
}
private void ClearData()
{
this.txtktitle.Text="";
this.txtktype.Text="";
this.txtkkeywords.Text="";
this.txtkwid.Text=ShareClass.Operator;
this.txtkwname.Text=ShareClass.OperatorChinese;
this.txtkwdate.Text=DateTime.Today.Year.ToString()+"-"+DateTime.Today.Month.ToString()+"-"+DateTime.Today.Day.ToString();
this.cboamark.Text="不可访问";
this.txtkaid.Text=ShareClass.Operator;
this.txtkaname.Text=ShareClass.OperatorChinese;
this.txtoamount.Text="0";
this.txtiamount.Text="0";
this.txtcamount.Text="0";
// this.txtkcontent.Text="";
this.hRichTextBox1.Text="";
getEnabled(false);
}
private void getEnabled(bool enabled)
{
if(enabled==true)
{
// this.btSave.Enabled=true;
// this.btDelete.Enabled=true;
this.btReset.Enabled=true;
}
else
{
// this.btSave.Enabled=false;
// this.btDelete.Enabled=false;
this.btReset.Enabled=false;
}
}
private void groupBox1_Enter(object sender, System.EventArgs e)
{
}
private void btClose_Click(object sender, System.EventArgs e)
{
// this.Close();
}
private void btDelete_Click(object sender, System.EventArgs e)
{
try
{
if(MessageBox.Show("确定要删除此条记录吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)==DialogResult.Yes)
{
KnowledgeBLL kbll=new KnowledgeBLL();
kbll.delKnowledgeByIds(knowledgeinfo.id.ToString());
ClearData();
MessageBox.Show("删除成功!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btSave_Click(object sender, System.EventArgs e)
{
try
{
modifyData();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void modifyData()
{
if(!this.checkValidate())
{
return;
}
KnowledgeInfo kinfo=new KnowledgeInfo();
kinfo=setData("修改");
KnowledgeBLL kbll=new KnowledgeBLL();
if(kbll.updateKnowledge(kinfo)<=0)
{
MessageBox.Show("修改失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
else
{
MessageBox.Show("修改成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
ClearData();
}
}
private bool checkValidate()
{
if(""==this.txtktitle.Text.Trim())
{
MessageBox.Show(this,"知识标题不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtktitle.Focus();
return false;
}
if(this.txtktitle.Text.Length>50)
{
MessageBox.Show(this,"知识标题不能多于50个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtktitle.Focus();
return false;
}
if("".Equals(this.txtktype.Text.Trim()))
{
MessageBox.Show(this,"知识类别不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtktype.Focus();
return false;
}
if("".Equals(this.txtkkeywords.Text.Trim()))
{
MessageBox.Show(this,"关键字不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtkkeywords.Focus();
return false;
}
if(this.txtkkeywords.Text.Length>50)
{
MessageBox.Show(this,"关键字不能多于50个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtkkeywords.Focus();
return false;
}
return true;
}
private void btReset_Click(object sender, System.EventArgs e)
{
ClearData();
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -