欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年C#实验报告 .pdf

    • 资源ID:34244568       资源大小:1,012.57KB        全文页数:29页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年C#实验报告 .pdf

    C#实验报告(人事管理系统)学号149074353 姓名程裕博班级物 141 指导教师夏敏安徽工业大学计算机学院2016 年 12 月名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 29 页 - - - - - - - - - 一程序步骤先设置一个登录界面(连接数据库),登录时进行判断,根据不同的错误信息进行报错,如密码错误。 登陆成功后, 进入主界面。 主界面通过树和表格来显示数据。可以对人员, 班组,部门进行增删改查操作,数据保存在数据库中。二程序源码1.数据库表结构名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 29 页 - - - - - - - - - 2、登录界面using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using CCWin; using System.Data.SqlClient; namespace 实验_人事管理系统 publicpartialclassForm_login : CCSkinMain public Form_login() InitializeComponent(); string src = 博博实验人事管理系统实验人事管理系统MyData.mdf;Integrated Security=True; privatevoid Form1_Load( object sender, EventArgs e) privatevoid button_login_Click(object sender, EventArgs e) string user = this .skinTextBox.Text; string password = this .skinTextBox2.Text; int sign1 = 0; int sign2 = 0; if (user = | password = ) MessageBox .Show( 您输入的数据不完整! ); else string sql1 = string.Format( select USERNAME from Table_login where USERNAME=N0;, user); using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql1, coon); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 29 页 - - - - - - - - - coon.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() sign1+; if (sign1 = 0) MessageBox .Show( 未查询到您的用户信息!); if (sign1 != 0) string sql2 = string.Format( select PASSWORD from Table_login where USERNAME=N0;, user); using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql2, coon); coon.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() if (password = drPASSWORD.ToString() sign2+; if (sign1 != 0 & sign2 = 0) MessageBox .Show( 您的密码输入错误! ); if (sign2 != 0) Form_show f1 = newForm_show (user, this ); f1.Show(); this .Visible = false ; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 29 页 - - - - - - - - - 3、主界面using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Timers; using System.Data.SqlClient; using CCWin; namespace 实验_人事管理系统 publicpartialclassForm_show : Form public Form_show() InitializeComponent(); public Form_show( string name1, Form_login f) login_name=name1; fl = f; InitializeComponent(); string login_name= xx ; Form_login fl =null ; TreeNode t = newTreeNode(); int ID=-1; public List list = new List (); string name; string birth; string sex; string education; string adminisitrator; string manegetime; / string category_name;string src = 博博实验人事管理系统实验人事管理系统MyData.mdf;Integrated Security=True; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 29 页 - - - - - - - - - privatevoid Form_show_Load(object sender, EventArgs e) toolStripStatusLabel_name.Text = 管理员: + this .login_name; toolStripStatusLabel_time.Text = 登录时间: + DateTime.Now.ToLongTimeString(); Addparent(); this .dataGridView1.ClearSelection(); privatevoid toolStripStatusLabel_name_Click(object sender, EventArgs e) privatevoid Form_show_FormClosed(object sender, FormClosedEventArgs e) fl.Close(); publicvoid Addparent() string sql = select * from Table_tree where PR_NUMBER=-1; using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, coon); coon.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() string name = drNAME .ToString(); string number = drNUMBER .ToString(); / string category=drCATEGORY.ToString();TreeNode tn = newTreeNode(); tn.Text = name; tn.Tag = number; tn.ImageIndex = 1; AddChild(number, tn); treeView_jiegou.Nodes.Add(tn); / skinTreeView1.Nodes.Add(tn); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 29 页 - - - - - - - - - privatevoid AddChild( string pnumber, TreeNode pnode) if ( Convert .ToInt32(pnode.Tag) = 0 | (pnode.Parent!=null & Convert .ToInt32(pnode.Parent.Tag) = 0) stringsql = select * from Table_tree where PR_NUMBER= + pnumber + order by NAME desc; ; using ( SqlConnection conn = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, conn); conn.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() string name = drNAME .ToString(); string number = drNUMBER .ToString(); / string category = drCATEGORY.ToString();TreeNode tn = newTreeNode(); tn.Text = name; tn.Tag = number; tn.ImageIndex = 1; AddChild(number, tn); pnode.Nodes.Add(tn); else stringsql = select * from Table_tree where PR_NUMBER= + pnumber + order by NAME desc; ; using ( SqlConnection conn = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, conn); conn.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() string name = drNAME .ToString(); string number = drNUMBER .ToString(); / string category = drCATEGORY.ToString();名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 29 页 - - - - - - - - - TreeNode tn = newTreeNode(); tn.Text = name; tn.Tag = number; tn.ImageIndex = 0; AddChild(number, tn); pnode.Nodes.Add(tn); privatevoid skinButton_add_Click(object sender, EventArgs e) / 无用的按钮 privatevoid skinButton_add_Click_1(object sender, EventArgs e) /MessageBox.Show( 添加! );if (t.Parent.Parent!=null & t.Parent!=null ) Form_Addperson fp = newForm_Addperson(t, toolStripStatusLabel_name.Text, DateTime.Now.ToString(); fp.Owner = this ; fp.Show(); list.Clear(); elseMessageBox .Show( 请到班组添加人员! ); / reshow(); privatevoid treeView_jiegou_AfterSelect(object sender, TreeViewEventArgs e) string sql = select * from Table_person where CATEGORY_NUMBER= + e.Node.Tag; List list = newList (); using ( SqlConnection conn = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, conn); conn.Open(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 29 页 - - - - - - - - - using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() person p = newperson (); p.Person_name = drPERSON_NAME.ToString(); p.Category_name = drCATEGORY_NAME.ToString(); p.Sex = drSEX.ToString(); string dt=drBIRTH.ToString().Split( ); p.Birth = dt0; p.Education = drEDUCATION .ToString(); p.Adminisitrator = drADMINISITRATOR .ToString(); p.Manegetime=drMANEGETIME.ToString(); list.Add(p); this .dataGridView1.ClearSelection(); this .dataGridView1.DataSource = list; ID = -1; privatevoid添加部门 ToolStripMenuItem_Click(object sender, EventArgs e) if (t.Parent = null | t.Parent.Parent = null ) Form_Add fa = newForm_Add (t); fa.Owner = this ; fa.Show(); else Form_Addperson fp = newForm_Addperson(t, toolStripStatusLabel_name.Text, DateTime.Now.ToString(); fp.Owner = this ; fp.Show(); list.Clear(); this .dataGridView1.DataSource = list; privatevoid treeView_jiegou_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 29 页 - - - - - - - - - this .t = e.Node; / MessageBox.Show(t.Name); publicvoid reshow() treeView_jiegou.Nodes.Clear(); Addparent(); privatevoid dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) /string name;/string birth;/string education;/string adminisitrator;/string manegetime; if (e.RowIndex != -1) name = this .dataGridView1.Rowse.RowIndex.Cells0.Value.ToString(); birth = this .dataGridView1.Rowse.RowIndex.Cells2.Value.ToString(); education = this .dataGridView1.Rowse.RowIndex.Cells4.Value.ToString(); adminisitrator = this .dataGridView1.Rowse.RowIndex.Cells5.Value.ToString(); manegetime = this .dataGridView1.Rowse.RowIndex.Cells6.Value.ToString(); sex = this .dataGridView1.Rowse.RowIndex.Cells3.Value.ToString(); /MessageBox.Show(name+birth+education+adminisitrator+manegetime+sex);string sql = string.Format( select ID from Table_person where PERSON_NAME=N0 and BIRTH=N1 and ADMINISITRATOR=N2 and MANEGETIME=N3, name, birth, adminisitrator, manegetime); / MessageBox.Show(sql);using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, coon); coon.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() ID = (int )dr ID ; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 29 页 - - - - - - - - - privatevoid skinButton_delete_Click(object sender, EventArgs e) if (ID != -1) string sql = delete from Table_person where ID=+ID.ToString()+; ; using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql,coon); coon.Open(); int n=cmd.ExecuteNonQuery(); if (n=1) MessageBox .Show( 删除成功! ); reshowview(); reshow(); /foreach (person p in list)/ if (p.Adminisitrator = adminisitrator & p.Birth = birth & p.Person_name = name & p.Manegetime = manegetime)/ / list.Remove(p);/ /this.dataGridView1.DataSource = list; else MessageBox .Show( 未选定行! ); privatevoid skinButton_rewrite_Click(object sender, EventArgs e) if (ID != -1) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 29 页 - - - - - - - - - Form_rewrite fr = new Form_rewrite (name, sex, birth, education, toolStripStatusLabel_name.Text, manegetime, ID); fr.Owner = this ; fr.Show(); elseMessageBox .Show( 未选定行! ); /list.Clear();/ this.dataGridView1.DataSource=list; privatevoid skinButton1_search_Click(object sender, EventArgs e) string sql = select * from Table_person where 1=1; List list1 = newList (); / list1.Clear();if ( this .textBox1.Text.Trim() != ) sql = sql + and PERSON_NAME like N%+ this .textBox1.Text.Trim()+ % ; if ( this .textBox2.Text.Trim() != ) sql = sql + and CATEGORY_NAME like N% + this .textBox2.Text.Trim()+ % ; sql += ; ; using ( SqlConnection conn = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql, conn); conn.Open(); using ( SqlDataReader dr = cmd.ExecuteReader() while (dr.Read() person p = newperson (); p.Person_name = drPERSON_NAME.ToString(); p.Category_name = drCATEGORY_NAME.ToString(); p.Sex = drSEX.ToString(); string dt = drBIRTH.ToString().Split( ); p.Birth = dt0; p.Education = drEDUCATION .ToString(); p.Adminisitrator = drADMINISITRATOR .ToString(); p.Manegetime = drMANEGETIME.ToString(); list1.Add(p); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 29 页 - - - - - - - - - this .dataGridView1.ClearSelection(); this .dataGridView1.DataSource = list1; privatevoid skinButton_reset_Click(object sender, EventArgs e) this .textBox1.Text = ; this .textBox2.Text = ; List list1 = newList (); this .dataGridView1.DataSource = list1; publicvoid reshowview() List list1 = newList (); list1.Clear(); this .dataGridView1.DataSource = list1; privatevoid删除部门 ToolStripMenuItem_Click(object sender, EventArgs e) Form_delete fm_delete = new Form_delete (t); fm_delete.Owner = this ; fm_delete.Show(); privatevoid修改单位 ToolStripMenuItem_Click(object sender, EventArgs e) Form_rename rename = newForm_rename (t, t.Text.ToString(); rename.Owner = this ; rename.Show(); 4、人员类using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 29 页 - - - - - - - - - namespace 实验_人事管理系统 publicclassperson privatestring person_name; publicstring Person_name get return person_name; set person_name = value ; privatestring category_name; publicstring Category_name get return category_name; set category_name = value ; privatestring birth; publicstring Birth get return birth; set birth = value ; privatestring sex; publicstring Sex get return sex; set sex = value ; privatestring education; publicstring Education get return education; set education = value ; privatestring adminisitrator; publicstring Adminisitrator get return adminisitrator; set adminisitrator = value ; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 29 页 - - - - - - - - - privatestring manegetime; publicstring Manegetime get return manegetime; set manegetime = value ; 5、删除界面using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.SqlClient; using CCWin; namespace 实验_人事管理系统 publicpartialclassForm_delete : CCSkinMain public Form_delete() InitializeComponent(); public Form_delete(TreeNode node) InitializeComponent(); this .t = node; TreeNode t = newTreeNode(); string src = 博博实验人事管理系统实验人事管理系统MyData.mdf;Integrated Security=True; privatevoid Form_delete_Load( object sender, EventArgs e) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 15 页,共 29 页 - - - - - - - - - privatevoid skinButton_sure_Click(object sender, EventArgs e) if (t != null & t.Parent != null ) if (t.Parent.Tag.ToString() = 0 ) / /ox.Show(t.Tag.ToString()+:+t.Text);string sql1 = delete from Table_person where CATEGORY_NUMBER in(select NUMBER from Table_tree where PR_NUMBER in(select NUMBER from Table_tree where NAME=N+ t.Text + ); / MessageBox.Show(sql1);using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql1, coon); coon.Open(); int n = cmd.ExecuteNonQuery(); / MessageBox.Show(您已经删除了 + n.ToString() + 条数据! ); string sql2 = delete from Table_tree where PR_NUMBER in(select NUMBER from Table_tree where NAME=N + t.Text + ); / MessageBox.Show(sql2);using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql2, coon); coon.Open(); int n = cmd.ExecuteNonQuery(); / MessageBox.Show(您已经删除了 + n.ToString() + 条数据! ); string sql3 = delete from Table_tree where NAME=N + t.Text + ; / MessageBox.Show(sql3);using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql3, coon); coon.Open(); int n = cmd.ExecuteNonQuery(); / MessageBox.Show(您已经删除了 + n.ToString() + 条数据! ); else string sql4 = delete from Table_person where CATEGORY_NUMBER = + t.Tag + ; ; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 16 页,共 29 页 - - - - - - - - - string sql5 = delete from Table_tree where NUMBER = + t.Tag + ; ; / MessageBox.Show(sql4);using ( SqlConnection coon = newSqlConnection (src) SqlCommand cmd = newSqlCommand (sql4, coon); coon.Open(); int n = cmd.ExecuteNonQuery(); / MessageBox.Show(您已经删除了 + n.ToString() + 条数据! );SqlCommand cmd1 = new SqlCommand (sql5, coon); int n1 = cmd1.ExecuteNonQuery(); / MessageBox.Show(您已经删除了 + n.ToString() + 条数据! ); Form_show ff = newForm_show (); ff = (Form_show ) this .Owner; ff.reshow(); this .Close(); privatevoid skinButton_giveup_Click(object sender, EventArgs e) this .Close(); 5、添加界面(部门,班组)using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using Sys

    注意事项

    本文(2022年C#实验报告 .pdf)为本站会员(Che****ry)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开