nafisehk
یک شنبه 22 مرداد 1391, 20:56 عصر
سلام دوستان
من میخوام تاریخ شمسی و تو دیتابیس ذخیره کنم.. آیا روشی بهتر از تبدیل تاریخ به میلادی و ذخیره تاریخ میللادی و تبدیل تاریخ میلادی به شمسی برای بازیابی وجود نداره؟
من مبتدی هستم ممکننه راهنماییم کنید...چه جوری باید از کد زیر استفاده کنم
// Name : C# Calendar
// Author : Terrence Ma
// Email : terrence@terrence.com
// Web : http://www.terrence.com
// Date : V1.0 10/05/2002
// Copyright : © 2002 Terrence Ma
// License : Non-commercial use only
// Warranty : No Warranty
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace calendar
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblMonth01;
private System.Windows.Forms.ComboBox cbxMonth01;
private System.Windows.Forms.Label lblYear01;
private System.Windows.Forms.ComboBox cbxYear01;
private System.Windows.Forms.MonthCalendar calCal01;
private System.Windows.Forms.Button btnSelect01;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.calCal01 = new System.Windows.Forms.MonthCalendar();
this.lblMonth01 = new System.Windows.Forms.Label();
this.cbxMonth01 = new System.Windows.Forms.ComboBox();
this.lblYear01 = new System.Windows.Forms.Label();
this.cbxYear01 = new System.Windows.Forms.ComboBox();
this.btnSelect01 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// calCal01
//
this.calCal01.Location = new System.Drawing.Point(60, 30);
this.calCal01.Name = "calCal01";
this.calCal01.TabIndex = 0;
//
// lblMonth01
//
this.lblMonth01.Location = new System.Drawing.Point(8, 256);
this.lblMonth01.Name = "lblMonth01";
this.lblMonth01.Size = new System.Drawing.Size(56, 23);
this.lblMonth01.TabIndex = 1;
this.lblMonth01.Text = "Month :";
this.lblMonth01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbxMonth01
//
this.cbxMonth01.Items.AddRange(new object[] {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12"});
this.cbxMonth01.Location = new System.Drawing.Point(72, 256);
this.cbxMonth01.Name = "cbxMonth01";
this.cbxMonth01.Size = new System.Drawing.Size(48, 24);
this.cbxMonth01.TabIndex = 2;
this.cbxMonth01.Text = "01";
//
// lblYear01
//
this.lblYear01.Location = new System.Drawing.Point(144, 256);
this.lblYear01.Name = "lblYear01";
this.lblYear01.Size = new System.Drawing.Size(40, 23);
this.lblYear01.TabIndex = 3;
this.lblYear01.Text = "Year :";
this.lblYear01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbxYear01
//
this.cbxYear01.Items.AddRange(new object[] {
"1990",
"1991",
"1992",
"1993",
"1994",
"1995",
"1996",
"1997",
"1998",
"1999",
"2000",
"2001",
"2002",
"2003",
"2004",
"2005",
"2006",
"2007",
"2008",
"2009",
"2010",
"2011",
"2012",
"2013",
"2014",
"2015",
"2016",
"2017",
"2018",
"2019",
"2020",
"2021",
"2022",
"2023",
"2024",
"2025",
"2026",
"2027",
"2028",
"2029",
"2030"});
this.cbxYear01.Location = new System.Drawing.Point(192, 256);
this.cbxYear01.Name = "cbxYear01";
this.cbxYear01.Size = new System.Drawing.Size(62, 24);
this.cbxYear01.TabIndex = 4;
this.cbxYear01.Text = "1990";
//
// btnSelect01
//
this.btnSelect01.Location = new System.Drawing.Point(280, 256);
this.btnSelect01.Name = "btnSelect01";
this.btnSelect01.Size = new System.Drawing.Size(62, 23);
this.btnSelect01.TabIndex = 5;
this.btnSelect01.Text = "Select";
this.btnSelect01.Click += new System.EventHandler(this.btnSelect01_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(352, 320);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnSelect01,
this.cbxYear01,
this.lblYear01,
this.cbxMonth01,
this.lblMonth01,
this.calCal01});
this.Name = "Form1";
this.Text = "C# Calendar";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSelect01_Click(object sender, System.EventArgs e)
{
string DateSelect01 = cbxMonth01.Text + "/1/" +cbxYear01.Text;
calCal01.SelectionRange = new SelectionRange(
Convert.ToDateTime(DateSelect01),
Convert.ToDateTime(DateSelect01));
}
}
}
من میخوام تاریخ شمسی و تو دیتابیس ذخیره کنم.. آیا روشی بهتر از تبدیل تاریخ به میلادی و ذخیره تاریخ میللادی و تبدیل تاریخ میلادی به شمسی برای بازیابی وجود نداره؟
من مبتدی هستم ممکننه راهنماییم کنید...چه جوری باید از کد زیر استفاده کنم
// Name : C# Calendar
// Author : Terrence Ma
// Email : terrence@terrence.com
// Web : http://www.terrence.com
// Date : V1.0 10/05/2002
// Copyright : © 2002 Terrence Ma
// License : Non-commercial use only
// Warranty : No Warranty
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace calendar
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblMonth01;
private System.Windows.Forms.ComboBox cbxMonth01;
private System.Windows.Forms.Label lblYear01;
private System.Windows.Forms.ComboBox cbxYear01;
private System.Windows.Forms.MonthCalendar calCal01;
private System.Windows.Forms.Button btnSelect01;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.calCal01 = new System.Windows.Forms.MonthCalendar();
this.lblMonth01 = new System.Windows.Forms.Label();
this.cbxMonth01 = new System.Windows.Forms.ComboBox();
this.lblYear01 = new System.Windows.Forms.Label();
this.cbxYear01 = new System.Windows.Forms.ComboBox();
this.btnSelect01 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// calCal01
//
this.calCal01.Location = new System.Drawing.Point(60, 30);
this.calCal01.Name = "calCal01";
this.calCal01.TabIndex = 0;
//
// lblMonth01
//
this.lblMonth01.Location = new System.Drawing.Point(8, 256);
this.lblMonth01.Name = "lblMonth01";
this.lblMonth01.Size = new System.Drawing.Size(56, 23);
this.lblMonth01.TabIndex = 1;
this.lblMonth01.Text = "Month :";
this.lblMonth01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbxMonth01
//
this.cbxMonth01.Items.AddRange(new object[] {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12"});
this.cbxMonth01.Location = new System.Drawing.Point(72, 256);
this.cbxMonth01.Name = "cbxMonth01";
this.cbxMonth01.Size = new System.Drawing.Size(48, 24);
this.cbxMonth01.TabIndex = 2;
this.cbxMonth01.Text = "01";
//
// lblYear01
//
this.lblYear01.Location = new System.Drawing.Point(144, 256);
this.lblYear01.Name = "lblYear01";
this.lblYear01.Size = new System.Drawing.Size(40, 23);
this.lblYear01.TabIndex = 3;
this.lblYear01.Text = "Year :";
this.lblYear01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cbxYear01
//
this.cbxYear01.Items.AddRange(new object[] {
"1990",
"1991",
"1992",
"1993",
"1994",
"1995",
"1996",
"1997",
"1998",
"1999",
"2000",
"2001",
"2002",
"2003",
"2004",
"2005",
"2006",
"2007",
"2008",
"2009",
"2010",
"2011",
"2012",
"2013",
"2014",
"2015",
"2016",
"2017",
"2018",
"2019",
"2020",
"2021",
"2022",
"2023",
"2024",
"2025",
"2026",
"2027",
"2028",
"2029",
"2030"});
this.cbxYear01.Location = new System.Drawing.Point(192, 256);
this.cbxYear01.Name = "cbxYear01";
this.cbxYear01.Size = new System.Drawing.Size(62, 24);
this.cbxYear01.TabIndex = 4;
this.cbxYear01.Text = "1990";
//
// btnSelect01
//
this.btnSelect01.Location = new System.Drawing.Point(280, 256);
this.btnSelect01.Name = "btnSelect01";
this.btnSelect01.Size = new System.Drawing.Size(62, 23);
this.btnSelect01.TabIndex = 5;
this.btnSelect01.Text = "Select";
this.btnSelect01.Click += new System.EventHandler(this.btnSelect01_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
this.ClientSize = new System.Drawing.Size(352, 320);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnSelect01,
this.cbxYear01,
this.lblYear01,
this.cbxMonth01,
this.lblMonth01,
this.calCal01});
this.Name = "Form1";
this.Text = "C# Calendar";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSelect01_Click(object sender, System.EventArgs e)
{
string DateSelect01 = cbxMonth01.Text + "/1/" +cbxYear01.Text;
calCal01.SelectionRange = new SelectionRange(
Convert.ToDateTime(DateSelect01),
Convert.ToDateTime(DateSelect01));
}
}
}