Пример #1
0
        private void btnEnsure_Click(object sender, EventArgs e)
        {
            AutoId ai = new AutoId();

            if (ValidateInput())
            {
                string   sql;
                DBHelper db = null;
                try
                {
                    db = new DBHelper();
                    string Room_id = cboNewHouse.Text.Substring(0, cboNewHouse.Text.IndexOf(" "));
                    string R_id    = hh.GetR_id(Room_id);
                    sql = string.Format("Update Guest set R_id='{0}',Bookleave='{1}',comeDate='{3}' where G_GuestId='{2}'", R_id, dtpBookLeave.Text, lblOldDate.Tag, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    if (db.UpdateDeleteAdd(sql) > 0)
                    {
                        if (hh.IshaveBook(cboOldHouse.Text))
                        {
                            sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "预订", hh.GetR_id(cboOldHouse.Text));
                        }
                        else
                        {
                            sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "空净", hh.GetR_id(cboOldHouse.Text));
                        }
                        db.UpdateDeleteAdd(sql);

                        sql = string.Format("update Room set State='{0}' where R_id='{1}'", "待客", R_id);
                        db.UpdateDeleteAdd(sql);


                        sql = string.Format("insert into Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                                            ai.GetId("C_ConsumeId", "Consume"), lblOldDate.Tag, "换房消费", lblOldPrice.Text, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "房间消费", UserHelper.LoginId, txtRemark.Text
                                            );
                        db.UpdateDeleteAdd(sql);

                        MessageBox.Show("换房成功!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("换房失败!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    db.GetClose();
                }
            }
        }
Пример #2
0
        //退房方法
        private void ExitHouse()
        {
            //判断是否签单
            if (!Underwrite && chkCust.Checked == false)
            {
                if (txtSpare.Text == "")
                {
                    MessageBox.Show("金额不能为空!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                //金额不足不能退房
                if (Convert.ToDouble(txtSpare.Text) < 0)
                {
                    MessageBox.Show("金额不足!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPaicl.SelectAll();
                    txtPaicl.Focus();
                    return;
                }
            }

            if (chkCust.Checked == false)
            {
                if (cboUnderwrite.Text == "" && chkUnderwrite.Checked == true)
                {
                    MessageBox.Show("签单单位不能为空!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            if (!isHaveMoney() && chkUnderwrite.Checked == false && chkCust.Checked == true)
            {
                MessageBox.Show("会员余额不足本次消费!请充值!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (chkCust.Checked == true && txtPass.Text == "")
            {
                txtPass.Focus();
                return;
            }

            //辅助类实例化
            HouseHelper hh = new HouseHelper();

            int      rows = 0; //受影响的行数
            DBHelper db   = null;

            db = new DBHelper();
            string sql;

            //循环修改入住状态为空净
            for (int i = 0; i < lvFitout.Items.Count; i++)
            {
                //获得房间的R_Id
                string R_id = lvFitout.Items[i].SubItems[0].Tag.ToString();
                string time = DateTime.Now.ToString();

                if (hh.IshaveBook(R_id))
                {
                    sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "预订", R_id);
                }
                else
                {
                    sql = string.Format("update Room set State ='{0}' where R_id='{1}'", "整理", R_id);
                }

                //return;

                rows = db.UpdateDeleteAdd(sql);



                sql = string.Format("update Guest set faceDate = '{0}' where R_id = '{1}' and  (faceDate = '{2}' or faceDate is null)", time, R_id, "");
                db.UpdateDeleteAdd(sql);

                if (!Underwrite)
                {
                    //sql = string.Format("update Guest set Fact='{0}' where G_GuestId='{1}'", lblDeal.Text, lvFitout.Items[0].SubItems[0].Text);
                    //MessageBox.Show(sql);
                    //db.UpdateDeleteAdd(sql);

                    if (i == 0)
                    {
                        AutoId ai = new AutoId();

                        string money = Convert.ToString(Convert.ToDouble(lblDeal.Text) * IsAwoke.discount);

                        sql = string.Format("insert Consume values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                                            ai.GetId("C_ConsumeId", "Consume"), lvFitout.Items[0].SubItems[0].Text, "房间消费", money.ToString(), 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "1", UserHelper.LoginId, ""
                                            );
                        db.UpdateDeleteAdd(sql);
                    }
                }
                else
                {
                    AutoId ai            = new AutoId();
                    string A_Id          = ai.GetId("A_Id", "UnderwriteAnnal");
                    string Room_id       = lvFitout.Items[i].SubItems[1].Text;
                    string G_GuestId     = lvFitout.Items[i].SubItems[0].Text;
                    string Underwritestr = cboUnderwrite.Text;
                    string U_money       = lvFitout.Items[i].SubItems[7].Text;
                    string State         = "未付";
                    sql = string.Format("insert UnderwriteAnnal values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", A_Id, Room_id, G_GuestId, Underwritestr, U_money, 0, 0, 0, State, Room_id + "号房费");
                    db.UpdateDeleteAdd(sql);

                    if (i == 0)
                    {
                        sql = string.Format("update UnderwriteAnnal set U_money = U_money - '{0}' where G_GuestId='{1}'", Convert.ToDouble(lblYaJin.Text), G_GuestId);
                        db.UpdateDeleteAdd(sql);
                    }
                }
            }

            //如果是签单
            if (Underwrite)
            {
                for (int i = 0; i < lvConsume.Items.Count; i++)
                {
                    AutoId ai            = new AutoId();
                    string A_Id          = ai.GetId("A_Id", "UnderwriteAnnal");
                    string Room_id       = lvFitout.Items[0].SubItems[1].Text;
                    string G_GuestId     = lvFitout.Items[0].SubItems[0].Text;
                    string Underwritestr = cboUnderwrite.Text;
                    string U_money       = lvConsume.Items[i].SubItems[4].Text;
                    string State         = "未付";
                    string Remark        = lvConsume.Items[i].SubItems[0].Text;
                    sql = string.Format("insert UnderwriteAnnal values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')", A_Id, Room_id, G_GuestId, Underwritestr, U_money, 0, 0, 0, State, Remark);
                    db.UpdateDeleteAdd(sql);
                }
            }

            //判断是否是会员
            if (chkCust.Checked)
            {
                db = new DBHelper();
                double score = Convert.ToDouble(lblDeal.Text) / 100;
                sql = string.Format("update Users set Score = Score + '{0}',U_money = U_money -'{1}' where U_UsersId='{2}' ", score, lblDeal.Text, lblU_UserId.Text);
                db.UpdateDeleteAdd(sql);
            }


            if (rows > 0)
            {
                MessageBox.Show("退房成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("退房失败", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }