void CalculateMonth(int thisYear, int thisMonth) { yearForNavigating = thisYear; monthForNavigating = thisMonth; System.DateTime tempDateTime = persianCalendar.ToDateTime(yearForNavigating, monthForNavigating, 15, 01, 01, 01, 01); int thisDay = 1; TextBlockThisMonth.Text = string.Empty; TextBlockThisMonth.Text = monthForNavigating.ConvertToPersianMonth() + " " + yearForNavigating.ConvertToPersianNumber(); //Different between first place of calendar and first place of this month //اختلاف بین خانه شروع ماه و اولین خانه تقویم string DayOfWeek = persianCalendar.GetDayOfWeek(persianCalendar.ToDateTime(thisYear, thisMonth, 01, 01, 01, 01, 01)).ToString(); int span = CalculatePersianSpan(DayOfWeek.ConvertToPersianDay()); DecreasePersianDay(ref thisYear, ref thisMonth, ref thisDay, span); string persianDate;//حاوی تاریخ روزهای شمسی Contains the date of Persian //////////////////////////////////// for (int i = 0; i < 6 * 7; i++) { tempDateTime = persianCalendar.ToDateTime(thisYear, thisMonth, thisDay, 01, 01, 01, 01); persianDate = thisDay.ConvertToPersianNumber(); DayOfWeek = persianCalendar.GetDayOfWeek(tempDateTime).ToString(); //RectangleStyleEventedDay if (thisMonth == monthForNavigating) // ماه کنونی { if (thisDay == currentDay && thisMonth == currentMonth && thisYear == currentYear) // امروز { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.TodayStyle, Infrastructure.Resources.PersianDatePicker.ThisMonthTextBlockStyle); SelectedDateTime = new FarsiLibrary.Utils.PersianDate(thisYear, thisMonth, thisDay); SelectedDateTimeChanged?.Invoke(this, System.EventArgs.Empty); } else // سایر روزهای ماه کنونی { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.NoneStyle, Infrastructure.Resources.PersianDatePicker.ThisMonthTextBlockStyle); } } else // ماه های دیگر { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.NoneStyle, Infrastructure.Resources.PersianDatePicker.OutOfThisMonthTextBlockStyle); } IncreasePersianDay(ref thisYear, ref thisMonth, ref thisDay, 1); } }
private void DateValueTextEdit_Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e) { if (e.Value != null) { if (string.IsNullOrWhiteSpace(e.Value.ToString()) == false) { FarsiLibrary.Utils.PersianDate oPersianDate = new FarsiLibrary.Utils.PersianDate(e.Value.ToString()); DatePickerPopupCalendar.SelectedDateTime = oPersianDate; DatePickerPopupCalendar.GoToDate(oPersianDate); SelectedDateTime = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(oPersianDate); SelectedPersianDateTime = oPersianDate; } } else { DatePickerPopupCalendar.GoToDate(SelectedPersianDateTime); SelectedDateTime = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(FarsiLibrary.Utils.PersianDate.Today); SelectedPersianDateTime = FarsiLibrary.Utils.PersianDate.Today; } Text = DateValueTextEdit.Text; }
public void GoToDate(FarsiLibrary.Utils.PersianDate persianDate) { currentYear = persianDate.Year; currentMonth = persianDate.Month; currentDay = persianDate.Day; CalculateMonth(persianDate.Year, persianDate.Month); }
public static string ToPersianDateTime(this System.DateTime dateTime) { string result = string.Empty; result = new FarsiLibrary.Utils.PersianDate(dateTime).ToString("g"); return(result); }
public string AsLongReadableDate(DateTime?dt) { if (dt == null) { return("فاقد تاریخ"); } FarsiLibrary.Utils.PersianDate pd = (DateTime)dt; return(string.Format("{0} {1} {2} {3}", GetPersianDayOfWeek(pd.DayOfWeek), GetPersianNumber(pd.Day), pd.LocalizedMonthName, GetPersianNumber(pd.Year))); }
public sefaresh(string table, string fish, FarsiLibrary.Utils.PersianDate time, ArrayList food_list) { table_fishcode = fish; table_number = table; this.time = time; list_codecstring = food_list; list_sefareshshow = convert_codeclist_to_sefareshlist(this); get_total_cost(); }
public sefaresh(string table, string fish, FarsiLibrary.Utils.PersianDate time, List<sefaresh_show> sefaresh_show_list, bool a) { table_fishcode = fish; table_number = table; this.time = time; list_codecstring = null; list_sefareshshow = sefaresh_show_list; get_total_cost(); }
//public static bool IsDate(FADatePicker cmbDate) //{ // if (cmbDate.Text.Trim() == "") // { // cmbDate.Text = "[هیج مقداری انتخاب نشده]"; // return true; // } // else if (cmbDate.Text.Trim() == "[هیج مقداری انتخاب نشده]") // { // return true; // } // try // { // FarsiLibrary.Utils.PersianDate pDate = FarsiLibrary.Utils.PersianDate.Parse(cmbDate.Text); // cmbDate.BackColor = colorValid; // return true; // } // catch // { // cmbDate.BackColor = colorInvalid; // return false; // } //} public static bool IsDate(string strInput) { try { FarsiLibrary.Utils.PersianDate pDate = FarsiLibrary.Utils.PersianDate.Parse(strInput); return(true); } catch { return(false); } }
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((value is string) == false) { return(null); } string strValue = value as string; FarsiLibrary.Utils.PersianDate oPersianDate = new FarsiLibrary.Utils.PersianDate(strValue); return(FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(oPersianDate)); }
public static bool IsDate(RadMaskedEditBox mskDate) { bool isValid = false; if (mskDate.Value.ToString() == "") { mskDate.BackColor = colorValid; return(true); } try { if ((Convert.ToInt16(mskDate.Text.Substring(3, 2)) > 12 || Convert.ToInt16(mskDate.Text.Substring(3, 2)) < 1) || (Convert.ToInt16(mskDate.Text.Substring(6, 2)) > 31 || Convert.ToInt16(mskDate.Text.Substring(6, 2)) < 1)) { mskDate.BackColor = colorInvalid; return(false); } else { try { FarsiLibrary.Utils.PersianDate pDate = FarsiLibrary.Utils.PersianDate.Parse("13" + mskDate.Text); isValid = true; mskDate.BackColor = colorValid; } catch { isValid = false; } } } catch { mskDate.BackColor = colorInvalid; return(false); } if (isValid) { mskDate.BackColor = colorValid; } else { mskDate.BackColor = colorInvalid; } return(isValid); }
public void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { int todayIndex; foreach (System.Windows.Shapes.Rectangle item in Rectangles) { item.Style = (System.Windows.Style)FindResource("RectangleStyleNone"); if (item.Style == (System.Windows.Style)FindResource("RectangleStyleToday")) { todayIndex = Rectangles.IndexOf(item); } } SelectedRectangleBaseName = System.Text.RegularExpressions.Regex.Replace((sender as System.Windows.Controls.Grid).Name, @"Grid", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Windows.Shapes.Rectangle SelectedRectangle = FindName("Rectangle" + SelectedRectangleBaseName) as System.Windows.Shapes.Rectangle; int Index = Rectangles.IndexOf(SelectedRectangle); System.Windows.Controls.TextBlock SelectedTextBlock = TextBlocks.ElementAt(Index); if ((SelectedRectangle.Style == FindResource("RectangleStyleNone") && SelectedTextBlock.Style == FindResource("TextBlockStyleForOtherMonths"))) { return; } foreach (int index in IntEventedIndex) { (Rectangles.ElementAt(index)).Style = (System.Windows.Style)FindResource("RectangleStyleEventedDay"); } SelectedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleToday"); PreviousRectangle = SelectedRectangle; ////بدست آوردن اطلاعات امروز this.yearPersian = this.yearForNavigating; this.monthPersian = this.monthForNavigating; this.dayPersian = (FindName("TextBlock" + SelectedRectangleBaseName) as System.Windows.Controls.TextBlock).Text.ConvertToInteger(); SelectedDateTime = new FarsiLibrary.Utils.PersianDate(yearPersian, monthPersian, dayPersian); SelectedDateTimeChanged?.Invoke(this, System.EventArgs.Empty); }
public DatePickerPopup() { this.InitializeComponent(); GetRectangles(); GetTextBoxes(); PreviousRectangle = Rectangles .Where(current => current.Style == (System.Windows.Style)FindResource("RectangleStyleToday")) .FirstOrDefault(); PreviousRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleNone"); SelectedDateTime = FarsiLibrary.Utils.PersianDate.Now; this.currentYear = SelectedDateTime.Year; this.currentMonth = SelectedDateTime.Month; this.currentDay = SelectedDateTime.Day; CalculateMonth(currentYear, currentMonth); }
static public string CurrentPersianDateWithoutSlash() { FarsiLibrary.Utils.PersianDate pd = FarsiLibrary.Utils.PersianDateConverter.ToPersianDate(DateTime.Now.ToString()); string d, m; d = pd.Day.ToString(); m = pd.Month.ToString(); if (d.Length == 1) { d = "0" + d; } if (m.Length == 1) { m = "0" + m; } return(pd.Year.ToString() + m + d); }
public static void ExportToPdf(this Stimulsoft.Report.StiReport report, string reportTitle) { _saveFileDialog = new Microsoft.Win32.SaveFileDialog(); _saveFileDialog.Filter = "PDF Files | *.pdf"; _saveFileDialog.Title = "Save as Pdf"; _saveFileDialog.OverwritePrompt = true; FarsiLibrary.Utils.PersianDate oPersianDate = FarsiLibrary.Utils.PersianDateConverter.ToPersianDate(System.DateTime.Now); _saveFileDialog.FileName = string.Format("{6} {5}-{4}-{3}-{2}-{1}-{0}", oPersianDate.Year, oPersianDate.Month.ToString("00"), oPersianDate.Day.ToString("00"), oPersianDate.Hour.ToString("00"), oPersianDate.Minute.ToString("00"), oPersianDate.Second.ToString("00"), reportTitle ); if (_saveFileDialog.ShowDialog() == true) { string path = System.IO.Path.GetFullPath(_saveFileDialog.FileName); report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, path); System.Windows.MessageBoxResult oDialogResult = Infrastructure.MessageBox.Show ( caption: Infrastructure.MessageBox.Caption.Question, text: "خروجی گزارش با موفقیت ذخیره گردید." + System.Environment.NewLine + "آیا مایل به مشاهده خروجی میباشید؟" ); if (oDialogResult == System.Windows.MessageBoxResult.Yes) { System.Diagnostics.Process.Start(path); } } }
private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DAL.UnitOfWork oUnitOfWork = null; oUnitOfWork = new DAL.UnitOfWork(); Models.Member oMember = oUnitOfWork.MemberRepository .GetById(Utility.CurrentMember.Id); Models.Fund oFund = oUnitOfWork.FundRepository .GetById(Utility.CurrentFund.Id); Models.Loan oLoan = new Models.Loan(); this.Dispatcher.Invoke(() => { oLoan.LoanAmount = LoanAmountTextBox.Text.StringToMoney(); oLoan.IsActive = true; oLoan.IsPayed = false; oLoan.MemberId = Utility.CurrentMember.Id; oLoan.InstallmentsCount = System.Convert.ToInt32(InstallmentsCountTextBox.Text.Trim()); oLoan.RefundAmount = LoanAmountTextBox.Text.StringToMoney(); oLoan.StartDate = LoanDateTimeDatePicker.SelectedDateTime; oLoan.EndDate = LoanDateTimeDatePicker.SelectedDateTime; oLoan.Description = DescriptionTextBox.Text.Trim(); }); oUnitOfWork.LoanRepository.Insert(oLoan); oFund.Balance -= oLoan.LoanAmount; oUnitOfWork.FundRepository.Update(oFund); oUnitOfWork.Save(); Utility.CurrentFund = oFund; Models.Transaction oTransaction = new Models.Transaction(); oTransaction.Amount = oLoan.LoanAmount; oTransaction.Balance = oFund.Balance; oTransaction.Date = System.DateTime.Now; oTransaction.Description = string.Format("پرداخت وام به مبلغ {0} ریال به {1}", oLoan.LoanAmount, Utility.CurrentMember.FullName); oTransaction.FundId = Utility.CurrentFund.Id; oTransaction.TransactionType = Models.TransactionType.Loan; oTransaction.MemberId = Utility.CurrentMember.Id; oTransaction.LoanId = oLoan.Id; oUnitOfWork.TransactionRepository.Insert(oTransaction); int percent = 0; this.Dispatcher.Invoke(() => { percent = (CalculatePercentCheckBox.IsChecked == true) ? Utility.CurrentFund.Percent : 0; }); ViewModels.CreateLoanViewModel oCreateLoanViewModel = CalculateLoanParameters(oLoan.LoanAmount, oLoan.InstallmentsCount, percent); for (int index = 0; index < oLoan.InstallmentsCount; index++) { int progressBarPercent = System.Convert.ToInt32(((double)(index + 1) / oLoan.InstallmentsCount) * 100); Models.Installment oInstallment = new Models.Installment(); oInstallment.PaymentAmount = oCreateLoanViewModel.Installments.ElementAt(index); oInstallment.IsPayed = false; oInstallment.InstallmentDate = oLoan.StartDate.AddMonths(index + 1); oInstallment.PaymentDate = null; oInstallment.LoanId = oLoan.Id; oUnitOfWork.InstallmentRepository.Insert(oInstallment); Models.Reminder oReminder = new Models.Reminder(); FarsiLibrary.Utils.PersianDate oPersianDate = new FarsiLibrary.Utils.PersianDate(oInstallment.InstallmentDate); oReminder.DateTime = oInstallment.InstallmentDate; oReminder.PersianDate.Year = oPersianDate.Year; oReminder.PersianDate.Month = oPersianDate.Month; oReminder.PersianDate.Day = oPersianDate.Day; oReminder.EventType = Models.Event.Installment; oReminder.Description = string.Format("قسط {0} وام {1} به مبلغ {2}", FarsiLibrary.Utils.ToWords.ToString(index + 1), Utility.CurrentMember.FullName, oInstallment.PaymentAmount.ToRialStringFormat()); oReminder.InstallmentId = oInstallment.Id; oReminder.FundId = Utility.CurrentFund.Id; oUnitOfWork.RemainderRepository.Insert(oReminder); if (index == oLoan.InstallmentsCount - 1) { oLoan.EndDate = oInstallment.InstallmentDate; oLoan.RefundAmount = oCreateLoanViewModel.RefundAmount; oUnitOfWork.LoanRepository.Update(oLoan); } oUnitOfWork.Save(); (sender as System.ComponentModel.BackgroundWorker).ReportProgress(progressBarPercent); } Utility.CurrentLoan = oLoan; oMember.Balance += oLoan.LoanAmount; oUnitOfWork.MemberRepository.Update(oMember); oUnitOfWork.Save(); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { FarsiLibrary.Utils.PersianDate oPersianDate = FarsiLibrary.Utils.PersianDate.Today; fundBuildYearTextBox.Text = oPersianDate.Year.ToString(); }
public string Convert_to_Midaly(string ShamsiDate, string time) { string str = ""; string year = ""; string month = ""; string day = ""; string hour = ""; string min = ""; string sec = ""; DateTime dtt; FarsiLibrary.Utils.PersianDate pd = new FarsiLibrary.Utils.PersianDate(ShamsiDate); dtt = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(pd); year = dtt.Year.ToString(); month = dtt.Month.ToString(); day = dtt.Day.ToString(); if (month.Length == 1) { month = "0" + month; } if (day.Length == 1) { day = "0" + day; } DateTime dt = Convert.ToDateTime(year + "/" + month + "/" + day + " " + time); year = dt.Year.ToString(); month = dt.Month.ToString(); day = dt.Day.ToString(); hour = dt.Hour.ToString(); min = dt.Minute.ToString(); sec = dt.Second.ToString(); if (month.Length == 1) { month = "0" + month; } if (day.Length == 1) { day = "0" + day; } if (hour.Length == 1) { hour = "0" + hour; } if (min.Length == 1) { min = "0" + min; } if (sec.Length == 1) { sec = "0" + sec; } str = year + "/" + month + "/" + day + " " + hour + ":" + min + ":" + sec; return str; }
public string Convert_to_Midaly(string ShamsiDate) { string str = ""; string year = ""; string month = ""; string day = ""; DateTime dtt; FarsiLibrary.Utils.PersianDate pd = new FarsiLibrary.Utils.PersianDate(ShamsiDate); dtt = FarsiLibrary.Utils.PersianDateConverter.ToGregorianDateTime(pd); year = dtt.Year.ToString(); month = dtt.Month.ToString(); day = dtt.Day.ToString(); if (month.Length == 1) { month = "0" + month; } if (day.Length == 1) { day = "0" + day; } DateTime dt = Convert.ToDateTime(year + "/" + month + "/" + day); year = dt.Year.ToString(); month = dt.Month.ToString(); day = dt.Day.ToString(); if (month.Length == 1) { month = "0" + month; } if (day.Length == 1) { day = "0" + day; } str = year + "/" + month + "/" + day + " "; return str; }
void CalculateMonth(int thisYear, int thisMonth) { IntEventedIndex = new System.Collections.Generic.List <int>(); try { yearForNavigating = thisYear; monthForNavigating = thisMonth; System.DateTime tempDateTime = persianCalendar.ToDateTime(yearForNavigating, monthForNavigating, 15, 01, 01, 01, 01); int thisDay = 1; TextBlockThisMonth.Text = string.Empty; TextBlockThisMonth.Text = monthForNavigating.ConvertToPersianMonth() + " " + yearForNavigating.ConvertToPersianNumber(); //Different between first place of calendar and first place of this month //اختلاف بین خانه شروع ماه و اولین خانه تقویم string DayOfWeek = persianCalendar.GetDayOfWeek(persianCalendar.ToDateTime(thisYear, thisMonth, 01, 01, 01, 01, 01)).ToString(); int span = CalculatePersianSpan(DayOfWeek.ConvertToPersianDay()); DecreasePersianDay(ref thisYear, ref thisMonth, ref thisDay, span); string persianDate;//حاوی تاریخ روزهای شمسی Contains the date of Persian //////////////////////////////////// for (int i = 0; i < 6 * 7; i++) { tempDateTime = persianCalendar.ToDateTime(thisYear, thisMonth, thisDay, 01, 01, 01, 01); persianDate = thisDay.ConvertToPersianNumber(); DayOfWeek = persianCalendar.GetDayOfWeek(tempDateTime).ToString(); //RectangleStyleEventedDay if (thisMonth == monthForNavigating) // ماه کنونی { if (thisDay == currentDay && thisMonth == currentMonth && thisYear == currentYear) // امروز { if (GetEventCountOfDay(thisYear, thisMonth, thisDay) != 0) { IntEventedIndex.Add(i); } ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.TodayStyle, Infrastructure.Resources.PersianDatePicker.ThisMonthTextBlockStyle); SelectedDateTime = new FarsiLibrary.Utils.PersianDate(thisYear, thisMonth, thisDay); SelectedDateTimeChanged?.Invoke(this, System.EventArgs.Empty); } else // سایر روزهای ماه کنونی { if (GetEventCountOfDay(thisYear, thisMonth, thisDay) == 0) { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.NoneStyle, Infrastructure.Resources.PersianDatePicker.ThisMonthTextBlockStyle); } else { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.EventedDayStyle, Infrastructure.Resources.PersianDatePicker.ThisMonthTextBlockStyle); IntEventedIndex.Add(i); } } } else // ماه های دیگر { ChangeProperties(i, persianDate, Infrastructure.Resources.PersianDatePicker.NoneStyle, Infrastructure.Resources.PersianDatePicker.OutOfThisMonthTextBlockStyle); } IncreasePersianDay(ref thisYear, ref thisMonth, ref thisDay, 1); } } catch (System.Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Exception", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }