Exemplo n.º 1
0
        public static string ToPersianBeautiful(this DateTime date)
        {
            var res = "";

            if (date.Year < 1000)
            {
                return(res);
            }

            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            if (DateTime.Today.ToShortDateString() == date.ToShortDateString())
            {
                TimeSpan span = DateTime.Now.Subtract(date);
                if (span.Hours > 0)
                {
                    res = DateTimeHelper.FarsiNumber(span.Hours.ToString()) + " ساعت پیش ";
                }
                else if (span.Minutes > 3)
                {
                    res = DateTimeHelper.FarsiNumber(span.Minutes.ToString()) + " دقیقه پیش";
                }
                else
                {
                    res = "همین لحظه";
                }
            }
            else
            {
                res = DateTimeHelper.FarsiNumber(pc.GetDayOfMonth(date).ToString() + " " + pc.GetMonthString(date).ToString() + " " + pc.GetYear(date).ToString());
            }
            return(res);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.SetVmPolicy(builder.Build());

            base.OnCreate(bundle);

            CrossCurrentActivity.Current.Init(this, bundle);
            PermissionsHelper.Activity = this;

            this.SetTheme(Resource.Style.Theme_Design_Light);

            //CachedImageRenderer.Init(false);
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init(false);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
Exemplo n.º 3
0
        /// <summary>
        /// این متد تاریخ را به صورت شمسی وارد می نماید
        /// </summary>
        ///  <returns>تاریخ</returns>
        public string PersianCalander()
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            string date = ((pc.GetYear(DateTime.Now)).ToString()).Substring(2, 2) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now);

            return(date);
        }
Exemplo n.º 4
0
        public static string GetMonthString(this System.Globalization.PersianCalendar pc, DateTime datetime)
        {
            int mont = pc.GetMonth(datetime);

            string[] monts = { "فروردین", "ادیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" };
            return(monts.GetValue(mont - 1).ToString());
        }
Exemplo n.º 5
0
        public IActionResult ShowDay(int year, int month, int day)
        {
            var p  = new System.Globalization.PersianCalendar();
            var dt = p.ToDateTime(year, month, day, 0, 0, 0, 0);

            var times = _repository.GetTimeTemplatesTimes(dt.DayOfWeek).Select(x => new Turn {
                Time = x
            }).ToList();

            var turns = _repository.GetTurnsOfDate(dt)
                        .Include(x => x.TurnDetails)
                        .ThenInclude(x => x.ExpertField)
                        .ThenInclude(x => x.SourceType)
                        .ThenInclude(x => x.SourceValues)
                        .ToList();

            var idMap = times.Union(turns).ToLookup(x => x.Time);
            var q     = idMap.Select(x => x.FirstOrDefault(y => y.ID != Guid.Empty) ?? x.First());

            var m = new CalendarShowDayViewModel {
                Date = Lib.persianDateTime.PersianDateStringFormat(dt), Turns = q
            };

            return(View(m));
        }
 public static string GetPersianDateString(DateTime? date)
 {
     string PersianDate = "";
     if (!date.HasValue)
     {
         return PersianDate;
     }
     System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
     int Year = p.GetYear(date.Value);
     int Month = p.GetMonth(date.Value);
     int Day = p.GetDayOfMonth(date.Value);
     string MonthName = "فروردین";
     switch (Month)
     {
         case 1: { MonthName = "فروردین"; break; }
         case 2: { MonthName = "اردیبهشت"; break; }
         case 3: { MonthName = "خرداد"; break; }
         case 4: { MonthName = "تیر"; break; }
         case 5: { MonthName = "مرداد"; break; }
         case 6: { MonthName = "شهریور"; break; }
         case 7: { MonthName = "مهر"; break; }
         case 8: { MonthName = "آبان"; break; }
         case 9: { MonthName = "آذر"; break; }
         case 10: { MonthName = "دی"; break; }
         case 11: { MonthName = "بهمن"; break; }
         case 12: { MonthName = "اسفند"; break; }
         default: { MonthName = "فروردین"; break; }
     }
     PersianDate = Day.ToString() + " " + MonthName + " " + Year.ToString();
     return PersianDate;
 }
        private void Form_newfactor_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            DataBase  db = new DataBase();

            dt = db.MySelect("select name from foroshandeh");
            comboBoxEx1.DataSource    = dt;
            comboBoxEx1.DisplayMember = "name";
            dt = db.MySelect("select name from tahvilgirandeh");
            comboBoxEx2.DataSource    = dt;
            comboBoxEx2.DisplayMember = "name";
            dt = db.MySelect("select name from anbar");
            comboBoxEx3.DataSource    = dt;
            comboBoxEx3.DisplayMember = "name";
            dt = db.MySelect("select name from kala where anbar='" + comboBoxEx3.Text + "'");
            comboBoxEx4.DataSource    = dt;
            comboBoxEx4.DisplayMember = "name";
            dt = db.MySelect("select unitprice from kala where name='" + comboBoxEx4.Text + "'");
            comboBoxEx5.DataSource    = dt;
            comboBoxEx5.DisplayMember = "unitprice";

            System.Globalization.PersianCalendar dtePersianCalendar = new System.Globalization.PersianCalendar();
            System.String Year, Month, Day, strResult;
            DateTime      Date_Now = DateTime.Now;

            //-----------------------------------------------------------------------------
            Year           = dtePersianCalendar.GetYear(Date_Now).ToString();
            Month          = dtePersianCalendar.GetMonth(Date_Now).ToString();
            Day            = dtePersianCalendar.GetDayOfMonth(Date_Now).ToString();
            strResult      = Year + "/" + Month + "/" + Day;
            textBoxX2.Text = strResult;
        }
Exemplo n.º 8
0
        public static void RefreshDateControl(ref PersianUI.Controls.DateControl DateControl)
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            int M = pc.GetMonth(DateTime.Now);
            int d = pc.GetDayOfMonth(DateTime.Now);
            int Y = pc.GetYear(DateTime.Now);

            if (M < 10)
            {
                DateControl.Month.Text = "0" + M.ToString();
            }
            else
            {
                DateControl.Month.Text = M.ToString();
            }
            if (d < 10)
            {
                DateControl.Day.Text = "0" + d.ToString();
            }
            else
            {
                DateControl.Day.Text = d.ToString();
            }
            DateControl.Year.Text = Y.ToString();
        }
        public IActionResult ViewerEvent()

        {
            var requestParams = StiAngularViewer.GetRequestParams(this);
            var reportName    = GetReportName();
            var data          = GetData();

            var dt = JsonConvert.DeserializeObject(data.ToString());

            //var json = StiJsonConnector.Get();
            //var dataSet = json.GetDataSet(new StiJsonOptions(data));÷


            if (requestParams.Action == StiAction.GetReport)

            {
                var report = StiReport.CreateNewReport();
                System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
                var    path        = StiAngularHelper.MapPath(this, "wwwroot/Reports/Currency/" + reportName);
                string Date_shamsi = pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" +
                                     pc.GetDayOfMonth(DateTime.Now);
                report.Load(path);
                //report.RegData("dt", data.ToString());
                report.RegData("dt", dt);
                report.Dictionary.Variables["shamsiDate"].Value = Date_shamsi;
                return(StiAngularViewer.GetReportResult(this, report));
            }

            return(StiAngularViewer.ProcessRequestResult(this));
        }
Exemplo n.º 10
0
        private void انتقالبهفایلExelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            //Atend.Base.Base.BReport report = Atend.Base.Base.BReport.Select_ByCode(1);
            System.Globalization.PersianCalendar calender = new System.Globalization.PersianCalendar();
            int day   = calender.GetDayOfMonth(DateTime.Today);
            int Month = calender.GetMonth(DateTime.Today);
            int Year  = calender.GetYear(DateTime.Today);

            string date          = Year.ToString() + "-" + Month.ToString() + "-" + day.ToString();
            string NameFlash     = "UTS جدول کشش و فلش به روش" + date + cboSelectSection.Text + ".xls";
            string NameConductor = "UTS جدول روز سیم کشی به روش" + date + cboSelectSection.Text + ".xls";
            string NameForce     = " UTS جدول نیرو های وارد بر پایه به روش" + date + cboSelectSection.Text + ".xls";

            string path             = Atend.Control.Common.fullPath + "\\ReportFile\\SagAndTensionReport.xls";
            string pathForce        = Atend.Control.Common.fullPath + "\\ReportFile\\نیروهای وارد بر پایه.xls";
            string pathConductorDay = Atend.Control.Common.fullPath + "\\ReportFile\\ConductorDayReport.xls";

            File.Copy(path, Atend.Control.Common.DesignFullAddress + @"\ProductList\" + NameFlash, true);
            File.Copy(pathForce, Atend.Control.Common.DesignFullAddress + @"\ProductList\" + NameForce, true);
            File.Copy(pathConductorDay, Atend.Control.Common.DesignFullAddress + @"\ProductList\" + NameConductor, true);
            ed.WriteMessage("PathFlash:={0},PAth={1}\n", NameFlash, path);
            Atend.Global.Utility.UReport.CreateExcelReaportForSagTension(NameFlash, dtSagTension, dtRow.Rows[0]);
            Atend.Global.Utility.UReport.CreateExcelReaportForForce(NameForce, dtPole, dtRow.Rows[0]);
            Atend.Global.Utility.UReport.CreateExcelReaportForConductorDay(NameConductor, dtConductorDay, dtRow.Rows[0]);
        }
Exemplo n.º 11
0
        public string methoood()
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();

            a = (pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now));
            return(a);
        }
Exemplo n.º 12
0
        private String ConvertDate(DateTime InputDate)
        {
            try
            {
                String Result = String.Empty;
                System.Globalization.PersianCalendar PersianCalender = new System.Globalization.PersianCalendar();
                int Year  = PersianCalender.GetYear(InputDate);
                int Month = PersianCalender.GetMonth(InputDate);
                int Day   = PersianCalender.GetDayOfMonth(InputDate);
                Result += Year.ToString() + "/";
                if (Month < 10)
                {
                    Result += "0" + Month.ToString() + "/";
                }
                else
                {
                    Result += Month.ToString() + "/";
                }

                if (Day < 10)
                {
                    Result += "0" + Day.ToString();
                }
                else
                {
                    Result += Day.ToString();
                }

                return(Result);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();

            Console.WriteLine((pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now)));
            Console.ReadKey();
        }
Exemplo n.º 14
0
 private bool CustomValidation()
 {
     try
     {
         if (!string.IsNullOrEmpty(txtDateSodoorHokm.Text) &&
             !string.IsNullOrEmpty(txtDateEjraHokm.Text))
         {
             System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
             var edParts = txtDateEjraHokm.Text.Split('/');
             var idParts = txtDateSodoorHokm.Text.Split('/');
             if (idParts.Length != 3 || edParts.Length != 3)
             {
                 customError = "تاریخ صدور یا اجرای حکم صحیح نیست.";
                 return(false);
             }
             //DateTime sodoorDate = new DateTime(Convert.ToInt32(idParts[0]), Convert.ToInt32(idParts[1]), Convert.ToInt32(idParts[2]), pc);
             //DateTime ejraDate = new DateTime(Convert.ToInt32(edParts[0]), Convert.ToInt32(edParts[1]), Convert.ToInt32(edParts[2]), pc);
             //if (ejraDate > sodoorDate)
             //    return true;
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            AnalyticsHelper.Initialize(Xamarin.Forms.Device.iOS);

            global::Xamarin.Forms.Forms.Init();

            CachedImageRenderer.Init();

            LoadApplication(new App());

            UITextField.Appearance.TintColor = Xamarin.Forms.Color.FromHex("#2548D8").ToUIColor();
#if __TESTS__
            Xamarin.Calabash.Start();
#endif
            return(base.FinishedLaunching(app, options));
        }
Exemplo n.º 16
0
        public string TodayFullChar()
        {
            string today;

            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            int M = pc.GetMonth(DateTime.Now);
            int d = pc.GetDayOfMonth(DateTime.Now);

            today = pc.GetYear(DateTime.Now).ToString() + "/";
            if (M < 10)
            {
                today += "0" + M.ToString() + "/";
            }
            else
            {
                today += M.ToString() + "/";
            }
            if (d < 10)
            {
                today += "0" + d.ToString();
            }
            else
            {
                today += d.ToString();
            }
            NowShamsi10Cahracter = today;
            NowShamsi8Character  = today;
            return(today);
        }
Exemplo n.º 17
0
        //dsSagAndTension ds = new dsSagAndTension();
        //public void SetDataset(dsSagAndTension Data)
        //{
        //    ds = Data;
        //}
        private void frmRemarkReport_Load(object sender, EventArgs e)
        {
            Atend.Report.dsSagAndTension dsloadbranch = new Atend.Report.dsSagAndTension();
            Atend.Base.Design.DRemark    remark       = Atend.Base.Design.DRemark.AccessSelectByCode(1);
            if (remark.Code != -1)
            {
                DataRow drRemark = dsloadbranch.Tables["Remark"].NewRow();
                drRemark["Name"] = remark.Name.ToString();
                //MessageBox.Show(drRemark["Name"].ToString());
                dsloadbranch.Tables["Remark"].Rows.Add(drRemark);


                Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect();
                DataRow drDesign = dsloadbranch.Tables["Title"].NewRow();
                drDesign["ProjectName"] = designProfile.DesignName;
                drDesign["Designer"]    = designProfile.Designer;
                drDesign["Area"]        = designProfile.Zone;
                drDesign["Credit"]      = designProfile.Validate;
                System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
                string _date = string.Format("{0}/{1}/{2}", p.GetYear(designProfile.DesignDate).ToString(), p.GetMonth(designProfile.DesignDate).ToString(), p.GetDayOfMonth(designProfile.DesignDate).ToString());

                drDesign["Date"] = _date;

                dsloadbranch.Tables["Title"].Rows.Add(drDesign);


                crRemark02 Remark = new crRemark02();
                Remark.SetDataSource(dsloadbranch);
                crViewerRemark.ReportSource = Remark;
            }
            else
            {
                ed.WriteMessage("در Remark مقداری وجود ندارد\n");
            }
        }
Exemplo n.º 18
0
        public static string ToPersianDate(DateTime objDateTime)
        {
            string rValue;

            System.Globalization.PersianCalendar objPersianCalendar = new System.Globalization.PersianCalendar();

            int Year  = objPersianCalendar.GetYear(objDateTime);
            int Month = objPersianCalendar.GetMonth(objDateTime);
            int Day   = objPersianCalendar.GetDayOfMonth(objDateTime);

            rValue = Year.ToString();

            if (Month < 10)
            {
                rValue += "/0" + Month;
            }
            else
            {
                rValue += "/" + Month;
            }


            if (Day < 10)
            {
                rValue += "/0" + Day;
            }
            else
            {
                rValue += "/" + Day;
            }

            return(rValue);
        }
        public static string GetTodayYearNumber()
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            string year = pc.GetYear(DateTime.Today).ToString().PadLeft(4, '0').Substring(2, 2);

            return(year);
        }
        public static string GetTodayMonthNumber()
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            string month = pc.GetMonth(DateTime.Today).ToString().PadLeft(2, '0');

            return(month);
        }
Exemplo n.º 21
0
        public static RequestView MakeRequestView(List <Request> requests, DateTime date, string CommonDate)
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();

            Request ArrivalRequest = requests.Where(w => w.Type == RequestType.arrival).FirstOrDefault();
            string  arrival        = ArrivalRequest is null ? "-" : pc.GetHour(ArrivalRequest.RequestTime).ToString("00") + ":" + pc.GetMinute(ArrivalRequest.RequestTime).ToString("00");
            Request ExitRequest    = requests.Where(w => w.Type == RequestType.exit).FirstOrDefault();
            string  exit           = ExitRequest is null ? "-" : pc.GetHour(ExitRequest.RequestTime).ToString("00") + ":" + pc.GetMinute(ExitRequest.RequestTime).ToString("00");

            //calculate working time
            int    workTimebyminute;
            string workTime;

            if (arrival != "-" && exit != "-")
            {
                workTimebyminute = (ExitRequest.RequestTime - ArrivalRequest.RequestTime).Hours * 60 + (ExitRequest.RequestTime - ArrivalRequest.RequestTime).Minutes;
                workTime         = (ExitRequest.RequestTime - ArrivalRequest.RequestTime).Hours.ToString("00") + ":" + (ExitRequest.RequestTime - ArrivalRequest.RequestTime).Minutes.ToString("00");
            }
            else
            {
                workTime         = "-";
                workTimebyminute = 0;
            }

            //return new requestview
            if (!(ArrivalRequest is null))
            {
                return(new RequestView(ArrivalRequest.RequestID, ArrivalRequest.UserID, ArrivalRequest.User.Name, arrival, exit, CommonDate, workTime, workTimebyminute
                                       , ArrivalRequest.State, SetDayOfWeek(date), ArrivalRequest.User.NationalCode));
            }
Exemplo n.º 22
0
        public static List <RequestView> getRequestViews(List <Request> requests, DateTime date, string personID)
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            string CommonDate = pc.GetYear(date) + "/" + pc.GetMonth(date).ToString("00") + "/" + pc.GetDayOfMonth(date).ToString("00");

            List <RequestView> requestViews = new List <RequestView>();

            //all accepted request
            List <Request> accepted = requests.Where(w => w.State == State.accepted && w.UserID == personID).ToList();

            if (accepted.Count != 0)
            {
                requestViews.Add(MakeRequestView(accepted, date, CommonDate));
            }

            //all rejected request
            List <Request> rejected = requests.Where(w => w.State == State.rejected && w.UserID == personID).ToList();

            if (rejected.Count != 0)
            {
                requestViews.Add(MakeRequestView(rejected, date, CommonDate));
            }

            //all processing request
            List <Request> processing = requests.Where(w => w.State == State.Processing && w.UserID == personID).ToList();

            if (processing.Count != 0)
            {
                requestViews.Add(MakeRequestView(processing, date, CommonDate));
            }

            return(requestViews);
        }
Exemplo n.º 23
0
        public static string ShamsiDate(DateTime?date, PersianCalendarFormat persianCalendarFormat)
        {
            DateTime dt = Convert.ToDateTime(date);

            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();

            switch (persianCalendarFormat)
            {
            case PersianCalendarFormat.ShortDateTime:
                string farsiDate = $"{pc.GetYear(dt)}/{pc.GetMonth(dt)}/{pc.GetDayOfMonth(dt)}";
                return(farsiDate + " - " + dt.TimeOfDay.ToString().Substring(0, 5));

            case PersianCalendarFormat.LongDate:
                return($"{pc.GetDayOfMonth(dt)} {GetMonthName(pc.GetMonth(dt))} {pc.GetYear(dt)}");

            case PersianCalendarFormat.LongDateTime:
                return($"{pc.GetDayOfMonth(dt)} {GetMonthName(pc.GetMonth(dt))} {pc.GetYear(dt)} - {dt.TimeOfDay.ToString().Substring(0, 5)}");

            case PersianCalendarFormat.ShortDate:
                return($"{ pc.GetYear(dt)}/{ pc.GetMonth(dt)}/{ pc.GetDayOfMonth(dt)}");

            case PersianCalendarFormat.ShortDayMonth:
                return($"{pc.GetMonth(dt)}/{ pc.GetDayOfMonth(dt)}");

            default:
                return(String.Empty);
            }
        }
Exemplo n.º 24
0
        public static string GetJalaliDayOfWeek(this DateTime gregorianDate)
        {
            System.Globalization.PersianCalendar persianCal = new System.Globalization.PersianCalendar();

            DayOfWeek dayOfWeek = persianCal.GetDayOfWeek(gregorianDate);

            switch (dayOfWeek)
            {
            case DayOfWeek.Saturday:
                return("شنبه");

            case DayOfWeek.Sunday:
                return("یکشنبه");

            case DayOfWeek.Monday:
                return("دوشنبه");

            case DayOfWeek.Tuesday:
                return("سه شنبه");

            case DayOfWeek.Wednesday:
                return("چهارشنبه");

            case DayOfWeek.Thursday:
                return("پنج شنبه");

            default:
                return("جمعه");
            }
        }
Exemplo n.º 25
0
        public static string GetPersianDateTime(DateTime Date)
        {
            var Persian = new System.Globalization.PersianCalendar();

            return(string.Format(DisplayFormat.DateTimeStringPersianFormat, Persian.GetYear(Date), Persian.GetMonth(Date), Persian.GetDayOfMonth(Date),
                                 Persian.GetHour(Date), Persian.GetMinute(Date)));
        }
Exemplo n.º 26
0
        public static string GetJalaliYear(this DateTime gregorianDate)
        {
            System.Globalization.PersianCalendar persianCal = new System.Globalization.PersianCalendar();
            int year = persianCal.GetYear(gregorianDate);

            return(year.ToString());
        }
Exemplo n.º 27
0
        public Atend.Report.dsSagAndTension FillRemark()
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            Atend.Report.dsSagAndTension dsloadbranch = new Atend.Report.dsSagAndTension();
            Atend.Base.Design.DRemark    remark       = Atend.Base.Design.DRemark.AccessSelectByCode(1);
            if (remark.Code != -1)
            {
                DataRow drRemark = dsloadbranch.Tables["Remark"].NewRow();
                drRemark["File"] = (byte[])remark.File;
                dsloadbranch.Tables["Remark"].Rows.Add(drRemark);



                //crRemark Remark = new crRemark();
                //Remark.SetDataSource(dsloadbranch);
                //crViewerRemark.ReportSource = Remark;
            }
            else
            {
                ed.WriteMessage("در Remark مقداری وجود ندارد\n");
            }

            DataRow dr1 = dsloadbranch.Tables["Title"].NewRow();

            Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect();

            if (designProfile.Id != 0)
            {
                Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(designProfile.Zone);
                dr1["Area"] = b12.SecondCode;
                System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
                string _date = ChangeToShamsi(designProfile.DesignDate);
                dr1["Date"]        = _date;                    //desProfile.DesignDate.ToString();
                dr1["Designer"]    = designProfile.Designer;
                dr1["ProjectName"] = designProfile.DesignName; //Atend.Control.Common.DesignName;
                dr1["Credit"]      = designProfile.Validate;
                //dr1["SectionCount"] = arrSection.Count.ToString();
                //dr1["PoleCount"] = CountPole.ToString();
                if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath))
                {
                    System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open);
                    byte[] reader           = new byte[FS.Length];
                    FS.Read(reader, 0, Convert.ToInt32(FS.Length));
                    dr1["Logo"] = reader;
                    FS.Close();
                }
                dr1["LogoName"] = Atend.Control.ConnectionString.LogoName;

                dsloadbranch.Tables["Title"].Rows.Add(dr1);
            }
            else
            {
                MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار");
                return(null);
            }


            return(dsloadbranch);
        }
Exemplo n.º 28
0
        private void frmListMonshi_Load(object sender, EventArgs e)
        {
            System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
            mskTarikh.Text = p.GetYear(DateTime.Now).ToString() + p.GetMonth(DateTime.Now).ToString("0#") + p.GetDayOfMonth(DateTime.Now).ToString("0#");

            Display();
        }
Exemplo n.º 29
0
        public int getMonthsDay(int year, int month)
        {
            var persianCal = new System.Globalization.PersianCalendar();
            int monthsDay  = persianCal.GetDaysInMonth(year, month);

            return(monthsDay);
        }
Exemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="persianDate"></param>
        /// <returns></returns>
        public static DateTime PersianDateTimeToGergorian(List <int> persianDate)
        {
            var        persianCalendar = new System.Globalization.PersianCalendar();
            DateTime   date            = new DateTime(1900, 1, 1);
            List <int> Start           = GergorianDateTimeToPersion(date);

            date = persianCalendar.AddYears(date, persianDate[0] - Start[0]);
            date = persianCalendar.AddMonths(date, persianDate[1] - Start[1]);
            date = persianCalendar.AddDays(date, persianDate[2] - Start[2]);

            try
            {
                date = persianCalendar.AddHours(date, persianDate[3] - Start[3]);
                date = persianCalendar.AddMinutes(date, persianDate[4] - Start[4]);
                date = persianCalendar.AddSeconds(date, persianDate[5] - Start[5]);
            }
            catch
            {
                date = persianCalendar.AddHours(date, 12 - Start[3]);
                date = persianCalendar.AddMinutes(date, 0 - Start[4]);
                date = persianCalendar.AddSeconds(date, 0 - Start[5]);
            }

            return(date);
        }
Exemplo n.º 31
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                System.Globalization.PersianCalendar x = new System.Globalization.PersianCalendar();
                DateTime dd = x.ToDateTime(int.Parse(txtdate.Text.Substring(0, 4)),
                                           int.Parse(txtdate.Text.Substring(5, 2)),
                                           int.Parse(txtdate.Text.Substring(8, 2)),
                                           0, 0, 0, 0, 0);

                // Updating the Data to the DataBase
                hazineh fa = new hazineh();
                fa.radif    = long.Parse(txtradif.Text);
                fa.type     = txttype.Text.Trim();
                fa.date     = txtdate.Text;
                fa.mablagh  = long.Parse(txtmablagh.Text);
                fa.comments = txtcomments.Text.Trim();
                fa.update();
                // End of Updating Data to the DataBase

                this.Close();
            }

            catch
            {
                MessageBox.Show("لطفا اطلاعات وارد شده را بررسی نمایید");
            }
        }
Exemplo n.º 32
0
 public static DateTime? PersianDateToDateTime(this DateTime? date)
 {
     try
     {
         System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
         DateTime dt = pc.ToDateTime(int.Parse(date.Value.Year.ToString()), int.Parse(date.Value.Month.ToString()), int.Parse(date.Value.Day.ToString()), 0, 0, 0, 0);
         return dt;
     }
     catch { return null; }
 }
Exemplo n.º 33
0
 /// <summary>
 /// This function convert shamsi datetime to miladi by given 3 parameter string for all one of the year ,month , day
 /// </summary>
 /// <param name="date"></param>
 /// <returns></returns>
 public DateTime? PersianDateToDateTime(string year, string month, string day)
 {
     try
     {
         System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
         DateTime dt = pc.ToDateTime(int.Parse(year), int.Parse(month), int.Parse(day), 0, 0, 0, 0);
         return dt;
     }
     catch { return null; }
 }
Exemplo n.º 34
0
        /// <summary>
        /// this constructor uses PersianCalendar and store its method returned values in a more friendler structor 
        /// and properties of this class
        /// </summary>
        /// <param name="date"></param>
        internal ShamsiDate(DateTime date)
        {
            EquivalentGoergianDate = date;
            var pDate = new System.Globalization.PersianCalendar();

            Saal = pDate.GetYear(date);
            Mah = pDate.GetMonth(date);
            RoozeMah = pDate.GetDayOfMonth(date);
            //time  
            Saat = pDate.GetHour(date);
            Daghighe = pDate.GetMinute(date);
            Saniyeh = pDate.GetSecond(date);

            RoozeHafteh = ConvertDate.MapWeekDayToNum(pDate.GetDayOfWeek(date));
        }
        public static string GetPersianDateStringSlashed(DateTime? date)
        {
            string PersianDate = "";
            if (!date.HasValue)
            {
                return PersianDate;
            }
            System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
            int Year = p.GetYear(date.Value);
            int Month = p.GetMonth(date.Value);
            int Day = p.GetDayOfMonth(date.Value);

            PersianDate = Day.ToString() + "/" + Month.ToString() + "/" + Year.ToString();
            return PersianDate;
        }
Exemplo n.º 36
0
        internal ShamsiDate(int saal,int mah,int rooz)
        {
           
            Saal = saal;
            Mah = mah;
            RoozeMah = rooz;

            var pDate = new System.Globalization.PersianCalendar();
            EquivalentGoergianDate = pDate.ToDateTime(saal, mah, rooz, 0, 0, 0, 0);
            
            Saat = pDate.GetHour(EquivalentGoergianDate);
            Daghighe = pDate.GetMinute(EquivalentGoergianDate);
            Saniyeh = pDate.GetSecond(EquivalentGoergianDate);

            RoozeHafteh = ConvertDate.MapWeekDayToNum(pDate.GetDayOfWeek(EquivalentGoergianDate));
        }
Exemplo n.º 37
0
 public DateTime? DateTimeToPersianTime(DateTime? dt)
 {
     if (dt != null)
     {
         System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
         try
         {
             int year = pc.GetYear((DateTime)dt);
             int month = pc.GetMonth((DateTime)dt);
             int day = pc.GetDayOfMonth((DateTime)dt);
             //string m = String.Format("{0}/{1}/{2}", year, month, day);
             return new DateTime(year, month, day, dt.Value.Hour, dt.Value.Minute, dt.Value.Second);
         }
         catch { return null; }
     }
     else
         return null;
 }
Exemplo n.º 38
0
        public static string DateTimeToPersianTimeForShow(this DateTime dt)
        {
            if (dt != null)
            {
                System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
                try
                {
                    string year = pc.GetYear((DateTime)dt).ToString();
                    string month = pc.GetMonth((DateTime)dt).ToString();
                    string day = pc.GetDayOfMonth((DateTime)dt).ToString();

                    string m = String.Format("{0}/{1}/{2}", year, month, day);
                    return m;
                }
                catch { return ""; }
            }
            else
                return "";
        }
Exemplo n.º 39
0
        public static string DateTimeToPersianTimeForFullShow(this DateTime? dt)
        {
            if (dt != null)
            {
                System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
                try
                {
                    string year = pc.GetYear((DateTime)dt).ToString();
                    string month = pc.GetMonth((DateTime)dt).ToString();
                    string day = pc.GetDayOfMonth((DateTime)dt).ToString();

                    string m = String.Format("{0}/{1}/{2} {3}:{4}", year, month, day,dt.Value.TimeOfDay.Hours,dt.Value.TimeOfDay.Minutes);
                    return m;
                }
                catch { return ""; }
            }
            else
                return "";
        }
        public AdaptedCultureInfo(string name)
            : base(name)
        {
            if (name.ToLower() == "fa-ir")
            {
                System.Globalization.DateTimeFormatInfo info = this.DateTimeFormat;
                info.AbbreviatedDayNames = new string[] { "ی", "د", "س", "چ", "پ", "ج", "ش" };
                info.DayNames = new string[] { "یکشنبه", "دوشنبه", "ﺳﻪشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" };
                info.AbbreviatedMonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
                info.MonthNames = new string[] { "فروردین", "ارديبهشت", "خرداد", "تير", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" };
                info.AMDesignator = "ق.ظ";
                info.PMDesignator = "ب.ظ";
                info.ShortDatePattern = "yyyy/MM/dd";
                info.FirstDayOfWeek = DayOfWeek.Saturday;

                System.Globalization.PersianCalendar cal = new System.Globalization.PersianCalendar();

                typeof(System.Globalization.DateTimeFormatInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(info, cal);
                //object obj = typeof(System.Globalization.DateTimeFormatInfo).GetField("m_cultureTableRecord", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(info);
                //obj.GetType().GetMethod("UseCurrentCalendar", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(cal, null) });
                typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this, cal);
                typeof(System.Globalization.CultureInfo).GetField("calendar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this, cal);
            }
        }
Exemplo n.º 41
0
 public String GetPersianDate(DateTime now)
 {
     System.Globalization.PersianCalendar jc = new System.Globalization.PersianCalendar();
     String tempdate = jc.GetYear(now) + ":" + jc.GetMonth(now) + ":" + jc.GetDayOfMonth(now);
     return tempdate;
 }
Exemplo n.º 42
0
 public static DateTime? PersianDateToDateTime(this string text)
 {
     try
     {
         var elements = text.Split('-', '\\', '/');
         System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
         DateTime dt = pc.ToDateTime(int.Parse(elements[0]), int.Parse(elements[1]), int.Parse(elements[2]), 0, 0, 0, 0);
         return dt;
     }
     catch { return null; }
 }
Exemplo n.º 43
0
 private KeyValuePair<double, double> CalculateUserPoint(Guid userId)
 {
     try
     {
         KeyValuePair<double, double> Result = new KeyValuePair<double, double>(0.0,0.0);
         double result = 0;
         if (m_model.Payments.Count(P => P.MemberID.Equals(userId)) <= 0)
         {
             result = 0;
             return Result;
         }
         else
         {
             var payments = m_model.Payments.Where(P => P.MemberID.Equals(userId));
             System.Globalization.PersianCalendar persian = new System.Globalization.PersianCalendar();
             double sum = 0;
             foreach (var x in payments)
             {
                 String[] dates = x.DateOfPayment.Split(new char[] { '/' });
                 DateTime tempDateTime = new DateTime(int.Parse(dates[0]), int.Parse(dates[1]), int.Parse(dates[2]), persian);
                 DateTime tempNowDate = GetPersianDateInstance(DateTime.Now);
                 double days = (tempNowDate - tempDateTime).TotalDays;
                 double f =  double.Parse(x.Fee);
                 double moneyWeight = f/ 100000.0;
                 sum += f;
                 result += days * moneyWeight;
             }
             return new KeyValuePair<double, double>(Math.Round(result / 100.00, 2), sum);
         }
     }
     catch (Exception ex)
     {
         return new KeyValuePair<double, double>(0.0, 0.0);
     }
 }
 public static int GetPersianMonth(this DateTime date)
 {
     System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
     int Month = p.GetMonth(date);
     return Month;
 }
 public static string GetPersianYearAndMounth(this DateTime date)
 {
     System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
     int Year = p.GetYear(date);
     int Month = p.GetMonth(date);
     int Day = p.GetDayOfMonth(date);
     return Year + "/" + Month;
 }
 public static int GetPersianYear(this DateTime date)
 {
     System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
     int Year = p.GetYear(date);
     return Year;
 }
Exemplo n.º 47
0
        public ActionResult GetListOfMembers()
        {
            try
            {
                System.Globalization.PersianCalendar jc = new System.Globalization.PersianCalendar();
                String tempdate = jc.GetYear((DateTime)DateTime.Now) + ":" + jc.GetMonth((DateTime)DateTime.Now) + ":" + jc.GetDayOfMonth((DateTime)DateTime.Now);
                var Result = (from p in m_model.MembersProfiles
                                      where p.IsDisabled == null || p.IsDisabled == false
                                      select new
                                      {
                                          FirstName = p.FirstName,
                                          LastName = p.LastName,
                                          UserId = p.MemberID,
                                          UserName= p.InternationalCode,
                                          NationalityCode = p.InternationalCode,
                                          Point = p.Point,
                                          Rank = p.Rank,
                                          Date = p.CreateDate != null ? p.CreateDate : tempdate,
                                          IsApproved = p.aspnet_User.aspnet_Membership.IsApproved,
                                          TotalPayment = p.Payment,
                                          DocumentCode = p.DocumentCode
                                      }).ToList();

                return Json(new { Status = true, Message = 37, Result}, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Error(ex.Message);
            }
        }
Exemplo n.º 48
0
 public DateTime GetPersianDateInstance(DateTime now)
 {
     System.Globalization.PersianCalendar jc = new System.Globalization.PersianCalendar();
     String tempdate = jc.GetYear(now) + ":" + jc.GetMonth(now) + ":" + jc.GetDayOfMonth(now);
     return new DateTime(jc.GetYear(now), jc.GetMonth(now), jc.GetDayOfMonth(now), jc);
 }
Exemplo n.º 49
0
        private string GetPersianDate()
        {
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();

            DateTime dt = DateTime.Now;

            //{0} = Year
            //{1} = Month
            //{2} = Day
            return String.Format("{0}/{1}/{2}", pc.GetYear(dt), pc.GetMonth(dt), pc.GetDayOfMonth(dt));
        }
Exemplo n.º 50
0
 public ActionResult GetMember(string userName)
 {
     try
     {
         if (m_model.aspnet_Users.Count(P => P.UserName.Equals(userName)) > 0)
         {
             Guid userId = m_model.aspnet_Users.Single(P => P.UserName.Equals(userName)).UserId;
             System.Globalization.PersianCalendar jc = new System.Globalization.PersianCalendar();
             String tempdate = jc.GetYear((DateTime)DateTime.Now) + ":" + jc.GetMonth((DateTime)DateTime.Now) + ":" + jc.GetDayOfMonth((DateTime)DateTime.Now);
             var Result = (from p in m_model.MembersProfiles
                           where p.MemberID.Equals(userId)
                           select new
                           {
                               UserId = p.MemberID,
                               NationalityCode = p.InternationalCode,
                               FirstName = p.FirstName,
                               LastName = p.LastName,
                               Date = p.CreateDate != null ? p.CreateDate : tempdate,
                               IsApproved = p.aspnet_User.aspnet_Membership.IsApproved,
                               Point = p.Point,
                               Rank = p.Rank,
                               TotalPayment = p.Payment,
                               DocumentCode = p.DocumentCode
                           }).ToList()[0];
             return Json(new { Status = true, Message = 37, Result }, JsonRequestBehavior.AllowGet);
         }
         else
         {
             return Error(38);
         }
     }
     catch (Exception ex)
     {
         return Error(ex.Message);
     }
 }