📄 rzdj.cs
字号:
this.label21.TabIndex = 47;
this.label21.Text = "证件号码";
//
// textBox14
//
this.textBox14.Location = new System.Drawing.Point(288, 160);
this.textBox14.Name = "textBox14";
this.textBox14.Size = new System.Drawing.Size(232, 21);
this.textBox14.TabIndex = 48;
this.textBox14.Text = "textBox14";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(560, 216);
this.checkBox1.Name = "checkBox1";
this.checkBox1.TabIndex = 49;
this.checkBox1.Text = "是否结帐";
//
// rzdj
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(720, 421);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.textBox14);
this.Controls.Add(this.label21);
this.Controls.Add(this.textBox13);
this.Controls.Add(this.label20);
this.Controls.Add(this.textBox12);
this.Controls.Add(this.label19);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label18);
this.Controls.Add(this.textBox11);
this.Controls.Add(this.label17);
this.Controls.Add(this.textBox10);
this.Controls.Add(this.label16);
this.Controls.Add(this.textBox9);
this.Controls.Add(this.label15);
this.Controls.Add(this.textBox8);
this.Controls.Add(this.label14);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label13);
this.Controls.Add(this.button1);
this.Controls.Add(this.label12);
this.Controls.Add(this.dgrd_StockerData);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.textBox7);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dateTimePicker2);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.toolBar1);
this.Name = "rzdj";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【入住登记】";
this.Load += new System.EventHandler(this.rzdj_Load);
((System.ComponentModel.ISupportInitialize)(this.dgrd_StockerData)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void rzdj_Load(object sender, System.EventArgs e)
{
this.textBox1.Text=this.textBox2.Text=this.textBox3.Text=this.textBox4.Text=this.textBox5.Text=this.textBox6.Text=this.richTextBox1.Text="";
this.textBox8.Text=this.textBox9.Text=this.textBox10.Text=this.textBox11.Text=this.textBox12.Text=this.textBox13.Text=this.textBox14.Text="";
this.textBox4.Text="2";
this.textBox5.Text="1000";
this.textBox6.Text="1";
if (LoginFrm.strUser=="")
{ this.textBox7.Text="未知";}
else
{this.textBox7.Text=LoginFrm.strUser;}
scfjh();
}
private void scfjh() //生成房间号
{
string sendTableName = "jud_kfxx";
string kong="空房";
string sendStrSQL ="select fjh from jud_kfxx where ft='"+kong+"'";
this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
listBox1.DataSource = ds.Tables[sendTableName];
listBox1.DisplayMember = "fjh";
}
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
if (textBox1.Text=="")
{
textBox1.Text="无";
}
if (textBox3.Text=="")
{
textBox3.Text="无";
}
if(textBox2.Text=="")
{
MessageBox.Show("姓名不能为空!","提示");
this.textBox2.Focus();
}
else
{
DateTime dt = DateTime.Now;
DataTable ordersTable = ds1.Tables["jud_djb"];
DataRow workRow = ds1.Tables["jud_djb"].NewRow();
int yue =dt.Month;
string yue1;
if (yue<10)
{ yue1="0"+yue.ToString();}
else{yue1=yue.ToString();}
int day =dt.Day;
string day1;
if (day<10)
{day1="0"+day.ToString();}
else{day1=day.ToString();}
int hour=dt.Hour;
int min=dt.Minute;
int sec=dt.Second;
string hour1;
string min1;
string sec1;
if (hour<10)
{hour1="0"+hour.ToString();}
else{hour1=hour.ToString();}
if (min<10)
{min1="0"+min.ToString();}
else{min1=min.ToString();}
if (sec<10)
{sec1="0"+sec.ToString();}
else{sec1=sec.ToString();}
string pz ="DJ"+dt.Year.ToString()+yue1+day1+hour1+min1+sec1;
string xz="";
if (checkBox1.Checked ==true)
{ xz="1";}
else{xz="0";}
workRow[0] = pz;
workRow[1] = textBox2.Text;
workRow[2] = comboBox1.Text;
workRow[3] = textBox8.Text;
workRow[4] = textBox9.Text;
workRow[5] = textBox10.Text;
workRow[6] = textBox1.Text;
workRow[7] = textBox11.Text;
workRow[8] = comboBox2.Text;
workRow[9] = textBox12.Text;
workRow[10] = textBox13.Text;
workRow[11] = textBox14.Text;
workRow[12] = textBox3.Text;
workRow[13] = listBox1.Text;
workRow[14] = dateTimePicker1.Text;
workRow[15] = textBox4.Text;
workRow[16] = dateTimePicker2.Text;
workRow[17] = textBox5.Text;
workRow[18] = richTextBox1.Text;
workRow[19] = dt.Year.ToString()+"-"+dt.Month.ToString()+"-"+dt.Day.ToString();
workRow[20] = hour1+":"+min1+":"+sec1;
workRow[21] = textBox7.Text;
workRow[22] = xz;
ds1.Tables["jud_djb"].Rows.Add(workRow);
this.textBox1.Focus();
this.textBox1.Text=this.textBox2.Text=this.textBox3.Text=this.textBox4.Text=this.textBox5.Text=this.textBox6.Text=this.richTextBox1.Text="";
this.textBox8.Text=this.textBox9.Text=this.textBox10.Text=this.textBox11.Text=this.textBox12.Text=this.textBox13.Text=this.textBox14.Text="";
this.textBox4.Text="2";
this.textBox5.Text="1000";
this.textBox6.Text="1";
}
}
private void fangtai(string ft,string fjh)
{
//修改房屋状态
string sendTableName = "jud_kfxx";
string sendStrSQL ="update jud_kfxx set ft='"+ft+"' where fjh='"+fjh+"'";
this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
listBox1.DataSource = ds.Tables[sendTableName];
listBox1.DisplayMember = "fjh";
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
DateTime dt = DateTime.Now;
string shijian = dt.Year.ToString()+"-"+dt.Month.ToString()+"-"+dt.Day.ToString();
string sendTableName="jud_djb";
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 pzhm as '凭证号码',xm as '姓名',xb as '性别',nl as '年龄',zjmc as '证件名称',zjhm as '证件号码',gzdw as '工作单位',xm1 as '姓名1',xb1 as '性别1',nl1 as '年龄1',zjmc1 as '证件名称1',zjhm1 as '证件号码1',gzdw1 as '工作单位1',fjh as '房间号',zsrq as '住宿日期',yzts as '预住天数',tsrq as '退宿日期',yj as '押金',bz as '备注',rq as '日期',sj as '时间',lsfwy as '来宿服务员',sfjz as '是否结帐' from jud_djb where rq='"+shijian+"'";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
fangtai("入住",listBox1.Text);
scfjh();
}
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[13].ToString();
this.ds1.Tables[0].Rows[intRowNumber].Delete();
this.link1.UpdateDataBase(this.ds1.GetChanges(),sendTableName);
MessageBox.Show("数据删除成功!","信息");
string tempStrSQL ="select pzhm as '凭证号码',xm as '姓名',xb as '性别',nl as '年龄',zjmc as '证件名称',zjhm as '证件号码',gzdw as '工作单位',xm1 as '姓名1',xb1 as '性别1',nl1 as '年龄1',zjmc1 as '证件名称1',zjhm1 as '证件号码1',gzdw1 as '工作单位1',fjh as '房间号',zsrq as '住宿日期',yzts as '预住天数',tsrq as '退宿日期',yj as '押金',bz as '备注',rq as '日期',sj as '时间',lsfwy as '来宿服务员',sfjz as '是否结帐' from jud_djb where rq='"+shijian+"'";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
fangtai("空房",fjh);
scfjh();
}
catch(Exception ex)
{
MessageBox.Show("该数据不能删除!"+ex,"提示");
string tempStrSQL ="select pzhm as '凭证号码',xm as '姓名',xb as '性别',nl as '年龄',zjmc as '证件名称',zjhm as '证件号码',gzdw as '工作单位',xm1 as '姓名1',xb1 as '性别1',nl1 as '年龄1',zjmc1 as '证件名称1',zjhm1 as '证件号码1',gzdw1 as '工作单位1',fjh as '房间号',zsrq as '住宿日期',yzts as '预住天数',tsrq as '退宿日期',yj as '押金',bz as '备注',rq as '日期',sj as '时间',lsfwy as '来宿服务员',sfjz as '是否结帐' from jud_djb where rq='"+shijian+"'";
this.link1.SelectDataBase(tempStrSQL,sendTableName);
return;
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -