Ejemplo n.º 1
0
    protected void PageBind()
    {
        string strBuType = string.Empty;
        List<MBL_BookInfo> LList = new List<MBL_BookInfo>();
        DataTable dt = SelectData(strBuType);
        DataSet ds = new DataSet();
        ds.Tables.Clear();
        ds.Tables.Add("showTable");
        ds.Tables["showTable"].Columns.Add("selfTeamId");//团号
        ds.Tables["showTable"].Columns.Add("peopleNum");//团队人数
        ds.Tables["showTable"].Columns.Add("Unit");//单位
        ds.Tables["showTable"].Columns.Add("HouseType");//房间类别
        ds.Tables["showTable"].Columns.Add("DateTime");//日期
        ds.Tables["showTable"].Columns.Add("Price");//单价
        ds.Tables["showTable"].Columns.Add("Num");//数量
        ds.Tables["showTable"].Columns.Add("Day");//天数
        ds.Tables["showTable"].Columns.Add("Waive");//免去
        ds.Tables["showTable"].Columns.Add("Amount");//应付
        ds.Tables["showTable"].Columns.Add("PayAmount");//已付
        ds.Tables["showTable"].Columns.Add("UserId");//计调
        ds.Tables["showTable"].Columns.Add("TRoom");//用房合计
        ds.Tables["showTable"].Columns.Add("RealityPrice");//实际价
        ds.Tables["showTable"].Columns.Add("SlotCardPrice");//刷卡价
        ds.Tables["showTable"].Columns.Add("RealityMoney");//实际总金额
        ds.Tables["showTable"].Columns.Add("SlotCardMoney");//刷卡总金额
        ds.Tables["showTable"].Columns.Add("R_S_CY");//差异
        ds.Tables["showTable"].Columns.Add("Model");//结算方式
        //ds.Tables["showTable"].Columns.Add("ANum");//地陪

        foreach (DataRow _dr in dt.Rows)
        {
            DataRow dr = ds.Tables["showTable"].NewRow();
            dr["selfTeamId"] = _dr["MyTeamNum"];
            string mytemnum = _dr["MyTeamNum"].ToString();
            magreeitem = bagreeitem.GetList(Convert.ToInt64(_dr["AGIID"]));
            dr["Unit"] = _dr["SupplierName"] + "(" + _dr["SupplierCode"].ToString() + ")";
            dr["HouseType"] = bdcbll.GetList(magreeitem.ItemTypeID).CName;
            dr["DateTime"] = string.Format("{0:yyyy-MM-dd}", _dr["BeginDate"]);
            dr["Price"] = String.Format("{0:n}", _dr["BookTotalPrice"]);
            //AdultNum是Teaminfo中的成人数,bookinfo中的实际人数是AdultNumber
            //dr["Num"] = _dr["AdultNum"].ToString() + "+" + _dr["ChildNum"].ToString() + "/2";
            dr["Num"] = _dr["AdultNumber"].ToString() + "+" + _dr["ChildNumber"].ToString() + "/2";
           // dr["ANum"] = _dr["AccompanyNum"].ToString();
            dr["Day"] = (Convert.ToDateTime(_dr["EndDate"].ToString()) - Convert.ToDateTime(_dr["BeginDate"].ToString())).Days.ToString();
            dr["Waive"] = _dr["ExceptNum"];
            dr["Amount"] = string.Format("{0:n}", _dr["BookTotalPrice"]);
            dr["UserId"] = _dr["UserName"];
            dr["TRoom"] = Convert.ToSingle(_dr["BookNumber"]) * Convert.ToSingle(dr["Day"]);
            dr["RealityPrice"] = bllhelper.GetAgreeItemPriceDateSpan(magreeitem.AGIID.ToString(), Convert.ToDateTime(_dr["BeginDate"].ToString()), Convert.ToDateTime(_dr["BeginDate"].ToString()), magreeitem.CouterByTimeSpan, 1);
            dr["SlotCardPrice"] = _dr["BookTotalPrice"];
            dr["RealityMoney"] = ((Convert.ToDecimal(_dr["BookTotalPrice"]) > 0) ? _dr["BookTotalPrice"] : co.ReturnBookTotalPrice(bhBll.GetList(int.Parse(_dr["BID"].ToString())), true));
            dr["SlotCardMoney"] = _dr["BookTotalPrice"];
            dr["Model"] = bdcbll.GetList(Convert.ToInt32(_dr["FKTypeID"])).CName;
            ds.Tables["showTable"].Rows.Add(dr);
        }
        if (!CheckBox_TeamNum.Checked)//未选中团号
        {
            DataSet dstemp = ds.Clone();
            DataRow[] drarray = ds.Tables["showTable"].Select("1=1", "Unit,HouseType");
            string Unit = "";
            string HouseType = "";
            bool recouter = false;
            decimal Price = 0;
            decimal Num = 0;
            decimal NumAdult = 0;
            decimal NumChild = 0;
            decimal Day = 0;
            decimal Waive = 0;
            decimal Amount = 0;
            decimal TRoom = 0;
            foreach (DataRow dr in drarray)
            {
                if (recouter)
                {
                    if (CheckBox_MealName.Checked)
                    {
                        if (Unit != dr["Unit"].ToString() || HouseType != dr["HouseType"].ToString())
                        {
                            DataRow dr1 = dstemp.Tables["showTable"].NewRow();

                            dr1["Unit"] = Unit;
                            dr1["HouseType"] = HouseType;
                            dr1["Price"] = Price;
                            dr1["Num"] = NumAdult + "+" + NumChild + "/2";
                            dr1["Day"] = Day;
                            dr1["Waive"] = Waive;
                            dr1["Amount"] = Amount;
                            dr1["TRoom"] = TRoom;
                            dr1["RealityMoney"] = Price;

                            dstemp.Tables["showTable"].Rows.Add(dr1);
                            Unit = "";
                            HouseType = ""; ;
                            Price = 0;
                            Num = 0;
                            Day = 0;
                            Waive = 0;
                            Amount = 0;
                            TRoom = 0;
                            recouter = false;
                            //成人数和儿童人数需要清零
                            NumAdult = 0;
                            NumChild=0;
                        }
                    }
                    else
                    {
                        if (Unit != dr["Unit"].ToString())
                        {
                            DataRow dr1 = dstemp.Tables["showTable"].NewRow();
                            dr1["Unit"] = Unit;
                            dr1["HouseType"] = HouseType;
                            dr1["Price"] = Price;
                            dr1["Num"] = NumAdult + "+" + NumChild + "/2";
                            dr1["Day"] = Day;
                            dr1["Waive"] = Waive;
                            dr1["Amount"] = Amount;
                            dr1["TRoom"] = TRoom;
                            dr1["RealityMoney"] = Price;
                            dstemp.Tables["showTable"].Rows.Add(dr1);
                            Unit = "";
                            HouseType = ""; ;
                            Price = 0;
                            Num = 0;
                            Day = 0;
                            Waive = 0;
                            Amount = 0;
                            TRoom = 0;
                            recouter = false;
                            //成人数和儿童人数需要清零
                            NumAdult = 0;
                            NumChild = 0;
                        }
                    }
                }

                if (!recouter)
                {
                    if (CheckBox_MealName.Checked)
                    {
                        if (Unit == "" || HouseType == "")
                        {
                            Unit = dr["Unit"].ToString();
                            HouseType = dr["HouseType"].ToString();
                        }
                        recouter = true;
                    }
                    else
                    {
                        if (Unit == "")
                        {
                            Unit = dr["Unit"].ToString();
                        }
                        recouter = true;
                    }
                }
                Price += Convert.ToDecimal(dr["Price"].ToString());
                string[] numstring = dr["Num"].ToString().Split('+');
                //以下两个参数需要清零
                NumAdult += Convert.ToDecimal(numstring[0]);
                NumChild += Convert.ToDecimal(numstring[1].Replace("/2", ""));
                Day += Convert.ToDecimal(dr["Day"]);
                Waive += Convert.ToDecimal(dr["Waive"]);
                Amount += Convert.ToDecimal(dr["Amount"]);
                TRoom += Convert.ToDecimal(dr["TRoom"]);
            }
            if (recouter)
            {
                DataRow dr1 = dstemp.Tables["showTable"].NewRow();
                dr1["Unit"] = Unit;
                dr1["HouseType"] = HouseType;
                dr1["Price"] = Price;
                dr1["Num"] = NumAdult + "+" + NumChild + "/2";
                dr1["Day"] = Day;
                dr1["Waive"] = Waive;
                dr1["Amount"] = Amount;
                dr1["TRoom"] = TRoom;
                dr1["RealityMoney"] = Price;
                dstemp.Tables["showTable"].Rows.Add(dr1);
            }
            Session["PrintTable"] = dstemp;
            gvinfo.DataSource = dstemp;
            gvinfo.DataBind();
        }
        else
        {
            Session["PrintTable"] = ds;
            gvinfo.DataSource = ds;
        }
        gvinfo.DataBind();

        //汇总
        string peopleNumJoin = string.Empty;
        float NumJoin = 0;
        //double WaiveNumJoin = 0;
        //decimal PayMentAmount = 0.00M;
        //decimal PaidAmount = 0.00M;
        //decimal NotPayAmount = 0.00M;

        foreach (GridViewRow row in gvinfo.Rows)
        {
            Label ppnj = row.FindControl("GroupNum") as Label;
            Label nj = row.FindControl("Num") as Label;
            Label pma = row.FindControl("Amount") as Label;
            Label pa = row.FindControl("PayAmount") as Label;
            Label npa = row.FindControl("NotAmount") as Label;
            string[] temparray = nj.Text.Trim().Split('+');
            float numjoin = Convert.ToSingle(temparray[0].ToString().Equals("") ? "0" : temparray[0].ToString()) + Convert.ToSingle(temparray[1].ToString().Replace("/2", ""));
            //decimal paymentamount = Convert.ToDecimal(pma.Text.Trim());
            //decimal paidamount = Convert.ToDecimal(pa.Text.Trim());
            //decimal notpayamount = paidamount - paymentamount;

            NumJoin += numjoin;
            //PayMentAmount += paymentamount;
            //PaidAmount += paidamount;
            //npa.Text = notpayamount>=0?notpayamount.ToString():"<font color=#ff0000>"+notpayamount.ToString()+"</font>";
            //NotPayAmount += notpayamount;

            Label nt = gvinfo.FooterRow.FindControl("NumTotal") as Label;
            Label at = gvinfo.FooterRow.FindControl("AmountTotal") as Label;
            Label pat = gvinfo.FooterRow.FindControl("PayAmountTotal") as Label;
            Label nat = gvinfo.FooterRow.FindControl("NotAmountTotal") as Label;

            nt.Text = NumJoin.ToString();

            //at.Text = PayMentAmount.ToString();
            //pat.Text = PaidAmount.ToString();
            //nat.Text = NotPayAmount >= 0 ? NotPayAmount.ToString() : "<font color=#ff0000>" + NotPayAmount.ToString() + "</font>";

            Label _lbl_TRealityMoney = gvinfo.FooterRow.FindControl("lbl_TRealityMoney") as Label;
            _lbl_TRealityMoney.Text = (Convert.ToDecimal(_lbl_TRealityMoney.Text) + Convert.ToDecimal((row.FindControl("lblRealityMoney") as Label).Text)).ToString();

        }
    }
Ejemplo n.º 2
0
 private decimal BookValue(string TIDString)
 {
     bookvalue = 0;
     if (TIDString.Length > 0)
     {
         int couter = 0;
         IList<MBL_BookInfo> booklist = bbook.GetListsByFilterString("TID in (" + TIDString + ")");
         foreach (MBL_BookInfo mbook in booklist)
         {
             tempvalue = 0;
             if (mbook.BookTotalPrice == 0)
             {
                 magreeitem = bagreeitem.GetList(mbook.AGIID);
                 switch (mbook.CID)
                 {
                     case 4:
                         carlist = bcardetail.GetListsByFilterString("BID=" + mbook.BID);
                         foreach (MBL_BookCarDetail mcar in carlist)
                         {
                             tempvalue += mcar.Days * mcar.PriceNum;
                         }
                         break;
                     case 8:
                         guidelist = bguidedetal.GetListsByFilterString("BID=" + mbook.BID);
                         foreach (MBL_BookGuideDetail mguidedetail in guidelist)
                         {
                             tempvalue += mguidedetail.Fee;
                         }
                         break;
                     case 10:
                         yanyiticketlist = byanyiticket.GetListsByFilterString("BID=" + mbook.BID);
                         foreach (MBL_BookYanYiTicketDetail myanyiticket in yanyiticketlist)
                         {
                             tempvalue += myanyiticket.AdultFee * mbook.AdultNumber;
                         }
                         break;
                     default:
                         tempvalue = Convert.ToDecimal(bllhelper.ReturnItemPrice(magreeitem.CouterByPeople, magreeitem.EnableDiscount, mbook.AGID, mbook.AGIID.ToString(), mbook.BeginDate, mbook.EndDate.AddDays(-1), mbook.BookNumber, mbook.AdultNumber, mbook.ChildNumber, magreeitem.ChildDiscount, ref reducenumber, magreeitem.CouterByTimeSpan).Replace("¥", ""));
                         break;
                 }
                 mbook.BookTotalPrice = tempvalue;
                 bbook.Modify(mbook);
                 bookvalue += tempvalue;
             }
             else
             {
                 bookvalue += mbook.BookTotalPrice;
             }
             couter++;
         }
     }
     return bookvalue;
 }