📄 frmunitopen.cs
字号:
MessageBox.Show("请选择证件类型!", "提示");
return;
}
if (txtCardNum.Text.Trim().Equals(""))
{
MessageBox.Show("证件号码不能为空!", "提示");
return;
}
if (txtPhone.Text.Trim().Equals(""))
{
MessageBox.Show("联系电话不能为空!", "提示");
return;
}
if (txtAddress.Text.Trim().Equals(""))
{
MessageBox.Show("请输入宾客的联系地址!", "提示");
return;
}
// 以证件号码查询客户表,是否存在该客户
string str = txtCardNum.Text.Trim();
objBuyerAccess = new BuyerAccess();
ds = new DataSet();
ds = objBuyerAccess.GetBuyerInfo(str);
if (ds.Tables[0].Rows.Count == 0)
{
lear = true;
}
else
{
txtBuyerNum.Text = ds.Tables[0].Rows[0][0].ToString();
lear = false;
}
//如果客户表里不存在该客户,则插入记录
if (lear == true)
{
//使用储存过程插入客户信息
buyerEntity = new Buyer();
buyerEntity.BName = txtBuyerName.Text;
buyerEntity.Birthday = dtpBirthday.Text;
buyerEntity.CertificateID = cboCardType.SelectedIndex + 1;
buyerEntity.BCarNum = txtCardNum.Text;
buyerEntity.BSex = cboSex.Text;
buyerEntity.Phone = txtPhone.Text;
buyerEntity.Company = txtCompany.Text;
buyerEntity.NationalityID = cboNationality.SelectedIndex + 1;
buyerEntity.ProvinceID = cboProvince.SelectedIndex + 1;
buyerEntity.Address = txtAddress.Text;
buyerEntity.Remark = txtRemark.Text;
int k = objBuyerAccess.AddBuyerInfo(buyerEntity);
if (k != 0)
{
//MessageBox.Show("添加成功", "提示");
//插入操作日志
JobInfoAccess obj = new JobInfoAccess();
int ac = obj.AddJobInfo(Program.strName, DateTime.Now.ToString(), "插入宾客信息", 0);
if (ac == 0)
{
MessageBox.Show("插入操作日志失败!");
}
}
else
{
MessageBox.Show("添加失败!", "提示");
return;
}
}
//开房
//获取客户选定的房间
ArrayList arr=new ArrayList();
for(int i=0;i<lsbUseRoom.Items.Count;i++)
{
arr.Add(lsbUseRoom.Items[i].ToString().Trim().Substring(0,5));
}
string sss = DateTime.Now.ToString("yyyy-MM-dd");
foreach(string room in arr)
{
SqlParameter[] paraRoom ={
new SqlParameter("@Buyer",int.Parse(txtBuyerNum.Text.Trim())),
new SqlParameter("@GuesRoomID",room),
new SqlParameter("@ArriveTime",DateTime.Now.ToString("yyyy-MM-dd")),
new SqlParameter("@InTime",int.Parse(txtHow.Text.Trim())),
new SqlParameter("@CountMode",lblHow.Text.Trim()),
new SqlParameter("@charge",txtRoomCharge.Text.Trim()),
new SqlParameter("@otherExpenses","0"),
new SqlParameter("@InForegift",txtDeposit.Text.Trim()),
new SqlParameter("@OutForegift","0"),
new SqlParameter("@BNum",int.Parse(cboCount.Text.Trim())),
new SqlParameter("@ConsumeID",cboMode.SelectedIndex+1),
new SqlParameter("@Rebate",float.Parse(txtRebate.Text.Trim())),
new SqlParameter("@OpenUser",txtUser.Text.Trim()),
new SqlParameter("@FillTime",DateTime.Now.ToString("yyyy-MM-dd")),
new SqlParameter("@EndCharge",float.Parse(txtEndCharge.Text.Trim())),
new SqlParameter("@State","正在消费"),
new SqlParameter("@UserID",txtUser.Text.Trim()),
new SqlParameter("@ReckoningTime",DateTime.Now.ToString("yyyy-MM-dd")),
new SqlParameter("@Remark","无")};
objRoomUseAccess = new RoomUseAccess();
int a= objRoomUseAccess.AddRoomUseInfo(paraRoom);
if (a == 0)
{
MessageBox.Show("添加失败!");
return;
}
else
{
MessageBox.Show("添加成功!");
//插入操作日志
JobInfoAccess obj = new JobInfoAccess();
int ac = obj.AddJobInfo(Program.strName, DateTime.Now.ToString(), txtBuyerNum.Text.Trim() + "散客开单", float.Parse(txtEndCharge.Text.Trim()));
if (ac == 0)
{
MessageBox.Show("插入操作日志失败!");
}
}
//修改房间状态
objGuestRoomAccess = new GuestRoomAccess();
int sta= objGuestRoomAccess.ModifiRoomState(room, "使用");
if (sta == 0)
{
MessageBox.Show("出错误!","提示");
}
this.Close();//添加完后关闭
}
}
//通过证件号码搜客户信息
private void btnFind_Click(object sender, EventArgs e)
{
if (txtCardNum.Text.Trim().Equals(""))
{
MessageBox.Show("请输入证件号码!","提示");
return;
}
string str = txtCardNum.Text.Trim();
objBuyerAccess = new BuyerAccess();
ds = new DataSet();
ds= objBuyerAccess.GetBuyerInfo(str);
if (ds.Tables[0].Rows.Count==0)
{
MessageBox.Show("没有找到!","提示");
lear = true;
return;
}
//将搜到的值添加到界面
txtBuyerNum.Text = ds.Tables[0].Rows[0][0].ToString();
txtBuyerName.Text = ds.Tables[0].Rows[0][1].ToString();
dtpBirthday.Text = ds.Tables[0].Rows[0][2].ToString();
cboCardType.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][3].ToString()) - 1;
txtCardNum.Text = ds.Tables[0].Rows[0][4].ToString();
cboSex.Text = ds.Tables[0].Rows[0][5].ToString();
txtPhone.Text = ds.Tables[0].Rows[0][6].ToString();
txtCompany.Text = ds.Tables[0].Rows[0][7].ToString();
cboNationality.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][8].ToString()) - 1;
cboProvince.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][9].ToString()) - 1;
txtAddress.Text = ds.Tables[0].Rows[0][10].ToString();
txtRemark.Text = ds.Tables[0].Rows[0][12].ToString();
lear = false;
}
//按姓名查找
public static ArrayList li = new ArrayList();
public static string card = "";
private void btnFindName_Click(object sender, EventArgs e)
{
//验证是否为空
if (txtBuyerName.Text.Trim().Equals(""))
{
MessageBox.Show("请输入宾客姓名!","提示");
return;
}
string str = txtBuyerName.Text.Trim();
ds = new DataSet();
//调用按姓名查找的方法
ds = objBuyerAccess.GetBuyerDS(str);
if (ds.Tables[0].Rows.Count > 1)
{
li.Clear();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
li.Add(ds.Tables[0].Rows[i][4].ToString());
}
frmSelect frm = new frmSelect();
frm.ShowDialog();
ds = new DataSet();
//调用按证件号码查找的方法
ds = objBuyerAccess.GetBuyerInfo(card);
txtBuyerNum.Text = ds.Tables[0].Rows[0][0].ToString();
txtBuyerName.Text = ds.Tables[0].Rows[0][1].ToString();
dtpBirthday.Text = ds.Tables[0].Rows[0][2].ToString();
cboCardType.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][3].ToString()) - 1;
txtCardNum.Text = ds.Tables[0].Rows[0][4].ToString();
cboSex.Text = ds.Tables[0].Rows[0][5].ToString();
txtPhone.Text = ds.Tables[0].Rows[0][6].ToString();
txtCompany.Text = ds.Tables[0].Rows[0][7].ToString();
cboNationality.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][8].ToString()) - 1;
cboProvince.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][9].ToString()) - 1;
txtAddress.Text = ds.Tables[0].Rows[0][10].ToString();
txtRemark.Text = ds.Tables[0].Rows[0][12].ToString();
lear = false;
}
else if (ds.Tables[0].Rows.Count == 1)
{
txtBuyerNum.Text = ds.Tables[0].Rows[0][0].ToString();
txtBuyerName.Text = ds.Tables[0].Rows[0][1].ToString();
dtpBirthday.Text = ds.Tables[0].Rows[0][2].ToString();
cboCardType.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][3].ToString()) - 1;
txtCardNum.Text = ds.Tables[0].Rows[0][4].ToString();
cboSex.Text = ds.Tables[0].Rows[0][5].ToString();
txtPhone.Text = ds.Tables[0].Rows[0][6].ToString();
txtCompany.Text = ds.Tables[0].Rows[0][7].ToString();
cboNationality.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][8].ToString()) - 1;
cboProvince.SelectedIndex = int.Parse(ds.Tables[0].Rows[0][9].ToString()) - 1;
txtAddress.Text = ds.Tables[0].Rows[0][10].ToString();
txtRemark.Text = ds.Tables[0].Rows[0][12].ToString();
lear = false;
}
else
{
MessageBox.Show("这位宾客还没有登记过!","提示");
lear = true;
}
}
//刷新费用
private void lblResert_Click(object sender, EventArgs e)
{
CountPrice(lblHow.Text.Trim(), lblRoomType.Text.Trim());
}
private void cboNationality_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboNationality.SelectedIndex != 0)
cboProvince.Visible = false;
else
cboProvince.Visible = true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -