本文整理匯總了C#中System.DateTime.ToShortDateString方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTime.ToShortDateString方法的具體用法?C# DateTime.ToShortDateString怎麽用?C# DateTime.ToShortDateString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToShortDateString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: display_for_detail
public void display_for_detail(BCTKUS.US_RPT_TONG_TIEN_DINH_MUC ip_us, DateTime ip_from_date, DateTime ip_to_date)
{
decimal don_gia_dinh_muc = 0;
decimal so_luong_thong_ke = 0;
decimal id_co_so_dinh_muc = -1;
DateTime ap_dung_tu_ngay = new DateTime();
string ten_co_so_dinh_muc = "";
m_lbl_ten_trung_tam.Text = ip_us.strTEN_PHONG_BAN + " (" + ip_us.strMA_PHONG_BAN + ")";
//m_lbl.Text = "Tổng tiền định mức " + ip_us.strTEN_NGAN +" tháng " + ip_from_date.Month + "/" + ip_from_date.Year;
ip_us.get_don_gia_dinh_muc_and_so_luong_thong_ke(ip_us.dcID_PHONG_BAN, ip_us.dcID_LOAI_DINH_MUC
, ip_from_date, ip_to_date
, ref don_gia_dinh_muc, ref so_luong_thong_ke);
m_lbl_don_gia.Text = CIPConvert.ToStr(don_gia_dinh_muc, "#,###") + " (VNĐ)";
//m_lbl_ngay_ap_dung.Text = so_luong_thong_ke + " (người)";
m_lbl_sltk.Text = so_luong_thong_ke + " (người)";
m_lbl_tong_tien.Text = CIPConvert.ToStr(don_gia_dinh_muc * so_luong_thong_ke, "#,###") + " (VNĐ)";
if(don_gia_dinh_muc*so_luong_thong_ke == 0) {
m_lbl_tong_tien.Text = "0" + " (VNĐ)";
}
ip_us.get_co_so_dinh_muc_ap_dung_tu_ngay(ip_us.dcID_PHONG_BAN, ip_us.dcID_LOAI_DINH_MUC
, ip_from_date, ip_to_date
, ref id_co_so_dinh_muc, ref ap_dung_tu_ngay
, ref ten_co_so_dinh_muc);
m_lbl_co_so_dinh_muc.Text = ten_co_so_dinh_muc;
if(ap_dung_tu_ngay.ToShortDateString() != "01/01/0001") {
m_lbl_ngay_ap_dung.Text = ap_dung_tu_ngay.ToShortDateString();
}
this.ShowDialog();
}
示例2: ConvertDateToString
/// <summary>
/// �����ڶ���ת��Ϊ��ʽ�ַ���
/// </summary>
/// <param name="oDateTime">���ڶ���</param>
/// <param name="strFormat">
/// ��ʽ��
/// "SHORTDATE"===������
/// "LONGDATE"==������
/// ����====�Զ����ʽ
/// </param>
/// <returns>�����ַ���</returns>
public static string ConvertDateToString(DateTime oDateTime, string strFormat)
{
string strDate = "";
try
{
switch (strFormat.ToUpper())
{
case "SHORTDATE":
strDate = oDateTime.ToShortDateString();
break;
case "LONGDATE":
strDate = oDateTime.ToLongDateString();
break;
default:
strDate = oDateTime.ToString(strFormat);
break;
}
}
catch (Exception)
{
strDate = oDateTime.ToShortDateString();
}
return strDate;
}
示例3: bokningar
/// <summary>
/// Hämtar alla bokningar under en viss dag
/// </summary>
private void bokningar(DateTime dag)
{
boknings_objekt bokningar = new boknings_objekt(new SqlCeDatabase(), this.admin);
SortedList<string,string>[] allaBokningar;
Label[] tider = { labelTid08, labelTid10, labelTid14, labelTid16 };
allaBokningar = bokningar.hamtaAllaBokningar(dag.ToShortDateString());
for (int i = 0; i < 4; i++)
{
tider[i].Click -= fordonsInfo;
tider[i].Click -= label_Click;
if (allaBokningar[i] == null)
{
tider[i].Text = "Ledig";
tider[i].Click -= fordonsInfo;
tider[i].Click += new EventHandler(label_Click);
tider[i].Cursor = Cursors.Hand;
}
else
{
tider[i].Text = allaBokningar[i]["bil"];
tider[i].Click += new EventHandler(fordonsInfo);
tider[i].Cursor = Cursors.Hand;
}
if (DEBUG)
richTextBoxFormAdminMsgs.Lines = bokningar.GetTmpMsgs();
labelNyBokDag.Text = dag.ToShortDateString();
labelDag.Text = string.Format("Det valda datumet är {0}", dag.ToShortDateString());
panelBokDag.Show();
}
}
示例4: GetAutoCompleteInvoiceNumbers
public List<string> GetAutoCompleteInvoiceNumbers(DateTime date, int SupplierId)
{
List<string> obj = new List<string>();
DataBaseConnection dbConn = new DataBaseConnection();
SqlConnection con = dbConn.SqlConn();
SqlCommand cmdI = new SqlCommand("Select g.InvoiceNumber, g.GRVTypeID from t_GRVList g left join t_SparRecon sr on g.InvoiceNumber=sr.InvoiceNumber and g.GRVTypeID = sr.GRVTypeId "
+ " where g.InvoiceDate BETWEEN DATEADD(DAY, -7,'" + date.ToShortDateString() + "') AND '" + date.ToShortDateString() + "' and g.SupplierID = " + SupplierId
+ " and COALESCE(sr.SparReconId,0) = 0 and g.Removed =0 ", con);
cmdI.Connection.Open();
SqlDataReader drI = cmdI.ExecuteReader();
if (drI.HasRows)
{
while (drI.Read())
{
if (Convert.ToInt16(drI["GRVTypeID"]) == 1)
{
obj.Add(drI["InvoiceNumber"].ToString() + " - GRV");
}
else
{
obj.Add(drI["InvoiceNumber"].ToString() + " - CLM");
}
}
}
drI.Close();
con.Close();
con.Dispose();
return obj;
}
示例5: Main
static void Main()
{
DateTime today = DateTime.Now;
DateTime otherDate = new DateTime();
string[] dateFormat = new string[] { "dd.MM.yyyy" };
int workDays;
Console.WriteLine("Please enter the date /dd.MM.yyyy/:");
try
{
otherDate = DateTime.ParseExact(Console.ReadLine(), dateFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
//check which date is bigger and invert the calculation in order to receive the right result
if (today.Date<otherDate.Date)
{
workDays = WorkDaysCalculation(today, otherDate);
Console.WriteLine("The working days between {0} and {1} are {2}.", today.ToShortDateString(), otherDate.ToShortDateString(), workDays);
}
else
{
workDays = WorkDaysCalculation(otherDate, today);
Console.WriteLine("The working days between {0} and {1} are {2}.", otherDate.ToShortDateString(), today.ToShortDateString(), workDays);
}
}
catch(FormatException)
{
Console.WriteLine("Invalid date format!");
}
}
示例6: AddCourse
public ActionResult AddCourse(int id)
{
List<GradeLevel> gradeList = _opp2.GetAllGrades();
List<Subject> subjects = _opp1.GetAllSubjects();
DateTime Date = new DateTime();
var startDate = Date.ToShortDateString();
var endDate = Date.ToShortDateString();
var course = new TeacherViewModel()
{
GradeLevelList = gradeList.Select(x => new System.Web.Mvc.SelectListItem()
{
Value = x.GradeLevelId.ToString(),
Text = x.GradeLevelName.ToString()
}),
SubjectList = subjects.Select(x => new System.Web.Mvc.SelectListItem()
{
Value = x.SubjectId.ToString(),
Text = x.SubjectName.ToString()
})
};
course.StartDate = startDate;
course.EndDate = endDate;
course.UserId = id;
ViewBag.TeacherId = course.UserId;
return View("AddCourse", course);
}
示例7: GetDateSpanString
public static string GetDateSpanString(DateTime StartDate, DateTime EndDate)
{
if (StartDate.ToShortDateString() == EndDate.ToShortDateString())
{
return "(" + StartDate.ToShortDateString() + ")";
}
return "(" + StartDate.ToShortDateString() + " - " + EndDate.ToShortDateString() + ")";
}
示例8: RunBondDataToDB
static void RunBondDataToDB(DateTime targetDate)
{
logger.Info("Start RunBondDataToDB {0}", targetDate.ToShortDateString());
//KtbRegressionToDB ktbRegressionToDB = new KtbRegressionToDB();
//ktbRegressionToDB.Run(targetDate);
KtbAvgRateToDB ktbAvgRateToDB = new KtbAvgRateToDB();
ktbAvgRateToDB.Run(targetDate);
logger.Info("End RunBondDataToDB {0}", targetDate.ToShortDateString());
}
示例9: MainWindow
public MainWindow()
{
// start anotak
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ApplicationThreadException);
// end anotak
InitializeComponent();
//CommandBindings
//Find Shell Library at http://archive.msdn.microsoft.com/WPFShell/Release/ProjectReleases.aspx?ReleaseId=4332
Microsoft.Windows.Shell.SystemParameters2.Current.PropertyChanged += CurrentPropertyChanged;
if(UserSettings.CurrentSettings.UseAeroScheme)
if (Microsoft.Windows.Shell.SystemParameters2.Current.IsGlassEnabled)
Style = (Style)FindResource("AeroStyle");
Class.CharNames.LoadDictionary();
if (!UserSettings.CurrentSettings.WindowCollection.ContainsKey(Name))
UserSettings.CurrentSettings.WindowCollection.Add(Name, new TypeSettings());
else
{
Left = UserSettings.CurrentSettings.WindowCollection[Name].ThisLocation.X;
Top = UserSettings.CurrentSettings.WindowCollection[Name].ThisLocation.Y;
Width = UserSettings.CurrentSettings.WindowCollection[Name].ThisSize.Width;
Height = UserSettings.CurrentSettings.WindowCollection[Name].ThisSize.Height;
}
recentFileList.MenuClick += (s, e) => RecentOpen(e.Filepath);
exButtonCharge.OnClick += exButtonCharge_OnClick;
exButtonInput.OnClick += exButtonInput_OnClick;
exButtonMoves.OnClick += exButtonMoves_OnClick;
exButtonCancels.OnClick += exButtonCancels_OnClick;
exButtonScripts.OnClick += exButtonScripts_OnClick;
exButtonVFX.OnClick += exButtonVFX_OnClick;
exButtonHitBox.OnClick += exButtonHitBox_OnClick;
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, ClickOpen));
CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, ClickSave, FilesOpened));
CommandBindings.Add(new CommandBinding(ApplicationCommands.SaveAs, ClickSaveAs, FilesOpened));
this.Title = "Ono! " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//Build Timestamp
var version = Assembly.GetEntryAssembly().GetName().Version;
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(
TimeSpan.TicksPerDay * version.Build + // days since 1 January 2000
TimeSpan.TicksPerSecond * 2 * version.Revision)); // seconds since midnight, (multiply by 2 to get original)
//CommandManager.AddExecutedHandler(ApplicationCommands.Open, ClickOpen);
BuildTime.Content = "Build Date: "+buildDateTime.ToShortDateString();
AELogger.Log("Build Date: " + buildDateTime.ToShortDateString(), false);
App.OpenedFiles.Log = AELogger.Logger;
this.PreviewKeyDown += this.Base_PreviewKeyDown;
}
示例10: ddlMonth_SelectedIndexChanged
protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e)
{
DateTime beginDate = new DateTime(DateTime.Now.Year, int.Parse(ddlMonth.SelectedValue), 1);
DateTime endDate = new DateTime(beginDate.AddMonths(1).Year, beginDate.AddMonths(1).Month, 1);
DateTime pastDate = new DateTime(beginDate.AddDays(-1).Year, beginDate.AddDays(-1).Month, 1);
txtBeginDate.Text = beginDate.ToShortDateString();
txtEndDate.Text = endDate.AddDays(-1).ToShortDateString();
txtPastBeginDate.Text = pastDate.ToShortDateString();
txtPastEndDate.Text = pastDate.AddMonths(1).AddDays(-1).ToShortDateString();
this.lblTime.Text = "月" + "[" + beginDate.ToShortDateString() + " - " + endDate.AddDays(-1).ToShortDateString() + "]";
this.lblPastPlanYear.Text = pastDate.Year.ToString();
lblPastPlanPeriod.Text = pastDate.Month.ToString();
this.lblPastPlanPeroidType.Text = "月";
this.lblCurrentPlanYear.Text = beginDate.Year.ToString();
this.lblCurrentPlanPeroid.Text = beginDate.Month.ToString();
this.lblCurrentPlanPeroidType.Text = "月";
//this.lblPastPlan.Text = pastDate.Year.ToString() + "年" + pastDate.Month.ToString() + "月計劃";
this.lblConclusion.Text = pastDate.Year.ToString() + "年" + pastDate.Month.ToString() + "月總結";
//this.lblCurrentPlan.Text = beginDate.Year.ToString() + "年" + beginDate.Month.ToString() + "月計劃";
ActiveRecord.Model.Plan plan = new ActiveRecord.Model.Plan().Find(ddlPlanObjectType.SelectedValue, ddlPlanPeriodType.SelectedValue, lblCurrentPlanYear.Text, lblCurrentPlanPeroid.Text, Server.UrlDecode(Request.Cookies["UserName"].Value));
if (plan != null)//本月計劃
{
this.FCKeditor3.Value = plan.PlanContent;
}
else
{
this.FCKeditor3.Value = "";
}
//if (plan.PlanBeginDate > DateTime.Now || plan.PlanEndDate < DateTime.Now)
//{
// Response.Write("<script laguage='javascript'>setFckEditor3ReadOnly();</script>");
//}
//上月總結
plan = new ActiveRecord.Model.Plan().Find(ddlPlanObjectType.SelectedValue, ddlPlanPeriodType.SelectedValue, lblPastPlanYear.Text, int.Parse(lblPastPlanPeriod.Text).ToString(), Server.UrlDecode(Request.Cookies["UserName"].Value));
if (plan != null)//上月總結
{
this.FCKeditor2.Value = plan.PlanConclusion;
this.past_plan_content.InnerHtml = plan.PlanContent;//上月計劃
}
else
{
this.FCKeditor2.Value = "";
this.past_plan_content.InnerHtml = "";
}
//if (plan.PlanBeginDate > DateTime.Now || plan.PlanEndDate < DateTime.Now)
//{
// Response.Write("<script laguage='javascript'>setFckEditor2ReadOnly();</script>");
//}
}
示例11: buscar
public IList<AutorizacionDetalle> buscar(DateTime desde,DateTime hasta )
{
IList<AutorizacionDetalle> autorizaciones = null;
if (ConexionBD.getSession().CreateCriteria(typeof(AutorizacionDetalle)).Add(Expression.Between("Visita.Fecha", DateTime.Parse(desde.ToShortDateString()), DateTime.Parse(hasta.ToShortDateString()))).List<AutorizacionDetalle>().Count > 0)
{
autorizaciones = ConexionBD.getSession().CreateCriteria(typeof(AutorizacionDetalle)).Add(Expression.Between("Visita.Fecha", DateTime.Parse(desde.ToShortDateString()), DateTime.Parse(hasta.ToShortDateString()))).List<AutorizacionDetalle>();
}
return autorizaciones;
}
示例12: CultureTest
public void CultureTest()
{
Assert.AreEqual (CultureInfo.CurrentCulture.Name, "ja-JP");
Assert.AreEqual (Thread.CurrentThread.CurrentCulture.Name,"ja-JP");
DateTime dateTime = new DateTime(2013, 7, 2);
Assert.AreEqual (dateTime.ToShortDateString(), "2013/07/02");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Assert.AreEqual (dateTime.ToShortDateString(), "7/2/2013");
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
Assert.AreEqual (dateTime.ToShortDateString(), "02.07.2013");
}
示例13: clear
public static List<string> clear(DateTime begin, DateTime end, string extension, string user)
{
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
string sql = "SELECT PAD FROM BESTAND WHERE Datum BETWEEN '" + begin.ToShortDateString() + "' AND '" + end.ToShortDateString() + "'";
List<string> paden = new List<string>();
if (extension != "")
{
cmd.Parameters.Add(new OracleParameter("extension", extension));
sql += " AND Extensie = :extension";
}
if (user != "")
{
cmd.Parameters.Add(new OracleParameter("user0", user));
sql += " AND RFID = :user0";
}
cmd.CommandText = sql;
try
{
conn.Open();
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
paden.Add(reader["PAD"].ToString());
}
sql = "DELETE FROM BESTAND WHERE Datum BETWEEN '" + begin.ToShortDateString() + "' AND '" + end.ToShortDateString() + "'";
if (extension != "")
{
sql += " AND Extensie = :extension";
}
if (user != "")
{
sql += " AND RFID = :user0";
}
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
catch (OracleException ex)
{
throw ex;
}
finally
{
conn.Close();
}
return paden;
}
示例14: GenerateReportGrid
public void GenerateReportGrid(DateTime dateFrom, DateTime dateTo)
{
Cursor current = this.Cursor;
this.Cursor = Cursors.WaitCursor;
labelControlfromto.Text = dateFrom.ToShortDateString() + " - " + dateTo.ToShortDateString();
gridViewAnalizeReport.ViewCaption = "Отчет по анализам за период " + " "
+ dateFrom.ToShortDateString() + " - " + dateTo.ToShortDateString();
List<UslugiCount> listUslugiCount = DataProvider.DataProvider.GetUslugiCount(dateFrom, dateTo,false);
uslugiCountBindingSource.DataSource = listUslugiCount;
this.Cursor = Cursors.Arrow;
}
示例15: GetReportTotalMedicineDeliveryByMonth
public List<ReportTotalMedicineDeliveryByMonth> GetReportTotalMedicineDeliveryByMonth(int clinicId, DateTime month)
{
var parameters = new SqlParameter[]
{
new SqlParameter("@ClinicId", clinicId),
new SqlParameter("@Month", month.ToShortDateString())
};
var ds = this.Context.Database.SqlQuery<ReportTotalMedicineDeliveryByMonth>("sp_ReportTotalMedicineDeliveryByMonth @ClinicId, @Month",
new SqlParameter("@ClinicId", AppContext.CurrentClinic.Id),
new SqlParameter("@Month", month.ToShortDateString()));
return ds.ToList();
}