Beispiel #1
0
        public MainWindow()
        {
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);


            InitializeComponent();
            this.Title         = "Cleaning Records ver. " + fvi.FileVersion;
            mainGrid.IsEnabled = false;


            using (var db = new PodaciContext())
            {
                var rjobs = db.RepeatJobs.Include(x => x.CleaningJobs);
                foreach (var rjob in rjobs)
                {
                    var date = DateTime.Now.Date;
                    var cj   = rjob.CleaningJobs.FirstOrDefault(x => x.Date.Date == date);
                    if (cj != null)
                    {
                        Fun.setRepeatingJobs(rjob.Id, cj);
                    }
                }
            }

            mainGrid.IsEnabled = true;
            CalendarUserControl x2 = new CalendarUserControl();

            x2.Visibility = Visibility.Collapsed;
            DisplayGrid.Children.Add(x2);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name + "<br/>");
            //Dynamc UserControl
            CalendarUserControl CuC = (CalendarUserControl)LoadControl("~/UserControls/CalendarUserControl.ascx");

            CuC.ID = "CU1";
            PlaceHolder1.Controls.Add(CuC);
            CuC.DateSelected += new DateSelectedEventHandler(CuC_DateSelected);
            Panel1.Controls.Add(LoadControl("~/UserControls/CalendarUserControl.ascx"));

            if (Application["UsersOnline"] != null)
            {
                Response.Write("Number of Users Online = " +
                               Application["UsersOnline"].ToString() + "<br/>");
            }
            TextBox2.Focus();
            HyperLink2.Focus();
            if (!IsPostBack)
            {
                if (Request.Browser.Cookies)
                {
                    if (Request.QueryString["CheckCookie"] == null)
                    {
                        // Create the test cookie object
                        HttpCookie cookie = new HttpCookie("TestCookie", "1");
                        Response.Cookies.Add(cookie);
                        // Redirect to the same webform
                        Response.Redirect("WebForm1.aspx?CheckCookie=1");
                    }
                    else
                    {
                        //Check the existence of the test cookie
                        HttpCookie cookie = Request.Cookies["TestCookie"];
                        if (cookie == null)
                        {
                            lblCookieMessage.Text = "We have detected that, the cookies are disabled on your browser. Please enable cookies.";
                        }
                    }
                }



                LoadCityDropDownList();
                PopulateContinentsDropDownList();
                PostGraduateCheckBox.Checked = true;
                Calendar1.Visible            = false;

                checkboxListEducation.SelectedValue = "2";
                AdRotator1.KeywordFilter            = "Google";

                Response.Write("Page Loaded for the first time" + "<br/>");
                Button6.Click   += new EventHandler(Button6_Click);
                Button6.Command += new CommandEventHandler(Button6_Command);


                string CS = ConfigurationManager.ConnectionStrings["EmployeeDB"].ConnectionString;

                using (SqlConnection con = new SqlConnection(CS))
                {
                    SqlCommand cmd = new SqlCommand("select a.id as Id ,  a.Name  as City ,  b.Name as Country from tblCity a join tblCountry b  on a.CountryId = b.Id ", con);
                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    DropDownList2.DataSource = rdr;

                    DropDownList2.DataTextField  = "City";
                    DropDownList2.DataValueField = "Id";
                    DropDownList2.DataBind();
                }
                // EnityFramework
                using (var ctx = new DBCS())
                {
                    var cites = ctx.tblCities.ToList();;
                    DropDownList3.DataSource     = cites;
                    DropDownList3.DataTextField  = "CityName";
                    DropDownList3.DataValueField = "CityId";
                    DropDownList3.DataBind();
                }

                DataSet DS = new DataSet();
                //Read the xml data from the XML file using ReadXml() method

                DS.ReadXml(Server.MapPath("Countries.xml"));
                DropDownList4.DataTextField  = "CountryName";
                DropDownList4.DataValueField = "CountryId";
                DropDownList4.DataSource     = DS;
                DropDownList4.DataBind();
                ListItem li = new ListItem("Select", "-1");
                DropDownList4.Items.Insert(0, li);

                ddlCountries.Enabled = false;
                ddlCities.Enabled    = false;

                //----List box fill
                using (var ctx = new DBCS())
                {
                    var cites = ctx.tblCities.Select(x => x.CityName).ToList();;
                    ListBox2.DataSource = cites;
                    ListBox2.DataBind();
                }
                ///// Add to list controls  :

                AddListItems(DropDownList5);
                AddListItems(CheckBoxList1);
                AddListItems(RadioButtonList1);
                AddListItems(ListBox4);
                AddListItems(BulletedList3);
            }



            // Adding controls Dynamically

            DropDownList DDL = new DropDownList();

            DDL.ID = "DDL1";
            DDL.Items.Add("New York");
            DDL.Items.Add("New Jeresy");
            DDL.Items.Add("Washington");
            DDL.Visible = false;
            PlaceHolder2.Controls.Add(DDL);


            TextBox TB = new TextBox();

            TB.ID = "TB1";
            PlaceHolder2.Controls.Add(TB);
            TB.Visible = false;

            if (DropDownList7.SelectedValue == "TB")
            {
                TB.Visible = true;
                //DDL.Visible = false;
            }
            else if (DropDownList7.SelectedValue == "DDL")
            {
                DDL.Visible = true;
                //TB.Visible = false;
            }
        }