DateTimePicker and Localization...

edited 1:09AM in FastReport .NET
hi my dear friends...
i am using asp.net web app with c# in vs 2008
i have a class that i am using to convert datetime and calendare control (default vs) to my own
when i call this method (class) in Page_Load so every date in report will show in my language...
================================================================
i read dialoge demos and implementation one of them (Filtering by Date ranges)
but when i browse that page in browser so DateTimePicker never change to my own culture - persian - farsi (i am using that class in my page load)
but every calendar in my page will convert...
how can i solve this problem ???
thanks a lot

Comments

  • edited 1:09AM
    Hello,

    Report dialogs are not working in ASP.Net mode. Don't use it.
  • edited 1:09AM
    hello dear

    I'm Persian.
    It's nice to meet you.
    I can help you convert Gregorian Date to Persian date in Win App.
    first you make new class in project for convert date time same under code.


    public static class clsPersianDate
    {
    public static string ShamsiDate(DateTime dt)
    {
    System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
    strMonth = pc.GetMonth(dt).ToString();
    strDay = pc.GetDayOfMonth(dt).ToString();
    {
    if (pc.GetMonth(dt) > 0 && pc.GetMonth(dt) < 10)
    strMonth = "0" + strMonth;
    if (pc.GetDayOfMonth(dt) > 0 && pc.GetDayOfMonth(dt) < 10)
    strDay = "0" + strDay;
    return string.Format("{0}/{1}/{2}", pc.GetYear(dt), strMonth, strDay);
    }

    }
    }

    so add columns in data table for view Persian date. look like under code


    private void button1_Click(object sender, EventArgs e)
    {
    Report report = new Report();
    using (SqlConnection SqlConnection1 = new SqlConnection("Data Source=.; Initial Catalog=NewTest2; Integrated Security=True; POOLING=FALSE"))
    {
    using (SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter("Select * from CUT.CUTParent order by DocDate", SqlConnection1))
    {
    try
    {
    DataSet DataSet1 = new DataSet();
    DataTable DataTable1 = new DataTable();
    SqlDataAdapter1.Fill(DataTable1);
    DataColumnCollection columns = DataTable1.Columns;
    columns.Add("PersianDate", typeof(System.String));
    DataSet1.Tables.Add(DataTable1);

    for (int i = 0; i <= DataTable1.Rows.Count - 1; i++)
    {
    if (!String.IsNullOrEmpty(DataTable1.Rows["DocDate"].ToString()))
    {
    DataTable1.Rows["PersianDate"] =
    clsPersianDate.ShamsiDate(Convert.ToDateTime(DataTable1.Rows["DocDate"].ToString()));
    }
    }
    DataSet1.AcceptChanges();
    report.RegisterData(DataTable1, "Parent");
    report.GetDataSource("Parent").Enabled = true;//Table1
    report.Design();

    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    finally
    {
    SqlConnection1.Dispose();
    SqlDataAdapter1.Dispose();
    report.Dispose();
    }

    }
    }
    }
    if don't sole your problem connect with me by email address.
    good luck

    Email : dp29088@yahoo.com
    >

Leave a Comment