📄 return_form.cs
字号:
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(112, 32);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(168, 21);
this.textBox3.TabIndex = 7;
this.textBox3.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(24, 192);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 16);
this.label6.TabIndex = 6;
this.label6.Text = "货物状态:";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 152);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(96, 16);
this.label5.TabIndex = 5;
this.label5.Text = "接收货物数量:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 112);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 16);
this.label4.TabIndex = 4;
this.label4.Text = "配送员帐号:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 2;
this.label3.Text = "回执单号:";
//
// groupBox3
//
this.groupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label8,
this.label7,
this.textBox8,
this.textBox7});
this.groupBox3.Location = new System.Drawing.Point(352, 64);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(312, 224);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "收货方信息";
//
// label8
//
this.label8.Location = new System.Drawing.Point(32, 104);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(144, 16);
this.label8.TabIndex = 14;
this.label8.Text = "收货详细地址:";
//
// label7
//
this.label7.Location = new System.Drawing.Point(32, 40);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 16);
this.label7.TabIndex = 13;
this.label7.Text = "收货人:";
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(24, 136);
this.textBox8.Multiline = true;
this.textBox8.Name = "textBox8";
this.textBox8.Size = new System.Drawing.Size(272, 56);
this.textBox8.TabIndex = 12;
this.textBox8.Text = "";
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(120, 40);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(168, 21);
this.textBox7.TabIndex = 11;
this.textBox7.Text = "";
//
// return_Form
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(680, 533);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.groupBox3,
this.groupBox2,
this.dataGrid1,
this.toolBar1});
this.Name = "return_Form";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "回执单维护";
this.Load += new System.EventHandler(this.return_Form_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void DataBingingsFunction()
{
this.textBox1.DataBindings.Add("Text",ds.Tables[0],"订单编号");
this.textBox3.DataBindings.Add("Text",ds.Tables[0],"回执单号");
this.textBox4.DataBindings.Add("Text",ds.Tables[0],"配送员帐号");
this.textBox5.DataBindings.Add("Text",ds.Tables[0],"接收货物数量");
this.textBox6.DataBindings.Add("Text",ds.Tables[0],"货物状态");
this.textBox7.DataBindings.Add("Text",ds.Tables[0],"收货人");
this.textBox8.DataBindings.Add("Text",ds.Tables[0],"收货地点");
}
private void return_Form_Load(object sender, System.EventArgs e)
{
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
if (e.Button.ToolTipText == "首记录")
{
this.dataGrid1.UnSelect(cmAmend.Position); //取消选中指定行
cmAmend.Position = 0;
this.dataGrid1.Select(cmAmend.Position); //选中指定行
this.dataGrid1.CurrentRowIndex = cmAmend.Position; //移动表头指示图标
return;
}
if (e.Button.ToolTipText == "上一个记录")
{
if (cmAmend.Position > 0)
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position--;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
}
return;
}
if (e.Button.ToolTipText == "下一个记录")
{
if (cmAmend.Position < cmAmend.Count-1)
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position++;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
}
return;
}
if (e.Button.ToolTipText == "末记录")
{
this.dataGrid1.UnSelect(cmAmend.Position);
cmAmend.Position = cmAmend.Count-1;
this.dataGrid1.Select(cmAmend.Position);
this.dataGrid1.CurrentRowIndex = cmAmend.Position;
return;
}
if(e.Button.ToolTipText=="退出")
{
this.Close();
}
if (e.Button.ToolTipText == "新增记录")
{
cmAmend.AddNew();
return;
}
if (e.Button.ToolTipText == "删除记录")
{
if (MessageBox.Show(" 确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
if (cmAmend.Count > 0)
cmAmend.RemoveAt(cmAmend.Position);
else
{
MessageBox.Show("没有可以删除的数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
catch(Exception express)
{
MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
return;
}
}
if (e.Button.ToolTipText == "保存修改")//保存对数据所作的修改
{
try
{
int row = this.dataGrid1.CurrentCell.RowNumber;
//将当前所在行往下移动一行,为便于实现同步保存
//(否则会出现修改的最后一行无法保存,因为它还处于编辑状态)
this.dataGrid1.CurrentCell = new DataGridCell(row+1,0);
if (this.ds.HasChanges())
{
this.link.UpdateDataBase(this.ds.GetChanges(),sendTableName);
MessageBox.Show("数据修改成功!","信息");
}
else
{
MessageBox.Show("没有需要修改的数据!");
return;
}
}
catch
{
MessageBox.Show("数据保存失败,请确认所有信息输入完整且正确!","提示");
return;
}
}
if (e.Button.ToolTipText == "提交记录")
{
if (this.textBox3.Text.Trim() == ""||this.textBox4.Text.Trim()==""||this.textBox5.Text.Trim()==""||this.textBox6.Text.Trim()==""||this.textBox7.Text.Trim()==""||this.textBox8.Text.Trim()=="")//检查不能为空的字段
{
MessageBox.Show("栏目不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
cmAmend.EndCurrentEdit();//结束当前编辑操作并提交修改
if (ds.GetChanges() != null)
{
try
{
this.link.UpdateDataBase(this.ds.GetChanges(),sendTableName);
}
catch(Exception express)
{
MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.ds.Tables [0].RejectChanges();
}
}
return;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -