下午上机
来源:互联网 发布:excel里数据里边单引号 编辑:程序博客网 时间:2024/04/28 03:01
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;namespace 上机_下午{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //string stu = "Data Source=.;Initial Catalog=assetsDB;Integrated Security=True"; private void 新增固定资产ToolStripMenuItem1_Click(object sender, EventArgs e) { Form2 f = new Form2(); f.MdiParent = this; f.Show(); } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void 查询固定资产ToolStripMenuItem_Click(object sender, EventArgs e) { Form3 q = new Form3(); q.MdiParent = this; q.Show(); } }}
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;namespace 上机_下午{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { sr(); } public void sr() { this.comboBox1.SelectedIndex = 0; } MySchool.DBHelper a = new MySchool.DBHelper(); public bool ss() { bool success = false; string assetId = this.textBox1.Text.Trim(); string assetName = this.textBox2.Text.Trim(); string assetType = this.comboBox1.Text.Trim(); string intpDate= this.textBox3.Text.Trim(); try { string sql = string.Format("select * from assets"); a.OpenConnection(); SqlCommand comm = new SqlCommand(sql,a.Connection); StringBuilder sb = new StringBuilder(); sb.AppendLine("insert into assets(assetId,assetName,assetType,intoData)"); sb.AppendFormat("values ('{0}','{1}','{2}','{3}')", assetId, assetName, assetType, intpDate); MessageBox.Show(sb.ToString()); comm = new SqlCommand(sb.ToString(),a.Connection); int result = comm.ExecuteNonQuery(); if (result == 1) { success = true; return success; } } catch (Exception e) { MessageBox.Show(e.Message); } return false; } private void button2_Click(object sender, EventArgs e) { this.textBox1.Text = ""; this.textBox2.Text = ""; this.textBox3.Text = ""; this.comboBox1.Text = ""; } private void button1_Click(object sender, EventArgs e) { ss(); } }}
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;namespace 上机_下午{ public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { st(); sr(); } public void sr() { this.comboBox1.SelectedIndex = 0; } MySchool.DBHelper a= new MySchool.DBHelper(); DataSet ds = new DataSet(); public void st() { try { string sql = "select * from assets"; MessageBox.Show(sql); SqlDataAdapter da = new SqlDataAdapter(sql,a.Connection); da.Fill(ds, "r"); dataGridView1.DataSource = ds.Tables["r"]; } catch (Exception e) { MessageBox.Show(e.Message); } } private void button1_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString().Equals(null)) { MessageBox.Show("没有查询到结果", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { se(); } } public void se() { try { if (ds.Tables["assets"] != null) { ds.Tables["assets"].Clear(); } StringBuilder sb = new StringBuilder(); sb.Append("select * from assets"); sb.AppendFormat(" where assetId='{0}' OR assetType='{1}' ", this.textBox1.Text, this.comboBox1.Text.Trim()); SqlDataAdapter da = new SqlDataAdapter(sb.ToString(), a.Connection); da.Fill(ds, "assets"); dataGridView1.DataSource = ds.Tables["assets"]; } catch (Exception w) { MessageBox.Show(w.Message); } finally { a.CloseConnection(); } } }}
0 0
- 下午上机
- 下午
- 下午
- 2010年12月7日下午北大数据库系统原理上机题
- 2014北邮计算机考研复试上机题解(上午+下午)
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目1(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目2(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目3(9月6日下午1点场) .
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目程序实现(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012届华为校园招聘上机考试题目(9月6日下午1点场)
- 2012 届华为校园招聘上机考试题目(9 月 6 日下午 1 点场)
- 上机
- 上机
- 流程走通!!!
- Spring依赖注入的两种方式
- linux字符设备驱动
- [源码]LeakCanary
- 第14章 线程机制:并发函数的使用
- 下午上机
- UILabel如何根据富文本内容计算高度
- GrassLand密码
- [笔记]MySQL 配置优化
- Window Server2008 防火墙配置
- 使用apache的httpcomponents中的httpclient 4.5对https进行访问
- Netty之HelloWorld
- rcv_msg
- 密码学基本概念(一)