示例#1
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (tbXingMing.Text.Equals("") || tbFangHao.Text.Equals("") || tbShengFengZheng.Text.Equals(""))
            {
                MessageBox.Show("文本框均不能为空");
                return;
            }
            try
            {   //导入入住表
                string sql = string.Format(@"insert into CheckInTable(OrderID, UName, CarID, RoomID, CheckInTime, PreDepartureTime, Operator)
            values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", DingDan, tbXingMing.Text, tbShengFengZheng.Text, tbFangHao.Text, ruZhu, yuLi, CaoZuoYuan);
                int    a   = db.ExecuteSQLCommand(sql);
                if ((a > 0))
                {
                    string tiShi = string.Format("{0}顾客入住信息添加成功!", tbFangHao.Text);
                    MessageBox.Show(tiShi);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("新增到入住表失败");
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            finally
            {
                db.CloseConnection();
            }


            //判断是否是新顾客
            if (tbGuKe.Text.Equals("是"))
            {
                try
                {
                    //新顾客余额为0
                    string yuE = "0";
                    string sex = "";
                    if (rbNan.Checked)
                    {
                        sex = "男";
                    }
                    else
                    {
                        sex = "女";
                    }
                    //将顾客信息新增顾客表
                    string sql = string.Format(@"insert into CustomerTable(Name, CarID, Phone, Balance, Type, Sex, Age)
                                          values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", tbXingMing.Text, tbShengFengZheng.Text, tbDianHua.Text, yuE, 1, sex, tbNianLing.Text);
                    if (db.ExecuteSQLCommand(sql) > 0)
                    {
                        //新增成功
                    }
                    else
                    {
                        MessageBox.Show("顾客信息填入顾客表失败");
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
                finally
                {
                    db.CloseConnection();
                }
            }
            try
            {
                //查询房卡是否已激活
                string sql = string.Format(@"select count(*)
                                        from [dbo].[RoomIDCard]
                                        where RoomID = '{0}'", tbFangHao.Text);
                if (db.GetSingleIntValue(sql) == 0)
                {
                    //激活房卡
                    Activation at = new Activation();
                    at.FangHao = tbFangHao.Text;
                    at.ShowDialog();
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            finally
            {
                db.CloseConnection();
            }

            this.Close();
            //            try
            //            {
            //                string sql = string.Format(@"insert into RoomIDCard(RoomID, RoomCard)
            //                                            values('{0}','{1}')",FangHao,tbFangKa.Text);
            //                int a = db.ZengShanGaiCha(sql);
            //                if (a>0)
            //                {
            //                    string aaac = string.Format("激活成功!房号为:{0},房卡为:{1}",FangHao,tbFangKa.Text);
            //                    MessageBox.Show(aaac);
            //                }
            //                else
            //                {
            //                    string aaac = string.Format("{0}房卡激活失败!", FangHao);
            //                    MessageBox.Show(aaac);
            //                }
            //            }
            //            catch (Exception ee)
            //            {
            //                MessageBox.Show(ee.Message);
            //            }
            //            finally
            //            {
            //                db.GuanBi();
            //            }



            //            try
            //            {
            //                //修改房间信息
            //                string sql = string.Format(@"update OrderTable set [UName]='{0}',[Age]='{1}',[Phone]='{2}',[CustomerType]='{3}',[Address]='{4}'
            //                                                where [RoomID]='{5}'",tbXingMing.Text,tbNianLing.Text,tbDianHua.Text,cbLeiXing.Text,tbDiZhi.Text,tbFangHao.Text);
            //                int a = db.ZengShanGaiCha(sql);
            //                if (!(a>0))
            //                {
            //                    MessageBox.Show("修改失败!");
            //                }
            //            }
            //            catch (Exception ee)
            //            {
            //                MessageBox.Show(ee.Message);
            //            }
            //            finally
            //            {
            //                db.GuanBi();
            //            }
        }
示例#2
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            if (tbXingMing.Text.Equals("") || tbNianLing.Text.Equals("") || tbShengFenngZheng.Text.Equals(""))
            {
                MessageBox.Show("抱歉!请认真填写所有信息!");
                return;
            }
            if (Convert.ToDouble(tbZhaoLing.Text) < 0)
            {
                MessageBox.Show("抱歉!实付金额不足!");
                return;
            }
            if (lvYiXuang.Items.Count == 0)
            {
                MessageBox.Show("抱歉!请选择入住房间!");
                return;
            }
            string sex = "男";

            if (rbNv.Checked)
            {
                sex = "女";
            }
            //将新顾客信息新增到顾客表
            if (tbGuKe.Text.Equals("是"))
            {
                try
                {
                    //新顾客余额为0
                    string yuE = "0";
                    //将顾客信息新增顾客表
                    string sql = string.Format(@"insert into CustomerTable(Name, CarID, Phone, Balance, Type, Sex, Age)
                                values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", tbXingMing.Text, tbShengFenngZheng.Text, tbDianHua.Text, yuE, "1", sex, tbNianLing.Text);
                    if (db.ExecuteSQLCommand(sql) > 0)
                    {
                        //新增成功
                    }
                    else
                    {
                        MessageBox.Show("顾客信息填入顾客表失败");
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
                finally
                {
                    db.CloseConnection();
                }
            }
            try
            {
                //获取已选房间数
                int a       = lvYiXuang.Items.Count;
                int fangShu = 0;
                //循环输入已选房间
                for (int i = 0; i < a; i++)
                {
                    string FangJianHao = lvYiXuang.Items[i].Text.ToString();
                    try
                    {
                        string sql    = "";
                        double zheKou = 1;
                        if (tbZhiKou.Text != "不打折")
                        {
                            zheKou = Convert.ToDouble(tbZhiKou.Text.Substring(0, 1)) / 10;
                        }
                        double FangJias = Convert.ToDouble(lvYiXuang.Items[i].SubItems[2].Text);

                        //在订单表中插入相应数据
                        if (cbFuKuangFangShi.Text == "现金支付")
                        {
                            sql = string.Format(@"insert into [dbo].[OrderTable](OrderID, RoomID, UName, Age, Deposit, CheckInTime, PreDepartureTime, Phone, CustomerType, CompanyName, Remarks, State, Address, Discounts, AmountReceived, PaymentMethod, Operator, Price)
                                        values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')"
                                                , tbDingDanHao.Text, FangJianHao, tbXingMing.Text, tbNianLing.Text, "0", tpRuZhu.Text, tpYuLi.Text, tbDianHua.Text, tbLeiXing.Text, FangJias * zheKou, tbBeiZhu.Text, "新开单", tbDiZhi.Text, tbZhiKou.Text, FangJias * zheKou, cbFuKuangFangShi.Text, CaoZuoYuan, FangJias);
                        }
                        else if (cbFuKuangFangShi.Text == "账户余额")
                        {
                            sql = string.Format(@"insert into [dbo].[OrderTable](OrderID, RoomID, UName, Age, Deposit, CheckInTime, PreDepartureTime, Phone, CustomerType, CompanyName, Remarks, State, Address, Discounts, AmountReceived, PaymentMethod, Operator, Price)
                                        values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')"
                                                , tbDingDanHao.Text, FangJianHao, tbXingMing.Text, tbNianLing.Text, FangJias * zheKou, tpRuZhu.Text, tpYuLi.Text, tbDianHua.Text, tbLeiXing.Text, "0", tbBeiZhu.Text, "新开单", tbDiZhi.Text, tbZhiKou.Text, FangJias * zheKou, cbFuKuangFangShi.Text, CaoZuoYuan, FangJias);
                        }
                        else if (cbFuKuangFangShi.Text == "现金+余额")
                        {
                            double xianJins = Convert.ToDouble(tbXiangJin.Text) / lvYiXuang.Items.Count;
                            double yuEss    = Convert.ToDouble(tbYuEFuKuan.Text) / lvYiXuang.Items.Count;
                            sql = string.Format(@"insert into [dbo].[OrderTable](OrderID, RoomID, UName, Age, Deposit, CheckInTime, PreDepartureTime, Phone, CustomerType, CompanyName, Remarks, State, Address, Discounts, AmountReceived, PaymentMethod, Operator, Price)
                                        values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')"
                                                , tbDingDanHao.Text, FangJianHao, tbXingMing.Text, tbNianLing.Text, yuEss, tpRuZhu.Text, tpYuLi.Text, tbDianHua.Text, tbLeiXing.Text, xianJins, tbBeiZhu.Text, "新开单", tbDiZhi.Text, tbZhiKou.Text, xianJins + yuEss, cbFuKuangFangShi.Text, CaoZuoYuan, FangJias);
                        }


                        if (db.ExecuteSQLCommand(sql) > 0)
                        {
                            fangShu++;
                            //修改房间状态
                            sql = string.Format(@"update RoomTable set StateID = 2
                                                where RoomID ='{0}'", FangJianHao);
                            if (db.ExecuteSQLCommand(sql) == 0)
                            {
                                MessageBox.Show("修改房间状态失败,请手动修改!");
                            }
                        }
                        else
                        {
                            MessageBox.Show("入住失败!");
                        }
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                    finally
                    {
                        db.CloseConnection();
                    }
                }
                if (fangShu == a)
                {
                    MessageBox.Show("入住成功!");
                    Activation at = new Activation();
                    at.FangHao = lvYiXuang.Items[0].Text.ToString();
                    at.ShowDialog();
                    //语音提示
                    string            YuYinTiShi = string.Format("找零{0}元", tbZhaoLing.Text);
                    SpeechSynthesizer synth      = new SpeechSynthesizer();
                    synth.Speak(YuYinTiShi);
                    if (YuDingDan != null)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    Win32.AnimateWindow(this.Handle, 300, Win32.AW_HOR_POSITIVE | Win32.AW_HIDE | Win32.AW_SLIDE);
                    this.Close();
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            finally
            {
                db.CloseConnection();
            }
        }