//Returns a list of all orders placed in textboxes private ArrayList GetOrders() { //Get list of Textbox objects in ContentPlaceHolder ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.FindChildControlsRecursive(cph); var textBoxList = cf.FoundControls; //Create orders using data from textfields ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { //Make sure textbox.Text is not null if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); //Generate Order for each textbox which has an order greater than 0 if (amountOfOrders > 0) { Coffee coffee = ConnectionClass.GetCoffeeById(Convert.ToInt32(textBox.ID)); Order order = new Order( Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); //Add order to ArrayList orderList.Add(order); } } } return(orderList); }
private bool IsMinAge() { if (Config.MinAge > 0) { //find the Date of birth control var cfinder = new ControlFinder<DobPicker>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var vfinder = new ControlFinder<RequiredFieldValidator>(); vfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var dobCtl = cfinder.FoundControls.SingleOrDefault(c => c.ID == "DateOfBirth"); if (dobCtl != null) { if (Convert.ToInt32(Common.GetAgeFromDOB(dobCtl.DOBStr)) < Config.MinAge) { RequiredFieldValidator req = new RequiredFieldValidator { ValidationGroup = CreateUserWizard1.ID, ErrorMessage = String.Format( webResources.lblMinAge, Config.MinAge), IsValid = false }; Page.Validators.Add(req); //req.Visible = false; return false; } } return Convert.ToInt32(Common.GetAgeFromDOB(dobCtl.DOBStr)) > Config.MinAge; } return true; }
private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.FindChildControlsRecursive(cph); var textBoxList = cf.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { TblMovies movies = Mothercode.GetMoviesById(Convert.ToInt32(textBox.ID)); Order order = new Order( Session["New"].ToString(), movies.MovieName, amountOfOrders, movies.TotalPrice, DateTime.Now, false); orderList.Add(order); } } } return(orderList); }
//Returns a list of all orders placed in textboxes private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cF = new ControlFinder <TextBox>(); cF.FindChildControlsRecursive(cph); IEnumerable <TextBox> textBoxList = cF.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { Coffee coffee = ConnectionClass.GetCoffeeByID(Convert.ToInt32(textBox.ID)); Order order = new Order(Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); orderList.Add(order); } } } return(orderList); }
protected void CreateUserWizard1CreatedUser(object sender, EventArgs e) { var newMember = Members.GetMember(CreateUserWizard1.UserName); XElement root = _memberFields.Root; var properties = RegHelper.GetProperties(newMember); var fields = root.Elements().Where(a => a.Attribute("Show").Value == "true" && a.Attribute("Group").Value == "Member"); foreach (XElement field in fields) { var prop = properties.SingleOrDefault(p => p.Name == field.Name); Registration attr = (Registration)prop.GetCustomAttributes(false)[0]; switch (attr.Control) { case "Text" : case "LongText": var tfinder = new ControlFinder<TextBox>(); tfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var tinfo = tfinder.FoundControls.ToList(); if (tinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(tinfo.Single(t => t.ID == field.Name).Text, prop.PropertyType), null); break; case "DatePicker" : var dfinder = new ControlFinder<DobPicker>(); dfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var dinfo = dfinder.FoundControls.ToList(); if (dinfo.Any(t => t.ID == field.Name)) { newMember.DateOfBirth = dinfo.Single(t => t.ID == field.Name).DOBStr; newMember.Age = Common.GetAgeFromDOB(newMember.DateOfBirth); } break; case "GenderLookup" : var cfinder = new ControlFinder<GenderDropDownList>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var cinfo = cfinder.FoundControls.ToList(); if (cinfo.Any(t => t.ID == field.Name)) newMember.Gender = cinfo.Single(t => t.ID == field.Name).SelectedValue; break; } } newMember.MembersIP = Common.GetIP4Address(); newMember.LastIP = newMember.MembersIP; // Save the profile - must be done since we explicitly created this profile instance Members.SaveMember(newMember); Membership.GetUser(newMember.Username,true); }
//Returns a list of all orders placed in textboxes private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder<TextBox> cF = new ControlFinder<TextBox>(); cF.FindChildControlsRecursive(cph); IEnumerable<TextBox> textBoxList = cF.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { Coffee coffee = ConnectionClass.GetCoffeeByID(Convert.ToInt32(textBox.ID)); Order order = new Order(Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); orderList.Add(order); } } } return orderList; }
protected void SaveOptions(object sender, EventArgs e) { var newMember = Members.GetMember(CreateUserWizard1.UserName); XElement root = _memberFields.Root; var properties = RegHelper.GetProperties(newMember); var fields = root.Elements().Where(a => a.Attribute("Show").Value == "true" && a.Attribute("Group").Value != "Member"); foreach (XElement field in fields) { var prop = properties.SingleOrDefault(p => p.Name == field.Name); Registration attr = (Registration)prop.GetCustomAttributes(false)[0]; switch (attr.Control) { case "Text": case "LongText" : var tfinder = new ControlFinder<TextBox>(); tfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var tinfo = tfinder.FoundControls.ToList(); if (tinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(tinfo.Single(t => t.ID == field.Name).Text, prop.PropertyType), null); break; case "CheckBox" : var cfinder = new ControlFinder<CheckBox>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var cinfo = cfinder.FoundControls.ToList(); if (cinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(cinfo.Single(t => t.ID == field.Name).Checked, prop.PropertyType), null); break; case "CountryLookup" : var dfinder = new ControlFinder<CountryDropDownList>(); dfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var dinfo = dfinder.FoundControls.ToList(); if (dinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(dinfo.Single(t => t.ID == field.Name).SelectedValue, prop.PropertyType), null); break; case "TimeZoneLookup" : var tzfinder = new ControlFinder<TimeZoneListBox>(); tzfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var tzinfo = tzfinder.FoundControls.ToList(); if (tzinfo.Any(t => t.ID == field.Name)) { string tZone = tzinfo.Single(t => t.ID == field.Name).SelectedValue; prop.SetValue(newMember, Convert.ChangeType(tZone, prop.PropertyType), null); TimeZoneInfo tzoneInfo = TimeZoneInfo.FindSystemTimeZoneById(tZone); newMember.TimeOffset = tzoneInfo.BaseUtcOffset.TotalHours; } break; case "Lookup": var lfinder = new ControlFinder<DropDownList>(); lfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var linfo = lfinder.FoundControls.ToList(); if (linfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(linfo.Single(t => t.ID == field.Name).SelectedValue, prop.PropertyType), null); break; } } Members.SaveMember(newMember); }