示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ActiveTable.ValidFrom = DateTime.ParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            ActiveTable.Trip      = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue));
            if (ActiveTable.Trip.NumberOfOptions > 1)
            {
                ActiveTable.Option = (TripOption)ddlOptions.SelectedIndex;
            }
            else
            {
                ActiveTable.Option = TripOption.Option1;
            }
            Module.SaveOrUpdate(ActiveTable);

            foreach (RepeaterItem item in rptServices.Items)
            {
                HiddenField    hiddenType = (HiddenField)item.FindControl("hiddenType");
                HiddenField    hiddenId   = (HiddenField)item.FindControl("hiddenId");
                Domain.Costing cost;
                if (!string.IsNullOrEmpty(hiddenId.Value) && Convert.ToInt32(hiddenId.Value) > 0)
                {
                    cost = Module.CostingGetById(Convert.ToInt32(hiddenId.Value));
                }
                else
                {
                    cost = new Domain.Costing();
                }
                TextBox txtAdult = (TextBox)item.FindControl("txtAdult");
                TextBox txtChild = (TextBox)item.FindControl("txtChild");
                TextBox txtBaby  = (TextBox)item.FindControl("txtBaby");

                cost.Adult = Convert.ToDouble(txtAdult.Text);
                cost.Child = Convert.ToDouble(txtChild.Text);
                cost.Baby  = Convert.ToDouble(txtBaby.Text);

                foreach (CostType type in CostingList)
                {
                    if (type.Id == Convert.ToInt32(hiddenType.Value))
                    {
                        cost.Type = type;
                    }
                }

                cost.Table = ActiveTable;
                Module.SaveOrUpdate(cost);
            }

            PageRedirect(string.Format("Costing.aspx?NodeId={0}&SectionId={1}&TableId={2}", Node.Id, Section.Id, ActiveTable.Id));
        }
示例#2
0
        protected void rptServices_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is CostType)
            {
                CostType type    = (CostType)e.Item.DataItem;
                Literal  litName = e.Item.FindControl("litName") as Literal;
                if (litName != null)
                {
                    litName.Text = type.Name;
                }
                HiddenField hiddenType = e.Item.FindControl("hiddenType") as HiddenField;
                if (hiddenType != null)
                {
                    hiddenType.Value = type.Id.ToString();
                }
            }

            if (e.Item.DataItem is Domain.Costing)
            {
                Domain.Costing cost     = (Domain.Costing)e.Item.DataItem;
                HiddenField    hiddenId = (HiddenField)e.Item.FindControl("hiddenId");
                hiddenId.Value = cost.Id.ToString();
                Literal litName = e.Item.FindControl("litName") as Literal;
                if (litName != null)
                {
                    litName.Text = cost.Type.Name;
                }
                HiddenField hiddenType = e.Item.FindControl("hiddenType") as HiddenField;
                if (hiddenType != null)
                {
                    hiddenType.Value = (cost.Type.Id).ToString();
                }

                TextBox txtAdult = (TextBox)e.Item.FindControl("txtAdult");
                TextBox txtChild = (TextBox)e.Item.FindControl("txtChild");
                TextBox txtBaby  = (TextBox)e.Item.FindControl("txtBaby");

                txtAdult.Text = cost.Adult.ToString("0");
                txtChild.Text = cost.Child.ToString("0");
                txtBaby.Text  = cost.Baby.ToString("0");
            }
        }