コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Count != 0)
            {
                foreach (string name in Session.Keys)
                {
                    if (name == "Employee")
                    {
                        Employee myem = new Employee();
                        myem         = (Employee)Session[name];
                        Label30.Text = myem.EID.ToString();
                    }
                }
            }
            var empty = from a in myctx.ServiceProviders
                        where a.SupervisorID == Convert.ToInt16(Label30.Text)
                        select a;

            if (empty.Count() != 0)
            {
                var ty = empty.First();
                Label31.Text = ty.ServiceProviderType;
            }


            //ArrayList yearlist1 = new ArrayList();

            //for (int yea1 = 2019; yea1 <= 2050; yea1++)
            //{

            //    yearlist1.Add(yea1);

            //}
            //SYear.DataSource = yearlist1;
            //SYear.DataBind();

            //ArrayList monlist = new ArrayList();

            //for (int mon = 1; mon <= 12; mon++)
            //{

            //    monlist.Add(mon);

            //}
            //SMonth.DataSource = monlist;
            //SMonth.DataBind();


            //// Panel1.Visible = false;

            //ArrayList year2list = new ArrayList();

            //for (int yea = 2019; yea <= 2050; yea++)
            //{

            //    yearlist1.Add(yea);

            //}
            //Eyear.DataSource = yearlist1;
            //Eyear.DataBind();



            //ArrayList monlist1 = new ArrayList();

            //for (int mon = 1; mon <= 12; mon++)
            //{

            //    monlist.Add(mon);

            //}
            //EMonth.DataSource = monlist;
            //EMonth.DataBind();



            var elm1 = from BookCode1 in myctx.Bookings
                       orderby BookCode1.BookingCode descending
                       select BookCode1.BookingCode;

            if (elm1.Count() == 0)
            {
                Label11.Text = "BC00001";
            }

            if (elm1.Count() != 0)
            {
                var val = elm1.First();

                string s = val;
                int    i = Convert.ToInt32(s.Substring(3, 4));
                i = i + 1;
                s = i.ToString();

                if (s.Length == 1)
                {
                    Label11.Text = "BC0000" + i;
                }

                if (s.Length == 2)
                {
                    Label11.Text = "BC000" + i;
                }

                if (s.Length == 3)
                {
                    Label11.Text = "BC00" + i;
                }

                if (s.Length == 4)
                {
                    Label11.Text = "BC0" + i;
                }

                if (s.Length == 5)
                {
                    Label11.Text = "BC" + i;
                }
            }
            var executemp = from a in myctx.Employees
                            where a.EmployeeType == "Executive Secretary"
                            select new { name = a.FirstName + "  " + a.LastName, a.EID };

            if (executemp.Count() != 0)
            {
                BookingDL.DataSource     = executemp;
                BookingDL.DataTextField  = "name";
                BookingDL.DataValueField = "EID";
                BookingDL.DataBind();
            }
            //var sp2 = from a in myctx.ServiceProviders
            //          from b in myctx.Supervisors
            //          where a.SupervisorID == b.SupervisorID && a.SupervisorID==Convert.ToInt16(Label30.Text)
            //          select new { name = a.SPFirstName + "  " + a.SPLastName, a.ServiceProviderID };

            //if (sp2.Count() != 0)
            //{
            //    DropDownListSP.DataSource = sp2;
            //    DropDownListSP.DataTextField = "name";
            //    DropDownListSP.DataValueField = "ServiceProviderID";
            //    DropDownListSP.DataBind();
            //}
        }