BookSubscribe.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:40k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace 图书馆管理系统
- {
- /// <summary>
- /// BookSubscribe 的摘要说明。
- /// </summary>
- public class BookSubscribe : System.Windows.Forms.Form
- {
- private CurrencyManager cmOrders;
- public static string bookID,bookName;//保存选择而来的书名和编号
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button btnSearch;
- private System.Windows.Forms.TextBox txt1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox txt2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.TextBox txt3;
- private System.Windows.Forms.ImageList imageList1;
- private System.Windows.Forms.ToolBar toolBar1;
- private System.Windows.Forms.ToolBarButton tBtnFirst;
- private System.Windows.Forms.ToolBarButton tBtnPre;
- private System.Windows.Forms.ToolBarButton tBtnNext;
- private System.Windows.Forms.ToolBarButton tBtnLast;
- private System.Windows.Forms.ToolBarButton tBtnNew;
- private System.Windows.Forms.ToolBarButton tBtnEdit;
- private System.Windows.Forms.ToolBarButton tBtnDelete;
- private System.Windows.Forms.ToolBarButton tBtnSubmit;
- private System.Windows.Forms.ToolBarButton tBtnCancel;
- private System.Windows.Forms.ToolBarButton tBtnQuit;
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.ComboBox cmb1;
- private System.Windows.Forms.TextBox txt4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.TextBox txt5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.TextBox txt6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.TextBox txt7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.TextBox txt8;
- private System.Windows.Forms.TextBox txt9;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.Label label12;
- private System.Windows.Forms.TextBox txt10;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Button btnSusbribe;
- private System.Data.SqlClient.SqlDataAdapter da1;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
- private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
- private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private 图书馆管理系统.DataSet1 dataSet11;
- private System.ComponentModel.IContainer components;
- public BookSubscribe()
- {
- //
- // 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.components = new System.ComponentModel.Container();
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BookSubscribe));
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btnSearch = new System.Windows.Forms.Button();
- this.txt1 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.txt2 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.txt3 = new System.Windows.Forms.TextBox();
- this.dataSet11 = new 图书馆管理系统.DataSet1();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.toolBar1 = new System.Windows.Forms.ToolBar();
- this.tBtnFirst = new System.Windows.Forms.ToolBarButton();
- this.tBtnPre = new System.Windows.Forms.ToolBarButton();
- this.tBtnNext = new System.Windows.Forms.ToolBarButton();
- this.tBtnLast = new System.Windows.Forms.ToolBarButton();
- this.tBtnNew = new System.Windows.Forms.ToolBarButton();
- this.tBtnEdit = new System.Windows.Forms.ToolBarButton();
- this.tBtnDelete = new System.Windows.Forms.ToolBarButton();
- this.tBtnSubmit = new System.Windows.Forms.ToolBarButton();
- this.tBtnCancel = new System.Windows.Forms.ToolBarButton();
- this.tBtnQuit = new System.Windows.Forms.ToolBarButton();
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.cmb1 = new System.Windows.Forms.ComboBox();
- this.label4 = new System.Windows.Forms.Label();
- this.txt4 = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.txt5 = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.txt6 = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.txt7 = new System.Windows.Forms.TextBox();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.txt8 = new System.Windows.Forms.TextBox();
- this.txt9 = new System.Windows.Forms.TextBox();
- this.label11 = new System.Windows.Forms.Label();
- this.label12 = new System.Windows.Forms.Label();
- this.txt10 = new System.Windows.Forms.TextBox();
- this.btnSusbribe = new System.Windows.Forms.Button();
- this.da1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btnSearch);
- this.groupBox1.Controls.Add(this.txt1);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.txt2);
- this.groupBox1.Location = new System.Drawing.Point(0, 48);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(616, 56);
- this.groupBox1.TabIndex = 40;
- this.groupBox1.TabStop = false;
- //
- // btnSearch
- //
- this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
- this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnSearch.Location = new System.Drawing.Point(16, 24);
- this.btnSearch.Name = "btnSearch";
- this.btnSearch.Size = new System.Drawing.Size(72, 23);
- this.btnSearch.TabIndex = 0;
- this.btnSearch.Text = " 搜索";
- this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
- //
- // txt1
- //
- this.txt1.Location = new System.Drawing.Point(168, 24);
- this.txt1.Name = "txt1";
- this.txt1.TabIndex = 2;
- this.txt1.Text = "";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(104, 28);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(56, 16);
- this.label2.TabIndex = 1;
- this.label2.Text = "征订编号";
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(296, 28);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(64, 16);
- this.label1.TabIndex = 1;
- this.label1.Text = "图书编号";
- //
- // txt2
- //
- this.txt2.Location = new System.Drawing.Point(360, 24);
- this.txt2.Name = "txt2";
- this.txt2.TabIndex = 2;
- this.txt2.Text = "";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(48, 24);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(64, 16);
- this.label3.TabIndex = 1;
- this.label3.Text = "征订编号";
- //
- // txt3
- //
- this.txt3.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.征订编号"));
- this.txt3.Location = new System.Drawing.Point(48, 40);
- this.txt3.Name = "txt3";
- this.txt3.ReadOnly = true;
- this.txt3.TabIndex = 2;
- this.txt3.Text = "";
- //
- // dataSet11
- //
- this.dataSet11.DataSetName = "DataSet1";
- this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // imageList1
- //
- this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
- this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
- this.imageList1.TransparentColor = System.Drawing.SystemColors.ControlLightLight;
- //
- // toolBar1
- //
- this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
- this.tBtnFirst,
- this.tBtnPre,
- this.tBtnNext,
- this.tBtnLast,
- this.tBtnNew,
- this.tBtnEdit,
- this.tBtnDelete,
- this.tBtnSubmit,
- this.tBtnCancel,
- this.tBtnQuit});
- this.toolBar1.DropDownArrows = true;
- this.toolBar1.ImageList = this.imageList1;
- this.toolBar1.Location = new System.Drawing.Point(0, 0);
- this.toolBar1.Name = "toolBar1";
- this.toolBar1.ShowToolTips = true;
- this.toolBar1.Size = new System.Drawing.Size(616, 41);
- this.toolBar1.TabIndex = 41;
- this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
- //
- // tBtnFirst
- //
- this.tBtnFirst.ImageIndex = 0;
- this.tBtnFirst.Text = "首记录";
- this.tBtnFirst.ToolTipText = "首记录";
- //
- // tBtnPre
- //
- this.tBtnPre.ImageIndex = 1;
- this.tBtnPre.Text = "上一记录";
- this.tBtnPre.ToolTipText = "上一记录";
- //
- // tBtnNext
- //
- this.tBtnNext.ImageIndex = 2;
- this.tBtnNext.Text = "下一记录";
- this.tBtnNext.ToolTipText = "下一记录";
- //
- // tBtnLast
- //
- this.tBtnLast.ImageIndex = 3;
- this.tBtnLast.Text = "尾记录";
- this.tBtnLast.ToolTipText = "尾记录";
- //
- // tBtnNew
- //
- this.tBtnNew.ImageIndex = 4;
- this.tBtnNew.Text = "新增";
- this.tBtnNew.ToolTipText = "新增";
- //
- // tBtnEdit
- //
- this.tBtnEdit.ImageIndex = 5;
- this.tBtnEdit.Text = "修改";
- this.tBtnEdit.ToolTipText = "修改";
- //
- // tBtnDelete
- //
- this.tBtnDelete.ImageIndex = 6;
- this.tBtnDelete.Text = "删除";
- this.tBtnDelete.ToolTipText = "删除";
- //
- // tBtnSubmit
- //
- this.tBtnSubmit.ImageIndex = 7;
- this.tBtnSubmit.Text = "提交";
- this.tBtnSubmit.ToolTipText = "提交";
- //
- // tBtnCancel
- //
- this.tBtnCancel.ImageIndex = 8;
- this.tBtnCancel.Text = "取消";
- this.tBtnCancel.ToolTipText = "取消";
- //
- // tBtnQuit
- //
- this.tBtnQuit.ImageIndex = 9;
- this.tBtnQuit.Text = "退出";
- this.tBtnQuit.ToolTipText = "退出";
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "图书征订";
- this.dataGrid1.DataSource = this.dataSet11;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 104);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.ReadOnly = true;
- this.dataGrid1.Size = new System.Drawing.Size(616, 216);
- this.dataGrid1.TabIndex = 42;
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.checkBox1);
- this.groupBox2.Controls.Add(this.cmb1);
- this.groupBox2.Controls.Add(this.txt3);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.txt4);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.txt5);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.txt6);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.txt7);
- this.groupBox2.Controls.Add(this.label8);
- this.groupBox2.Controls.Add(this.label9);
- this.groupBox2.Controls.Add(this.txt8);
- this.groupBox2.Controls.Add(this.txt9);
- this.groupBox2.Controls.Add(this.label11);
- this.groupBox2.Controls.Add(this.label12);
- this.groupBox2.Controls.Add(this.txt10);
- this.groupBox2.Location = new System.Drawing.Point(0, 318);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(616, 176);
- this.groupBox2.TabIndex = 43;
- this.groupBox2.TabStop = false;
- //
- // checkBox1
- //
- this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.dataSet11, "图书征订.是否验收"));
- this.checkBox1.Enabled = false;
- this.checkBox1.Location = new System.Drawing.Point(192, 142);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.TabIndex = 4;
- this.checkBox1.Text = "是否验收";
- //
- // cmb1
- //
- this.cmb1.Enabled = false;
- this.cmb1.ItemHeight = 12;
- this.cmb1.Location = new System.Drawing.Point(336, 40);
- this.cmb1.Name = "cmb1";
- this.cmb1.Size = new System.Drawing.Size(192, 20);
- this.cmb1.TabIndex = 3;
- this.cmb1.DropDown += new System.EventHandler(this.cmb1_DropDown);
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(184, 24);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(64, 16);
- this.label4.TabIndex = 1;
- this.label4.Text = "图书编号";
- //
- // txt4
- //
- this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.图书编号"));
- this.txt4.Location = new System.Drawing.Point(184, 40);
- this.txt4.Name = "txt4";
- this.txt4.ReadOnly = true;
- this.txt4.Size = new System.Drawing.Size(120, 21);
- this.txt4.TabIndex = 2;
- this.txt4.Text = "";
- this.txt4.TextChanged += new System.EventHandler(this.txt4_TextChanged);
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(336, 24);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(72, 16);
- this.label5.TabIndex = 1;
- this.label5.Text = "图书名称";
- //
- // txt5
- //
- this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.订购者"));
- this.txt5.Location = new System.Drawing.Point(48, 96);
- this.txt5.Name = "txt5";
- this.txt5.ReadOnly = true;
- this.txt5.TabIndex = 2;
- this.txt5.Text = "";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(48, 80);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(48, 16);
- this.label6.TabIndex = 1;
- this.label6.Text = "订购者";
- //
- // txt6
- //
- this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.操作员"));
- this.txt6.Location = new System.Drawing.Point(176, 96);
- this.txt6.Name = "txt6";
- this.txt6.ReadOnly = true;
- this.txt6.TabIndex = 2;
- this.txt6.Text = "";
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(176, 80);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(56, 16);
- this.label7.TabIndex = 1;
- this.label7.Text = "操作员";
- //
- // txt7
- //
- this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.订购数量"));
- this.txt7.Location = new System.Drawing.Point(304, 96);
- this.txt7.Name = "txt7";
- this.txt7.ReadOnly = true;
- this.txt7.TabIndex = 2;
- this.txt7.Text = "";
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(304, 80);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(72, 16);
- this.label8.TabIndex = 1;
- this.label8.Text = "订购数量";
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(432, 80);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(80, 16);
- this.label9.TabIndex = 1;
- this.label9.Text = "订购单价";
- //
- // txt8
- //
- this.txt8.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.订购单价"));
- this.txt8.Location = new System.Drawing.Point(430, 96);
- this.txt8.Name = "txt8";
- this.txt8.ReadOnly = true;
- this.txt8.TabIndex = 2;
- this.txt8.Text = "";
- //
- // txt9
- //
- this.txt9.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.订购日期"));
- this.txt9.Location = new System.Drawing.Point(48, 144);
- this.txt9.Name = "txt9";
- this.txt9.ReadOnly = true;
- this.txt9.TabIndex = 2;
- this.txt9.Text = "";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(48, 128);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(72, 16);
- this.label11.TabIndex = 1;
- this.label11.Text = "订购日期";
- //
- // label12
- //
- this.label12.Location = new System.Drawing.Point(336, 128);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(128, 16);
- this.label12.TabIndex = 1;
- this.label12.Text = "订购者联系方式";
- //
- // txt10
- //
- this.txt10.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "图书征订.订购者联系方式"));
- this.txt10.Location = new System.Drawing.Point(336, 144);
- this.txt10.Name = "txt10";
- this.txt10.ReadOnly = true;
- this.txt10.Size = new System.Drawing.Size(192, 21);
- this.txt10.TabIndex = 2;
- this.txt10.Text = "";
- //
- // btnSusbribe
- //
- this.btnSusbribe.Location = new System.Drawing.Point(451, 4);
- this.btnSusbribe.Name = "btnSusbribe";
- this.btnSusbribe.Size = new System.Drawing.Size(141, 35);
- this.btnSusbribe.TabIndex = 44;
- this.btnSusbribe.Text = "提交征订(验收)";
- this.btnSusbribe.Click += new System.EventHandler(this.btnSusbribe_Click);
- //
- // da1
- //
- this.da1.DeleteCommand = this.sqlDeleteCommand1;
- this.da1.InsertCommand = this.sqlInsertCommand1;
- this.da1.SelectCommand = this.sqlSelectCommand1;
- this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "图书征订", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("征订编号", "征订编号"),
- new System.Data.Common.DataColumnMapping("图书编号", "图书编号"),
- new System.Data.Common.DataColumnMapping("订购者", "订购者"),
- new System.Data.Common.DataColumnMapping("订购者联系方式", "订购者联系方式"),
- new System.Data.Common.DataColumnMapping("订购数量", "订购数量"),
- new System.Data.Common.DataColumnMapping("订购单价", "订购单价"),
- new System.Data.Common.DataColumnMapping("订购日期", "订购日期"),
- new System.Data.Common.DataColumnMapping("是否验收", "是否验收"),
- new System.Data.Common.DataColumnMapping("验收日期", "验收日期"),
- new System.Data.Common.DataColumnMapping("操作员", "操作员")})});
- this.da1.UpdateCommand = this.sqlUpdateCommand1;
- //
- // sqlDeleteCommand1
- //
- this.sqlDeleteCommand1.CommandText = @"DELETE FROM 图书征订 WHERE (征订编号 = @Original_征订编号) AND (图书编号 = @Original_图书编号) AND (操作员 = @Original_操作员 OR @Original_操作员 IS NULL AND 操作员 IS NULL) AND (是否验收 = @Original_是否验收 OR @Original_是否验收 IS NULL AND 是否验收 IS NULL) AND (订购单价 = @Original_订购单价 OR @Original_订购单价 IS NULL AND 订购单价 IS NULL) AND (订购数量 = @Original_订购数量 OR @Original_订购数量 IS NULL AND 订购数量 IS NULL) AND (订购日期 = @Original_订购日期 OR @Original_订购日期 IS NULL AND 订购日期 IS NULL) AND (订购者 = @Original_订购者 OR @Original_订购者 IS NULL AND 订购者 IS NULL) AND (订购者联系方式 = @Original_订购者联系方式 OR @Original_订购者联系方式 IS NULL AND 订购者联系方式 IS NULL) AND (验收日期 = @Original_验收日期 OR @Original_验收日期 IS NULL AND 验收日期 IS NULL)";
- this.sqlDeleteCommand1.Connection = this.sqlConnection1;
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_征订编号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "征订编号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_图书编号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "图书编号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_操作员", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "操作员", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_是否验收", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "是否验收", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购单价", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购单价", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购数量", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购数量", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购日期", System.Data.SqlDbType.DateTime, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购日期", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购者", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购者", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购者联系方式", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购者联系方式", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_验收日期", System.Data.SqlDbType.DateTime, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "验收日期", System.Data.DataRowVersion.Original, null));
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=libbook;";
- //
- // sqlInsertCommand1
- //
- this.sqlInsertCommand1.CommandText = "INSERT INTO 图书征订(征订编号, 图书编号, 订购者, 订购者联系方式, 订购数量, 订购单价, 订购日期, 是否验收, 验收日期, 操作员) VAL" +
- "UES (@征订编号, @图书编号, @订购者, @订购者联系方式, @订购数量, @订购单价, @订购日期, @是否验收, @验收日期, @操作员); SEL" +
- "ECT 征订编号, 图书编号, 订购者, 订购者联系方式, 订购数量, 订购单价, 订购日期, 是否验收, 验收日期, 操作员 FROM 图书征订 WHERE " +
- "(征订编号 = @征订编号)";
- this.sqlInsertCommand1.Connection = this.sqlConnection1;
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@征订编号", System.Data.SqlDbType.VarChar, 50, "征订编号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@图书编号", System.Data.SqlDbType.VarChar, 50, "图书编号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购者", System.Data.SqlDbType.VarChar, 100, "订购者"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购者联系方式", System.Data.SqlDbType.VarChar, 100, "订购者联系方式"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购数量", System.Data.SqlDbType.Int, 4, "订购数量"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购单价", System.Data.SqlDbType.Money, 8, "订购单价"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购日期", System.Data.SqlDbType.DateTime, 4, "订购日期"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否验收", System.Data.SqlDbType.Bit, 1, "是否验收"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@验收日期", System.Data.SqlDbType.DateTime, 4, "验收日期"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@操作员", System.Data.SqlDbType.VarChar, 20, "操作员"));
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 征订编号, 图书编号, 订购者, 订购者联系方式, 订购数量, 订购单价, 订购日期, 是否验收, 验收日期, 操作员 FROM 图书征订 WHER" +
- "E (是否验收 = '0') AND (征订编号 LIKE @Param3) AND (图书编号 LIKE @Param4)";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param3", System.Data.SqlDbType.VarChar, 50, "征订编号"));
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 50, "图书编号"));
- //
- // sqlUpdateCommand1
- //
- this.sqlUpdateCommand1.CommandText = @"UPDATE 图书征订 SET 征订编号 = @征订编号, 图书编号 = @图书编号, 订购者 = @订购者, 订购者联系方式 = @订购者联系方式, 订购数量 = @订购数量, 订购单价 = @订购单价, 订购日期 = @订购日期, 是否验收 = @是否验收, 验收日期 = @验收日期, 操作员 = @操作员 WHERE (征订编号 = @Original_征订编号) AND (图书编号 = @Original_图书编号) AND (操作员 = @Original_操作员 OR @Original_操作员 IS NULL AND 操作员 IS NULL) AND (是否验收 = @Original_是否验收 OR @Original_是否验收 IS NULL AND 是否验收 IS NULL) AND (订购单价 = @Original_订购单价 OR @Original_订购单价 IS NULL AND 订购单价 IS NULL) AND (订购数量 = @Original_订购数量 OR @Original_订购数量 IS NULL AND 订购数量 IS NULL) AND (订购日期 = @Original_订购日期 OR @Original_订购日期 IS NULL AND 订购日期 IS NULL) AND (订购者 = @Original_订购者 OR @Original_订购者 IS NULL AND 订购者 IS NULL) AND (订购者联系方式 = @Original_订购者联系方式 OR @Original_订购者联系方式 IS NULL AND 订购者联系方式 IS NULL) AND (验收日期 = @Original_验收日期 OR @Original_验收日期 IS NULL AND 验收日期 IS NULL); SELECT 征订编号, 图书编号, 订购者, 订购者联系方式, 订购数量, 订购单价, 订购日期, 是否验收, 验收日期, 操作员 FROM 图书征订 WHERE (征订编号 = @征订编号)";
- this.sqlUpdateCommand1.Connection = this.sqlConnection1;
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@征订编号", System.Data.SqlDbType.VarChar, 50, "征订编号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@图书编号", System.Data.SqlDbType.VarChar, 50, "图书编号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购者", System.Data.SqlDbType.VarChar, 100, "订购者"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购者联系方式", System.Data.SqlDbType.VarChar, 100, "订购者联系方式"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购数量", System.Data.SqlDbType.Int, 4, "订购数量"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购单价", System.Data.SqlDbType.Money, 8, "订购单价"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@订购日期", System.Data.SqlDbType.DateTime, 4, "订购日期"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否验收", System.Data.SqlDbType.Bit, 1, "是否验收"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@验收日期", System.Data.SqlDbType.DateTime, 4, "验收日期"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@操作员", System.Data.SqlDbType.VarChar, 20, "操作员"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_征订编号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "征订编号", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_图书编号", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "图书编号", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_操作员", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "操作员", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_是否验收", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "是否验收", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购单价", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购单价", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购数量", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购数量", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购日期", System.Data.SqlDbType.DateTime, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购日期", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购者", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购者", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_订购者联系方式", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "订购者联系方式", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_验收日期", System.Data.SqlDbType.DateTime, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "验收日期", System.Data.DataRowVersion.Original, null));
- //
- // BookSubscribe
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(616, 493);
- this.Controls.Add(this.btnSusbribe);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.toolBar1);
- this.Controls.Add(this.groupBox1);
- this.Name = "BookSubscribe";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【图书征订】";
- this.Load += new System.EventHandler(this.BookSubscribe_Load);
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- //------------创建窗体时读入数据------------
- private void BookSubscribe_Load(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%%";
- da1.SelectCommand.Parameters[1].Value="%%";
- da1.Fill(dataSet11);
- //绑定数据导航
- cmOrders=(CurrencyManager) BindingContext[dataSet11,"图书征订"];
- }
- //-----------显示图书编号时同时显示图书名称--------------
- private void txt4_TextChanged(object sender, System.EventArgs e)
- {
- if(txt4.ReadOnly==false||txt4.Text.Trim()=="")//无内容或者是编辑状态时,无需查询
- {
- return;
- }
- string connStr="workstation id=localhost;Integrated Security=SSPI;Database=libbook;";
- SqlConnection cn=new SqlConnection(connStr);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="select 书名 from 图书信息 where 编号='"+txt4.Text.Trim()+"'";
- cmb1.Text=cmd.ExecuteScalar().ToString().Trim();
- }
- //----------根据输入的信息,查询征订图书信息--------
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%%";
- da1.SelectCommand.Parameters[1].Value="%%";
- if(txt1.Text!="")
- {
- da1.SelectCommand.Parameters[0].Value="%"+txt1.Text+"%";
- }
- if(txt2.Text!="")
- {
- da1.SelectCommand.Parameters[1].Value="%"+txt2.Text+"%";
- }
- dataSet11.图书征订.Clear();
- da1.Fill(dataSet11);
- }
- //---------------工具栏事务处理----------------
- private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
- {
- if (e.Button.ToolTipText == "首记录")
- {
- this.dataGrid1.UnSelect(cmOrders.Position); //取消原选中的行
- cmOrders.Position = 0;
- this.dataGrid1.Select(cmOrders.Position); //选中当前行
- this.dataGrid1.CurrentRowIndex = cmOrders.Position; //移动表头指示图标
- return;
- }
- if (e.Button.ToolTipText == "上一记录")
- {
- if (cmOrders.Position >= 0)
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position--;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- }
- return;
- }
- if (e.Button.ToolTipText == "下一记录")
- {
- if (cmOrders.Position <= cmOrders.Count-1)
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position++;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- }
- return;
- }
- if (e.Button.ToolTipText == "尾记录")
- {
- this.dataGrid1.UnSelect(cmOrders.Position);
- cmOrders.Position = cmOrders.Count-1;
- this.dataGrid1.Select(cmOrders.Position);
- this.dataGrid1.CurrentRowIndex = cmOrders.Position;
- return;
- }
- if(e.Button.ToolTipText=="新增")
- {
- cmOrders.AddNew();
- //设置默认值
- SetDefaultValue();
- SetModifyMode(true);
- cmb1.Text="";
- }
- if(e.Button.ToolTipText=="修改")
- {
- SetModifyMode(true);
- }
- if(e.Button.ToolTipText=="删除")
- {
- DialogResult result=MessageBox.Show("确认删除?","删除数据",MessageBoxButtons.OKCancel);
- if(result==DialogResult.OK)
- if(cmOrders.Count>0)//立即从数据集中删除
- {
- cmOrders.RemoveAt(cmOrders.Position);
- da1.Update(dataSet11);
- }
- else
- MessageBox.Show("表中为空,已无可删除数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- if(e.Button.ToolTipText=="提交")
- {
- if(txt4.Text.Trim()=="")//检查字段
- {
- MessageBox.Show("请输入图书编号","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
- return;
- }
- cmOrders.EndCurrentEdit();
- if(dataSet11.GetChanges()!=null)
- {
- try
- {
- da1.Update(dataSet11);
- SetModifyMode(false);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- dataSet11.RejectChanges();
- }
- }
- return;
- }
- if (e.Button.ToolTipText == "取消")
- {
- try
- {
- cmOrders.CancelCurrentEdit(); //取消编辑
- SetModifyMode(false);
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
- }
- return;
- }
- if(e.Button.ToolTipText=="退出")
- {
- this.Close();
- }
- }
- //--------------对控件的属性做设置---------------
- private void SetModifyMode(bool blnEdit)
- {
- //设置文本框和下拉列表框属性
- txt4.ReadOnly=!blnEdit;
- txt5.ReadOnly=!blnEdit;
- txt6.ReadOnly=!blnEdit;
- txt7.ReadOnly=!blnEdit;
- txt8.ReadOnly=!blnEdit;
- txt9.ReadOnly=!blnEdit;
- txt10.ReadOnly=!blnEdit;
- cmb1.Enabled=blnEdit;
- //设置搜索按钮属性
- btnSearch.Enabled=!blnEdit;
- }
- //------------在新增数据时,设置默认值--------------
- private void SetDefaultValue()
- {
- string strConn = "workstation id=localhost;Integrated Security=SSPI;database=libbook";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="select max(征订编号) 最大编号 from 图书征订";
- int maxID=1;//计算新编号
- object result=cmd.ExecuteScalar();
- if(result!=System.DBNull.Value)
- {
- maxID=Convert.ToInt32(result)+1;
- }
- int length=maxID.ToString().Length;
- switch(length)//生成新的编码
- {
- case 1:
- txt3.Text="000000"+maxID.ToString();
- break;
- case 2:
- txt3.Text="00000"+maxID.ToString();
- break;
- case 3:
- txt3.Text="0000"+maxID.ToString();
- break;
- case 4:
- txt3.Text="000"+maxID.ToString();
- break;
- case 5:
- txt3.Text="00"+maxID.ToString();
- break;
- case 6:
- txt3.Text="0"+maxID.ToString();
- break;
- }
- }
- //------------调出图书选择窗体,选择图书-------------
- private void cmb1_DropDown(object sender, System.EventArgs e)
- {
- cmb1.Text="";//清空原有书名
- SelectBook newfrm=new SelectBook();//调出新窗口选择图书
- newfrm.Text="双击表格选择图书";
- newfrm.ShowDialog();
- txt4.Text=bookID;//读入选择的图书信息
- cmb1.Text=bookName;
- }
- //-----------调用储存过程,提交图书征订----------
- private void btnSusbribe_Click(object sender, System.EventArgs e)
- {
- string strConn = "workstation id=localhost;Integrated Security=SSPI;database=libbook";
- SqlConnection cn=new SqlConnection(strConn);
- cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="exec sf_图书征订";
- try
- {
- cmd.ExecuteNonQuery();
- dataSet11.图书征订.Clear();//刷新数据集
- da1.SelectCommand.Parameters[0].Value="%";
- da1.SelectCommand.Parameters[1].Value="%";
- da1.Fill(dataSet11);
- return;
- }
- catch(Exception express)
- {
- MessageBox.Show(express.ToString(),"无法验收",MessageBoxButtons.OK,MessageBoxIcon.Error);
- return;
- }
- }
- }
- }