Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime  tnow   = DateTime.Now;//现在时间
            ArrayList AlYear = new ArrayList();
            int       i;

            for (i = 2019; i >= 1960; i--)
            {
                AlYear.Add(i);
            }
            ArrayList AlMonth = new ArrayList();

            for (i = 1; i <= 12; i++)
            {
                AlMonth.Add(i);
            }
            if (!this.IsPostBack)
            {
                DropDownListYear.DataSource = AlYear;
                DropDownListYear.DataBind(); //绑定年
                                             //选择当前年
                DropDownListYear.SelectedValue = tnow.Year.ToString();
                DropDownListMonth.DataSource   = AlMonth;
                DropDownListMonth.DataBind(); //绑定月
                                              //选择当前月
                DropDownListMonth.SelectedValue = tnow.Month.ToString();
                int year, month;
                year  = Int32.Parse(DropDownListYear.SelectedValue);
                month = Int32.Parse(DropDownListMonth.SelectedValue);
                BindDays(year, month); //绑定天
                                       //选择当前日期
                DropDownListDay.SelectedValue = tnow.Day.ToString();
            }
        }
 public void bindYear()
 {
     try
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
         con.Open();
         DataTable      dt  = new DataTable();
         SqlCommand     cmd = new SqlCommand("Select Distinct YEAR from DAARREARS$", con);
         SqlDataAdapter da  = new SqlDataAdapter(cmd);
         da.Fill(dt);
         con.Close();
         DropDownListYear.DataSource     = dt;
         DropDownListYear.DataValueField = "YEAR";
         DropDownListYear.DataBind();
         DropDownListYear.Items.Insert(0, new ListItem("Select", ""));
     }
     catch (Exception ee)
     {
         Response.Write("<script>alert('Error While Binding Year');</script>");
     }
     finally
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
     }
 }
        private void BindDropDownList()
        {
            try
            {
                PmsSysBiz      pmsSysBiz  = new PmsSysBiz();
                IList <PmsSys> pmsSysList = new List <PmsSys>();

                pmsSysList = pmsSysBiz.SelectData2ByTypeData1("PM", "Report", "YEAR");

                DropDownListYear.DataSource     = pmsSysList;
                DropDownListYear.DataTextField  = "data2";
                DropDownListYear.DataValueField = "data2";
                DropDownListYear.DataBind();

                DropDownListYear.Items.Insert(0, new ListItem());
                DropDownListYear.Items[0].Text  = "";
                DropDownListYear.Items[0].Value = "";


                pmsSysList = pmsSysBiz.SelectData2ByTypeData1("PM", "Report", "MONTH");

                DropDownListMonth.DataSource     = pmsSysList;
                DropDownListMonth.DataTextField  = "data2";
                DropDownListMonth.DataValueField = "data2";
                DropDownListMonth.DataBind();

                DropDownListMonth.Items.Insert(0, new ListItem());
                DropDownListMonth.Items[0].Text  = "";
                DropDownListMonth.Items[0].Value = "";


                pmsSysList = pmsSysBiz.SelectData1ByType("PM", "UserDept");

                DropDownListUserDept.DataSource     = pmsSysList;
                DropDownListUserDept.DataTextField  = "data1";
                DropDownListUserDept.DataValueField = "data1";
                DropDownListUserDept.DataBind();

                DropDownListUserDept.Items.Insert(0, new ListItem());
                DropDownListUserDept.Items[0].Text  = "";
                DropDownListUserDept.Items[0].Value = "";


                pmsSysList = pmsSysBiz.SelectData1ByType("PM", "RDDept");

                DropDownListRDDept.DataSource     = pmsSysList;
                DropDownListRDDept.DataTextField  = "data1";
                DropDownListRDDept.DataValueField = "data1";
                DropDownListRDDept.DataBind();

                DropDownListRDDept.Items.Insert(0, new ListItem());
                DropDownListRDDept.Items[0].Text  = "";
                DropDownListRDDept.Items[0].Value = "";
            }
            catch
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Bind DropDownList failure');", true);
            }
        }
Esempio n. 4
0
        protected void GetYear()
        {
            string sql = "SELECT DISTINCT GNFY_YEAR  FROM TBTM_GNFY";

            System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sql);
            DropDownListYear.DataTextField  = "GNFY_YEAR";
            DropDownListYear.DataValueField = "GNFY_YEAR";
            DropDownListYear.DataSource     = dt;
            DropDownListYear.DataBind();
        }
Esempio n. 5
0
        public void bindYear()
        {
            DataTable      dt  = new DataTable();
            SqlCommand     cmd = new SqlCommand("Select Distinct YEAR from MANUAL_BILLS$", con);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);

            cmd.CommandTimeout = 120;
            da.Fill(dt);
            con.Close();
            DropDownListYear.DataSource     = dt;
            DropDownListYear.DataValueField = "YEAR";
            DropDownListYear.DataBind();
            DropDownListYear.Items.Insert(0, new ListItem("Select", ""));
        }
Esempio n. 6
0
        protected void DropDownListYears()
        {
            DataContext db     = new DataContext();
            var         YearDD = from y in db.TblYears
                                 orderby y.Year
                                 select new
            {
                y.Year,
                y.Id,
            };

            DropDownListYear.DataSource     = YearDD;
            DropDownListYear.DataValueField = "Id";
            DropDownListYear.DataTextField  = "Year";
            DropDownListYear.DataBind();
        }
 public void bindYear()
 {
     try
     {
         DataTable      dt  = new DataTable();
         SqlCommand     cmd = new SqlCommand("Select Distinct YEAR from PAY_SLIP$", con);
         SqlDataAdapter da  = new SqlDataAdapter(cmd);
         cmd.CommandTimeout = 120;
         da.Fill(dt);
         con.Close();
         DropDownListYear.DataSource     = dt;
         DropDownListYear.DataValueField = "YEAR";
         DropDownListYear.DataBind();
         DropDownListYear.Items.Insert(0, new ListItem("Select", ""));
     }
     catch (Exception ee)
     {
         Response.Write("<script>alert('Error While Binding Year');</script>");
     }
 }
        protected void GetYear()
        {
            string sql = "SELECT DISTINCT CNJG_YEAR  FROM TBTM_CNJG";

            System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sql);
            DropDownListYear.DataTextField  = "CNJG_YEAR";
            DropDownListYear.DataValueField = "CNJG_YEAR";
            DropDownListYear.DataSource     = dt;
            DropDownListYear.DataBind();

            for (int k = 1; k <= 12; k++)
            {
                string j = k.ToString() + "月";
                if (k < 10)
                {
                    j = "0" + k.ToString() + "月";
                }
                DropDownMonth.Items.Add(new ListItem(j.ToString(), j.ToString()));
            }
            DropDownMonth.Items.Insert(0, new ListItem(" ", " "));
        }
Esempio n. 9
0
 public void bindYear()
 {
     try
     {
         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["UniversityDatabaseConnectionString"].ConnectionString);
         con.Open();
         DataTable      dt  = new DataTable();
         SqlCommand     cmd = new SqlCommand("Select Distinct YEAR from TESTING$", con);
         SqlDataAdapter da  = new SqlDataAdapter(cmd);
         da.Fill(dt);
         con.Close();
         DropDownListYear.DataSource     = dt;
         DropDownListYear.DataValueField = "YEAR";
         DropDownListYear.DataBind();
         DropDownListYear.Items.Insert(0, new ListItem("Select", ""));
     }
     catch (Exception ee)
     {
         Response.Write("<script>alert('Error While Binding Year!!');</script>");
     }
 }
Esempio n. 10
0
 private void fillDdl()
 {
     DropDownListYear.DataSource = System.Linq.Enumerable.Range(1940, 79);
     DropDownListYear.DataBind();
 }
Esempio n. 11
0
 //Funció per a reomplir el dropdownlist de l'any
 protected void fillDdl()
 {
     DropDownListYear.DataSource = Enumerable.Range(1940, 79);
     DropDownListYear.DataBind();
 }