當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.ToShortDateString方法代碼示例

本文整理匯總了C#中System.Data.DataTable.ToShortDateString方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.ToShortDateString方法的具體用法?C# DataTable.ToShortDateString怎麽用?C# DataTable.ToShortDateString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.ToShortDateString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: cbMonth_SelectedIndexChanged

        private void cbMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
            int month = (cbMonth.SelectedItem as ComboboxItem).Value.ToInt();
            if (cbMonth.SelectedIndex != 0)
            {

                startDate = new DateTime(startDate.Year, month, 1, 1, 0, 0, 0);
                endDate = new DateTime(endDate.Year, month, DateTime.DaysInMonth(endDate.Year, month), 23, 59, 59);

                DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
                Calendar cal = dfi.Calendar;

                if (startDate.DayOfWeek != DayOfWeek.Monday) { startDate = startDate.AddDays(7); }
                DateTime dt = startDate;

                if (cbWeek.Items.Count == 0)
                {

                    cbWeek.Items.Add(new ComboboxItem { Text = "กรุณาเลือกสัปดาห์...", Value = 0 });

                    DayOfWeek startOfWeek = DayOfWeek.Monday;

                    int diff = dt.DayOfWeek - startOfWeek;
                    if (diff < 0)
                    {
                        diff += 7;
                    }
                    dt = dt.AddDays(-1 * diff).Date;

                    for (int i = 1; i <= 4; i++)
                    {
                        cbWeek.Items.Add(new ComboboxItem { Text = "ตั้งแต่ " + dt.ToShortDateString() + " ถึง " + dt.AddDays(6).ToShortDateString() , Value = dt.Day });
                        dt = dt.AddDays(7);
                    }

                    cbWeek.SelectedIndex = 0;
                }
                else
                {
                    cbWeek.Items.Clear();
                    cbWeek.Items.Add(new ComboboxItem { Text = "กรุณาเลือกสัปดาห์...", Value = 0 });
                    DayOfWeek startOfWeek = DayOfWeek.Monday;
                    int diff = dt.DayOfWeek - startOfWeek;
                    if (diff < 0)
                    {
                        diff += 7;
                    }
                    dt = dt.AddDays(-1 * diff).Date;
                    for (int i = 1; i <= 4; i++)
                    {
                        cbWeek.Items.Add(new ComboboxItem { Text = "ตั้งแต่ " + dt.ToShortDateString() + " ถึง " + dt.AddDays(6).ToShortDateString(), Value = dt.Day });
                        dt = dt.AddDays(7);
                    }
                    cbWeek.SelectedIndex = 0;
                }
            }
        }
開發者ID:itktc,項目名稱:projectktc-v2,代碼行數:57,代碼來源:ProductSaleCompare.cs

示例2: Calendar_program_SelectionChanged

        protected void Calendar_program_SelectionChanged(object sender, EventArgs e)
        {
            DateTime dt = Calendar_program.SelectedDate;
            while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);

            Label_program_dag.Text = dt.ToShortDateString() + " - ";
            Label_program_sidste_dag.Text = dt.AddDays(6).ToShortDateString();
            Repeater_program_dag.DataSource = program_dag(dt, dt.AddDays(6));
            Repeater_program_dag.DataBind();
        }
開發者ID:ChristianPhilipEgeNielsen,項目名稱:dampradio,代碼行數:10,代碼來源:ugens_program.aspx.cs

示例3: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            while(dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);

            Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
            Label_program_dag.Text = dt.ToShortDateString() + " - ";
            Label_program_sidste_dag.Text = dt.AddDays(6).ToShortDateString();

            Repeater_program_dag.DataSource = program_dag(dt, dt.AddDays(6));
            Repeater_program_dag.DataBind();
            Calendar_program.SelectionMode = CalendarSelectionMode.DayWeek;
        }
開發者ID:ChristianPhilipEgeNielsen,項目名稱:dampradio,代碼行數:13,代碼來源:ugens_program.aspx.cs


注:本文中的System.Data.DataTable.ToShortDateString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。