Exemplo n.º 1
0
 private HejriCommonDate HejriCommonDateHelper(OracleDataReader reader)
 {
     HejriCommonDate hejriCommonDate = new HejriCommonDate();
     hejriCommonDate.GregorianDate = Convert.ToDateTime(reader["GREGORIAN_DATE"]);
     hejriCommonDate.HijriDay = Convert.ToInt32(reader["HEJRA_DD"]);
     hejriCommonDate.HijriMonth = Convert.ToInt32(reader["HEJRA_MM"]);
     hejriCommonDate.HijriYear = Convert.ToInt32(reader["HEJRA_YYYY"]);
     return hejriCommonDate;
 }
Exemplo n.º 2
0
        public string FromHijriToGer(string date)
        {
            GetCommonData();
            string[] dateArrr;
            string[] timeArray = date.Split(' ');
            if (timeArray.Count() == 2)
            {
                dateArrr = timeArray[0].Split('/');
            }
            else
            {
                dateArrr = date.Split('/');
            }

            if (dateArrr.Count() == 3)
            {

                var x = from z in list where z.HijriDay >= Convert.ToInt32(dateArrr[0]) && z.HijriMonth >= Convert.ToInt32(dateArrr[1]) && z.HijriYear >= Convert.ToInt32(dateArrr[2]) select z;
                List<HejriCommonDate> dtList = x.ToList<HejriCommonDate>();
                dtList = x.ToList<HejriCommonDate>();
                if (dtList != null)
                {
                    HejriCommonDate hejriCommonDate = new HejriCommonDate();
                    hejriCommonDate = dtList[dtList.Count - 1];
                    int result = Convert.ToInt32(dateArrr[0]) - hejriCommonDate.HijriDay;
                    if (timeArray.Count() == 2)
                    {
                        return hejriCommonDate.GregorianDate.AddDays(result).Date.ToString("d/M/yyyy") + " " + timeArray[1];
                    }
                    else
                    {
                        return hejriCommonDate.GregorianDate.AddDays(result).Date.ToString("d/M/yyyy");
                    }
                }
                else
                {
                    return "لاتوجد معلومات بالبحث المطلوب";
                }
            }
            else
            {
                return "حدث خطأ في تحويل التاريخ الرجاء التأكد من صيغة التاريخ";
            }
        }
Exemplo n.º 3
0
        private void GetCommonData()
        {
            List<HejriCommonDate> hejriCommonDateList = new List<HejriCommonDate>();
            OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            OracleCommand com = new OracleCommand("VW_HEJRA_DATES_FIND_ALL", conn);
            try
            {
                conn.Open();
                com.CommandType = System.Data.CommandType.StoredProcedure;
                OracleParameter parameter = new OracleParameter();
                parameter.Direction = System.Data.ParameterDirection.InputOutput;
                parameter.OracleDbType = OracleDbType.RefCursor;
                com.Parameters.Add(parameter);
                OracleDataReader reader = com.ExecuteReader();

                while (reader.Read())
                {
                    HejriCommonDate hejriCommonDate = new HejriCommonDate();
                    hejriCommonDate = HejriCommonDateHelper(reader);
                    if (hejriCommonDate != null)
                        hejriCommonDateList.Add(hejriCommonDate);
                }

            }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
                conn.Clone();
                com.Clone();
            }

            list = hejriCommonDateList;
        }