📄 kfdj.cs
字号:
//
this.label5.Location = new System.Drawing.Point(32, 136);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(40, 16);
this.label5.TabIndex = 15;
this.label5.Text = "配置";
//
// label7
//
this.label7.Location = new System.Drawing.Point(24, 192);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(56, 23);
this.label7.TabIndex = 16;
this.label7.Text = "使用设置";
//
// label8
//
this.label8.Location = new System.Drawing.Point(40, 240);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(32, 16);
this.label8.TabIndex = 17;
this.label8.Text = "备注";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(104, 128);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(376, 48);
this.richTextBox1.TabIndex = 18;
this.richTextBox1.Text = "richTextBox1";
//
// richTextBox2
//
this.richTextBox2.Location = new System.Drawing.Point(104, 184);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(320, 48);
this.richTextBox2.TabIndex = 19;
this.richTextBox2.Text = "richTextBox2";
//
// richTextBox3
//
this.richTextBox3.Location = new System.Drawing.Point(104, 240);
this.richTextBox3.Name = "richTextBox3";
this.richTextBox3.Size = new System.Drawing.Size(320, 48);
this.richTextBox3.TabIndex = 20;
this.richTextBox3.Text = "richTextBox3";
//
// dgrd_StockerData
//
this.dgrd_StockerData.AlternatingBackColor = System.Drawing.Color.GhostWhite;
this.dgrd_StockerData.BackColor = System.Drawing.Color.GhostWhite;
this.dgrd_StockerData.BackgroundColor = System.Drawing.Color.Lavender;
this.dgrd_StockerData.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dgrd_StockerData.CaptionBackColor = System.Drawing.Color.RoyalBlue;
this.dgrd_StockerData.CaptionForeColor = System.Drawing.Color.White;
this.dgrd_StockerData.DataMember = "";
this.dgrd_StockerData.FlatMode = true;
this.dgrd_StockerData.Font = new System.Drawing.Font("Tahoma", 8F);
this.dgrd_StockerData.ForeColor = System.Drawing.Color.MidnightBlue;
this.dgrd_StockerData.GridLineColor = System.Drawing.Color.RoyalBlue;
this.dgrd_StockerData.HeaderBackColor = System.Drawing.Color.MidnightBlue;
this.dgrd_StockerData.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
this.dgrd_StockerData.HeaderForeColor = System.Drawing.Color.Lavender;
this.dgrd_StockerData.LinkColor = System.Drawing.Color.Teal;
this.dgrd_StockerData.Location = new System.Drawing.Point(16, 296);
this.dgrd_StockerData.Name = "dgrd_StockerData";
this.dgrd_StockerData.ParentRowsBackColor = System.Drawing.Color.Lavender;
this.dgrd_StockerData.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
this.dgrd_StockerData.SelectionBackColor = System.Drawing.Color.Teal;
this.dgrd_StockerData.SelectionForeColor = System.Drawing.Color.PaleGreen;
this.dgrd_StockerData.Size = new System.Drawing.Size(488, 112);
this.dgrd_StockerData.TabIndex = 29;
//
// button1
//
this.button1.Location = new System.Drawing.Point(432, 216);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 56);
this.button1.TabIndex = 30;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// kfdj
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(520, 421);
this.Controls.Add(this.button1);
this.Controls.Add(this.dgrd_StockerData);
this.Controls.Add(this.richTextBox3);
this.Controls.Add(this.richTextBox2);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label5);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.label4);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.toolBar1);
this.Name = "kfdj";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【客房登记】";
this.Load += new System.EventHandler(this.kfdj_Load);
((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void kfdj_Load(object sender, System.EventArgs e)
{
textBox1.Text=richTextBox1.Text=richTextBox2.Text=richTextBox3.Text="";
}
private void button1_Click(object sender, System.EventArgs e)
{
DataTable ordersTable = ds1.Tables["jud_kfxx"];
DataRow workRow = ds1.Tables["jud_kfxx"].NewRow();
workRow[0] =textBox1.Text;
workRow[1] = comboBox1.Text;
workRow[2] = comboBox2.Text;
workRow[3] = richTextBox1.Text;
workRow[4] = richTextBox2.Text;
workRow[5] = dateTimePicker1.Text;
workRow[6] = richTextBox3.Text;
ds1.Tables["jud_kfxx"].Rows.Add(workRow);
textBox1.Text=richTextBox1.Text=richTextBox2.Text=richTextBox3.Text="";
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
string sendTableName="jud_kfxx";
if (e.Button.ToolTipText == "保存修改")
{
try
{
int row = this.dgrd_StockerData.CurrentCell.RowNumber;
//将当前所在行往下移动一行,为便于实现同步保存
//(否则会出现修改的最后一行无法保存,因为它还处于编辑状态)
this.dgrd_StockerData.CurrentCell = new DataGridCell(row+1,0);
if (this.ds1.HasChanges())
{
this.link1.UpdateDataBase(this.ds1.GetChanges(),sendTableName);
MessageBox.Show("数据修改成功!","信息");
string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
}
else
{
MessageBox.Show("没有修改的数据!");
return;
}
}
catch(Exception ex)
{
MessageBox.Show("数据保存失败,请确认所有信息输入完整且正确!"+ex,"提示");
return;
}
}
if (e.Button.ToolTipText == "删除数据")
{
if (MessageBox.Show("确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
int intRowNumber = this.dgrd_StockerData.CurrentCell.RowNumber;
try
{
DataRow workrow=this.ds1.Tables[0].Rows[intRowNumber];
string fjh = workrow[2].ToString();
this.ds1.Tables[0].Rows[intRowNumber].Delete();
this.link1.UpdateDataBase(this.ds1.GetChanges(),sendTableName);
MessageBox.Show("数据删除成功!","信息");
string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
}
catch(Exception ex)
{
MessageBox.Show("该数据不能删除!"+ex,"提示");
string tempStrSQL ="select fjh as '房间编号',lxbh as '类型编号',ft as '使用状态',pz as '配置',sypz as '使用配置',yysj as '营业时间',bz as '备注' from jud_kfxx ";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
return;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -