⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkout.aspx.cs

📁 酒店管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


public partial class checkOut : System.Web.UI.Page
{
    CheckOutDB checkoutDB;
    int ColNo;
    int RowNo;


    //static TextBox[] textpenalty;
    protected void Page_Load(object sender, EventArgs e)
    {
            

            if (IsPostBack)
            {
                if (CheckOutDB.staticInfo!=null)
                {
                    reload();
                }
            }
            if(!IsPostBack)
            {
                checkoutDB = new CheckOutDB();

                checkoutDB.Init();
                OKBtn.Enabled = false;
                ViewState.Clear();
            }
    }


    protected void LinkButton1_Click(object sender, EventArgs e)
    {

        int count = CheckOutDB.staticInfo.Rows.Count;
        //update
        try
        {
            for (int i = 0; i < count; i++)
            {

                if (((CheckBox)this.FindControl("tocheckout" + i)).Checked)
                {
                    int stayInfoID = int.Parse(StayInfomationView.Rows[i + 1].Cells[5].Text);

                    //checkoutDB.CheckOutUpdate(txtPenalty.Text = StayInfomationView.Rows[0].Cells[0].Text);
                    float inputPenalty = (float)(double.Parse(((TextBox)this.FindControl("penaltybox" + i)).Text));
                    float pay = (float)(double.Parse(StayInfomationView.Rows[i + 1].Cells[1].Text)
                        * double.Parse(StayInfomationView.Rows[i + 1].Cells[4].Text));
                    CheckOutDB checkoutDB = new CheckOutDB();
                    checkoutDB.Init();
                    if (RBIsGroup.Checked == true)
                    {
                        checkoutDB.CheckOutUpdate(2, stayInfoID, inputPenalty, pay);
                    }
                    else
                    {
                        checkoutDB.CheckOutUpdate(1, stayInfoID, inputPenalty, pay);

                    }
                }

            }
        }
        catch
        {
            new MessageBox(this).Show("出现错误 ");
        }

        //new MessageBox(this).Show("退房成功");
        Response.Redirect("checkOut.aspx");

    }
    protected void RRBIsClient_CheckedChanged(object sender, EventArgs e)
    {

            Label1.Text = "身份证";

    }
    protected void RBIsGroup_CheckedChanged(object sender, EventArgs e)
    {
        Label1.Text = "公司名";
        //LabName.Visible = false;
        //TextName.Visible = false;
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ViewState.Clear();          //从当前存储的东西中移出所有的state
        RRBIsClient.Enabled = false;
        RBIsGroup.Enabled = false;
        OKBtn.Enabled = true;
        if (RRBIsClient.Checked == true)        //如果是个人
        {
            TextName.Text = addRecord(1);
        }
        if(RBIsGroup.Checked==true)                                    //如果是团队
        {
            TextName.Text = addRecord(2);

        }
        if (TextName.Text == "")
        {
            RRBIsClient.Enabled = true;
            RBIsGroup.Enabled = true;
            OKBtn.Enabled = false;
            LinkButton1.Enabled = false;

            new MessageBox(this).Show("用户不存在");
        }

        TextName.Enabled = false;
        TextIDNo.Enabled = false;

        Button1.Enabled = false;
    }

    public string addRecord(int type)
    {
        ViewState.Clear();
        checkoutDB = new CheckOutDB();
        checkoutDB.Init();

        checkoutDB.StayInfoTable(type,TextIDNo.Text);
        reload();
        return CheckOutDB.cusinfo.CustomerName;

    }



    public void reload()
    {
        DataTable InfoTable = new DataTable();
        InfoTable = CheckOutDB.staticInfo;

        ColNo = InfoTable.Columns.Count;
        RowNo = InfoTable.Rows.Count;

        for (int i = 0; i < RowNo; i++)
        {
            TableRow tempRow = new TableRow();
            tempRow.EnableViewState = false;

            TableCell tempCell;
            for (int j = 0; j < ColNo - 3; j++)
            {
                tempCell = new TableCell();
                tempCell.Text = InfoTable.Rows[i][j].ToString();
                tempRow.Cells.Add(tempCell);


            }

            TableCell tempCell1 = new TableCell();
            TextBox penaltybox = new TextBox();
            tempCell1.Controls.Add(penaltybox);
            penaltybox.ID = "penaltybox" + i;
            penaltybox.Width = 30;


            tempRow.Cells.Add(tempCell1);

            TableCell tempCell2 = new TableCell();
            CheckBox tocheckout = new CheckBox();
            tocheckout.EnableViewState = true;
            tocheckout.ID = "tocheckout" + i;
 
            //tocheckout.AutoPostBack = true;
            tempCell2.Controls.Add(tocheckout);
            tempRow.Cells.Add(tempCell2);


            StayInfomationView.Rows.Add(tempRow);
            if (!((CheckBox)this.FindControl("tocheckout" + i)).Checked)
            {
                ((TextBox)this.FindControl("penaltybox" + i)).Text = "0";
            }
        }
    }


    protected void StayInfoList_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
    protected void OKBtn_Click(object sender, EventArgs e)
    {

        
    }
    protected void TextBox2_TextChanged(object sender, EventArgs e)
    {

    }
    protected void TextIDNo_TextChanged(object sender, EventArgs e)
    {

    }
    protected void OKBtn_Click1(object sender, EventArgs e)
    {

        DataTable InfoTable = new DataTable();
        LinkButton1.Enabled = true;

        InfoTable = CheckOutDB.staticInfo;

        TextPenalty.Text = "0";
        txttotal.Text = "0";
        txttotaldeposit.Text = "0";

        for (int i = 0; i < InfoTable.Rows.Count; i++)
        {

            if (((CheckBox)this.FindControl("tocheckout" + i)).Checked)
            {

                //checkoutDB.CheckOutUpdate(txtPenalty.Text = StayInfomationView.Rows[0].Cells[0].Text);
                TextPenalty.Text = Convert.ToString(double.Parse(TextPenalty.Text) +
                    double.Parse(((TextBox)this.FindControl("penaltybox" + i)).Text));
                txttotal.Text = Convert.ToString(double.Parse(txttotal.Text) + double.Parse(StayInfomationView.Rows[i + 1].Cells[1].Text)
                    * double.Parse(StayInfomationView.Rows[i + 1].Cells[4].Text));
                txttotaldeposit.Text =Convert.ToString( double.Parse(txttotaldeposit.Text)+
                    double.Parse(InfoTable.Rows[i][8].ToString()));
            }


        }
        double totalsub = double.Parse(txttotal.Text)+double.Parse(TextPenalty.Text) - double.Parse(txttotaldeposit.Text);
        if (totalsub < 0)
        {
            labbackmoney.Text = "退款";
            txtaddmoney.Text = Convert.ToString(0 - totalsub);
        }
        else
        {
            labbackmoney.Text = "加收";
            txtaddmoney.Text = Convert.ToString(totalsub);
        }
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Redirect("checkOut.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -