public bool IsFullday() { var start = Start.ToDayStart(); var end = Start.AddDays(1).ToDayStart(); return(Start == start && End == end); }
public void Update() { Active = Start <DateTime.Now && Start.Add(Duration)> DateTime.Now; if (RepeatType != GERepeatType.None && Start.Add(Duration) < DateTime.Now) { updateCondition: switch (RepeatType) { case GERepeatType.Annually: Start = Start.AddYears(1); break; case GERepeatType.Monthly: Start = Start.AddMonths(1); break; case GERepeatType.Weekly: Start = Start.AddDays(7); break; case GERepeatType.Daily: Start = Start.AddDays(1); break; } if (Start.Add(Duration) < DateTime.Now) { goto updateCondition; } Logger .ForContext(Constants.SourceContextPropertyName, Name) .Information("Updated active period, Start {0} - End {1}", Start, Start.Add(Duration)); } }
public Project() { Jobs = new HashSet <Job>(); TagProjectRelations = new HashSet <TagProject>(); Start = DateTime.Now; End = Start.AddDays(1); }
public void AddOrder(object target, object source, IDropInfo dropInfo) { Console.WriteLine("AddOrder"); //ObservableCollection<Models.Task> tasks = dropInfo.TargetCollection as ObservableCollection<Models.Task>; ScheduleTasks tasks = null; BookedOrder order = source as BookedOrder; DateTime start = Start; if (tasks.Count > 0) { start = tasks.Last().End.AddMinutes(1); } var procTime = order.BookQty / order.WPD; DateTime end = Start.AddDays((double)procTime); ScheduleTask task = new ScheduleTask() { Description = String.Format("{0} {1}", order.CustShortName, order.CustSpecNickName, order.OrdNum, order.OrdItem), Start = start, End = end }; tasks.Add(task); }
private void week(DateTime start) { Start = GetFirstDateOfWeek(start, CultureInfo.CurrentCulture); End = Start.AddDays(7).Subtract(TimeSpan.FromSeconds(1)); Granularity = TimeGranularity.Week; setWeekNumber(); }
public void MoveToWeek(DateTime weekStart) { int weeks = (int)Math.Ceiling((weekStart - Start).TotalDays / 7); Start = Start.AddDays(7 * weeks); End = End.AddDays(7 * weeks); }
public void ValueCheck() { Start = Start == DateTime.MinValue ? DateTime.Now.Date : Start; var end = string.IsNullOrWhiteSpace(ParentKey) ? Start.AddMonths(1) : Start.AddDays(7); End = End == DateTime.MinValue ? end : End; Name = string.IsNullOrWhiteSpace(Name) ? $"{Start.ToString("yyyy年M月d日")} - {End.ToString("M月d日")}" : Name; }
static TeamData() { Random = new Random(); Start = GetStart(); if (ViewModelBase.IsInDesignMode) { Employees = new List <Employee>(); Calendars = CreateCalendars().ToList(); VacationAppointments = new TeamAppointment[] { }; CompanyBirthdayAppointments = new TeamAppointment[] { }; BirthdayAppointments = new TeamAppointment[] { }; ConferenceAppointments = new TeamAppointment[] { }; MeetingAppointments = new TeamAppointment[] { }; PhoneCallsAppointments = new TeamAppointment[] { }; CarWashAppointments = new TeamAppointment[] { }; PayBillsAppointments = new TeamAppointment[] { }; DentistAppointments = new TeamAppointment[] { }; RestaurantAppointments = new TeamAppointment[] { }; AllAppointments = new TeamAppointment[] { }; return; } //Employees = NWindContext.Create().Employees.ToList(); Employees[0].BirthDate = Start.AddDays(4).AddYears(-30); Calendars = CreateCalendars().ToList(); VacationAppointments = CreateVacationsAppts(Start).ToList(); CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList(); BirthdayAppointments = CreateBirthdayAppts(Start).ToList(); ConferenceAppointments = CreateConferenceAppts(Start).ToList(); MeetingAppointments = CreateMeetingAppts(Start).ToList(); PhoneCallsAppointments = CreatePhoneCallsAppts(Start).ToList(); CarWashAppointments = CreateCarWashAppts(Start).ToList(); TrainingAppointments = CreateTrainingAppts(Start).ToList(); PayBillsAppointments = CreatePayBillsAppts(Start).ToList(); DentistAppointments = CreateDentistAppts(Start).ToList(); RestaurantAppointments = CreateRestaurantAppts(Start).ToList(); AllAppointments = VacationAppointments .Concat(BirthdayAppointments) .Concat(CompanyBirthdayAppointments) .Concat(ConferenceAppointments) .Concat(MeetingAppointments) .Concat(PhoneCallsAppointments) .Concat(CarWashAppointments) .Concat(TrainingAppointments) .Concat(PayBillsAppointments) .Concat(DentistAppointments) .Concat(RestaurantAppointments) .ToList(); int id = 0; foreach (TeamAppointment appt in AllAppointments) { appt.Id = id++; } }
void IInitializable.Initialize() { Start = RoundUpDateTime(DateTime.Now.AddDays(-1), TimeSpan.FromDays(1)); End = Start.AddDays(NbrOfDaysOut); ScheduleCode = ScheduleCodes.MasterSchedCode; Reactors = new ObservableRangeCollection <ReactorViewModel>(); _timer.Interval = TimeSpan.FromMinutes(5); _timer.Tick += new EventHandler(UpdateStartTime); _timer.Start(); }
public JobInput() { State = StateType.OnHold; EnabledSeeComment = false; EnabledDeleteComment = false; EnabledSeeJob = true; EnabledEditJob = false; EnabledDeleteJob = false; Start = DateTime.Now; End = Start.AddDays(1); }
public void ReviseReminder(double reminderTime, AssessmentReminderUnit reminderUnit, Email sendToEmail = null) { RaiseEvent(new AssessmentReminderRevisedEvent(Key, Version, reminderTime, reminderUnit, sendToEmail)); if (AlertSentDate.HasValue) //mark for re-send { var thresholdDate = reminderUnit == AssessmentReminderUnit.Days ? Start.AddDays(-Convert.ToInt32(reminderTime)) : Start.AddDays(-Convert.ToInt32(reminderTime * 7)); if (DateTime.Now < thresholdDate) { RaiseEvent(new AssessmentReminderUpdatedEvent(Key, Version, a => a.AlertSentDate, null)); } } }
public Job() { State = StateType.OnHold; TagJobRelations = new HashSet <TagJob>(); Comments = new HashSet <Comment>(); EnabledSeeComment = false; EnabledDeleteComment = false; EnabledSeeJob = true; EnabledEditJob = false; EnabledDeleteJob = false; Start = DateTime.Now; End = Start.AddDays(1); }
public Routine() { RoutineName = ""; TotalSessions = 0; IsEmpty = true; Start = DateTime.Now; Finish = Start.AddDays(60); Duration = Finish.Subtract(Start); WhenIHaveToWorkout.Add(DaysOfWeek.MONDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.TUESDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.WEDNESDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.THURSDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.FRIDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.SATURDAY, false); WhenIHaveToWorkout.Add(DaysOfWeek.SUNDAY, false); }
private double Period_Working_Days_With_Rounding(int deciamls) { var totalDays = End.Subtract(Start).Days + 1; var dates = Enumerable.Range(0, totalDays) .Select(i => Start.AddDays(i)) .Where(d => !Weekends.Contains(d.DayOfWeek)); var rawDays = dates.Count(); var weeks = Period_Weeks_With_Rounding(deciamls); var daysToRemove = 0.0; if (totalDays >= DaysPerWeek) { daysToRemove = WorkDaysInWeek - DaysPerWeek; } return(rawDays - (daysToRemove * weeks)); }
public WorkingWeek(DateTime date) { date = DateTime.SpecifyKind(date.Date, DateTimeKind.Utc); var firstDayOfWeek = DayOfWeek.Monday; int offset = firstDayOfWeek - date.DayOfWeek; if (offset != 1) { Start = date.AddDays(offset); End = Start.AddDays(4); } else { //Sunday Start = date.AddDays(-6); End = date.AddDays(-2); } }
private void UpdateStartTime(Object sender, EventArgs e) { if (!Loading) { //foreach (var reactorViewModel in Reactors.ToList()) { // reactorViewModel.RemoveProcessedTasks(); // reactorViewModel.RefreshLayout(); //} if (_startTimeFakeOut == 0) { Start = RoundUpDateTime(DateTime.Now.AddDays(-2), TimeSpan.FromDays(2)); End = Start.AddDays(NbrOfDaysOut + 2); _startTimeFakeOut = 1; } else { Start = RoundUpDateTime(DateTime.Now.AddDays(-1), TimeSpan.FromDays(1)); End = Start.AddDays(NbrOfDaysOut + 1); _startTimeFakeOut = 0; } } }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); if (Scheduler == null) { return; } Pen pen = new Pen(Brushes.Black); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; Rectangle monthRect; for (int i = 0; i < 5; i++) { monthRect = new Rectangle(new Point(pe.ClipRectangle.Location.X, WeekRectParameters[i].Y), new Size(pe.ClipRectangle.Width - 1, WeekRectParameters[i].Height)); pe.Graphics.DrawRectangle(pen, monthRect); int numberStart = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Start.AddDays(7 * i), CalendarWeekRule.FirstDay, DayOfWeek.Monday); int numberEnd = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Start.AddDays(7 * i + 6), CalendarWeekRule.FirstFullWeek, DayOfWeek.Sunday); string weekNumber = ""; if (numberStart == numberEnd) { weekNumber = numberStart.ToString(); } else { weekNumber = numberStart.ToString() + " / " + numberEnd.ToString(); } pe.Graphics.DrawString(weekNumber, Scheduler.Appearance.HeaderCaption.Font, Brushes.Black, monthRect, sf); } }
void _Scheduler_CustomDrawTimeCell(object sender, CustomDrawObjectEventArgs e) { MonthSingleWeekCell cell = e.ObjectInfo as MonthSingleWeekCell; if (cell == null) { return; } if (cell.Interval.Start.DayOfWeek == DayOfWeek.Monday) { for (int i = 0; i < 5; i++) { if (cell.Interval.Start == Start.AddDays(i * 7)) { WeekRectParameters[i] = new RectParameters() { Y = e.Bounds.Y, Height = e.Bounds.Height }; } } Invalidate(); } }
public DateTimeRange SpreadByDays(int daysStart, int daysEnd) { return(new DateTimeRange( start: Start.AddDays(-daysStart), end: End.AddDays(daysEnd))); }
public TaskModel() { Start = DateTime.Now; End = Start.AddDays(30); }
/// <summary> /// 前后扩展N天 /// </summary> /// <param name="value"></param> /// <returns></returns> public DateRange ExtendDay(double value) { return(new DateRange(Start.AddDays(-value), End.AddDays(value))); }
public BroadcastWeek AddWeeks(int weeks) { return(new BroadcastWeek(Start.AddDays(weeks * TimeSpec.DaysPerWeek), Calendar)); }
public Lance() { Start = DateTime.Now; End = Start.AddDays(30); StatusLance = true; }
static TeamData() { Random = new Random(); Start = GetStart(); if (ViewModelBase.IsInDesignMode) { Employees = new List <Employee>(); Calendars = CreateCalendars().ToList(); VacationAppointments = new TeamAppointment[] { }; CompanyBirthdayAppointments = new TeamAppointment[] { }; BirthdayAppointments = new TeamAppointment[] { }; ConferenceAppointments = new TeamAppointment[] { }; MeetingAppointments = new TeamAppointment[] { }; PhoneCallsAppointments = new TeamAppointment[] { }; CarWashAppointments = new TeamAppointment[] { }; PayBillsAppointments = new TeamAppointment[] { }; DentistAppointments = new TeamAppointment[] { }; RestaurantAppointments = new TeamAppointment[] { }; AllAppointments = new TeamAppointment[] { }; return; } Employees = new List <Employee>(); Employees.Add(new Employee() { FirstName = "John1", LastName = "Smith1" }); Employees.Add(new Employee() { FirstName = "John2", LastName = "Smith2" }); Employees.Add(new Employee() { FirstName = "John3", LastName = "Smith3" }); Employees.Add(new Employee() { FirstName = "John4", LastName = "Smith4" }); Employees.Add(new Employee() { FirstName = "John5", LastName = "Smith5" }); Employees.Add(new Employee() { FirstName = "John6", LastName = "Smith6" }); Employees[0].BirthDate = Start.AddDays(4).AddYears(-30); Employees[1].BirthDate = Start.AddDays(1).AddYears(-27); Employees[2].BirthDate = Start.AddDays(14).AddYears(-32); Employees[3].BirthDate = Start.AddDays(-8).AddYears(-41); Employees[4].BirthDate = Start.AddDays(-18).AddYears(-41); Employees[5].BirthDate = Start.AddDays(48).AddYears(-25); Calendars = CreateCalendars().ToList(); VacationAppointments = CreateVacationsAppts(Start).ToList(); CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList(); BirthdayAppointments = CreateBirthdayAppts(Start).ToList(); ConferenceAppointments = CreateConferenceAppts(Start).ToList(); MeetingAppointments = CreateMeetingAppts(Start).ToList(); PhoneCallsAppointments = CreatePhoneCallsAppts(Start).ToList(); CarWashAppointments = CreateCarWashAppts(Start).ToList(); TrainingAppointments = CreateTrainingAppts(Start).ToList(); PayBillsAppointments = CreatePayBillsAppts(Start).ToList(); DentistAppointments = CreateDentistAppts(Start).ToList(); RestaurantAppointments = CreateRestaurantAppts(Start).ToList(); AllAppointments = VacationAppointments .Concat(BirthdayAppointments) .Concat(CompanyBirthdayAppointments) .Concat(ConferenceAppointments) .Concat(MeetingAppointments) .Concat(PhoneCallsAppointments) .Concat(CarWashAppointments) .Concat(TrainingAppointments) .Concat(PayBillsAppointments) .Concat(DentistAppointments) .Concat(RestaurantAppointments) .ToList(); int id = 0; foreach (TeamAppointment appt in AllAppointments) { appt.Id = id++; } List <TimeRegion> regions = new List <TimeRegion>(); regions.Add(new TimeRegion() { Id = 0, Start = DateTime.Today.AddHours(13).AddMinutes(20), End = DateTime.Today.AddHours(14).AddMinutes(45), Brush = new SolidColorBrush(Colors.Blue) { Opacity = 0.4 }, CalendarId = 0, Type = (int)TimeRegionType.Pattern, RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(13).AddMinutes(20)).Build()).ToXml() }); regions.Add(new TimeRegion() { Id = 2, Start = DateTime.Today.AddHours(20), End = DateTime.Today.AddHours(22), Brush = new SolidColorBrush(Colors.DarkBlue) { Opacity = 0.4 }, CalendarId = 0, Type = (int)TimeRegionType.Pattern, RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(20)).Build()).ToXml() }); regions.Add(new TimeRegion() { Id = 1, Start = DateTime.Today.AddHours(13), End = DateTime.Today.AddHours(14), Brush = new SolidColorBrush(Colors.Blue) { Opacity = 0.4 }, CalendarId = 1, Type = (int)TimeRegionType.Pattern, RecurrenceInfo = ((RecurrenceInfo)RecurrenceBuilder.Daily(new DateTime(DateTime.Today.Year, 1, 1).AddHours(13)).Build()).ToXml() }); TimeRegions = regions; }
protected virtual void Create(Dto src, string user, IDbSession session) { Start = src.Start ?? MinimumDate; End = src.End ?? MaximumDate; var set = session.DbContext.Set <T>(); var items = set.Where(SeriesExpression).ToArray(); var replacing = items.Where(args => Start <= args.Start && args.End <= End); set.RemoveRange(replacing); var front = items.Where(args => args.Start < Start && args.End >= Start && args.End <= End); foreach (var item in front) { if (CanMerge(item)) { set.Remove(item); if (item.Start < Start) { Start = item.Start; } } else { item.End = Start.AddDays(-1); } } var back = items.Where(args => Start <= args.Start && args.Start <= End && End < args.End); foreach (var item in back) { if (CanMerge(item)) { set.Remove(item); if (item.End > End) { End = item.End; } } else { item.Start = End.AddDays(1); } } var overlap = items.Where(args => args.Start <Start && args.End> End); foreach (var item in overlap) { if (CanMerge(item)) { set.Remove(item); if (item.Start < Start) { Start = item.Start; } if (item.End > End) { End = item.End; } } else { var clone = item.Clone(user); item.End = Start.AddDays(-1); clone.Start = End.AddDays(1); set.Add(clone); } } base.Create(user); }
static TeamData() { Random = new Random(); Start = GetStart(); if (ViewModelBase.IsInDesignMode) { Employees = new List <Employee>(); Calendars = CreateCalendars().ToList(); VacationAppointments = new TeamAppointment[] { }; CompanyBirthdayAppointments = new TeamAppointment[] { }; BirthdayAppointments = new TeamAppointment[] { }; ConferenceAppointments = new TeamAppointment[] { }; MeetingAppointments = new TeamAppointment[] { }; PhoneCallsAppointments = new TeamAppointment[] { }; CarWashAppointments = new TeamAppointment[] { }; PayBillsAppointments = new TeamAppointment[] { }; DentistAppointments = new TeamAppointment[] { }; RestaurantAppointments = new TeamAppointment[] { }; AllAppointments = new TeamAppointment[] { }; return; } Employees = new List <Employee>(); Employees.Add(new Employee() { FirstName = "Andrew", LastName = "Glover" }); Employees.Add(new Employee() { FirstName = "Mark", LastName = "Oliver" }); Employees.Add(new Employee() { FirstName = "John", LastName = "Heart" }); Employees.Add(new Employee() { FirstName = "Olivia", LastName = "Peyton" }); Employees.Add(new Employee() { FirstName = "Sandra", LastName = "Johnson" }); Employees.Add(new Employee() { FirstName = "Amelia", LastName = "Harper" }); Employees[0].BirthDate = Start.AddDays(4).AddYears(-30); Employees[1].BirthDate = Start.AddDays(1).AddYears(-27); Employees[2].BirthDate = Start.AddDays(14).AddYears(-32); Employees[3].BirthDate = Start.AddDays(-8).AddYears(-41); Employees[4].BirthDate = Start.AddDays(-18).AddYears(-41); Employees[5].BirthDate = Start.AddDays(48).AddYears(-25); Calendars = CreateCalendars().ToList(); VacationAppointments = CreateVacationsAppts(Start).ToList(); CompanyBirthdayAppointments = CreateCompanyBirthdayAppts(Start).ToList(); BirthdayAppointments = CreateBirthdayAppts(Start).ToList(); ConferenceAppointments = CreateConferenceAppts(Start).ToList(); MeetingAppointments = CreateMeetingAppts(Start).ToList(); PhoneCallsAppointments = CreatePhoneCallsAppts(Start).ToList(); CarWashAppointments = CreateCarWashAppts(Start).ToList(); TrainingAppointments = CreateTrainingAppts(Start).ToList(); PayBillsAppointments = CreatePayBillsAppts(Start).ToList(); DentistAppointments = CreateDentistAppts(Start).ToList(); RestaurantAppointments = CreateRestaurantAppts(Start).ToList(); AllAppointments = VacationAppointments .Concat(BirthdayAppointments) .Concat(CompanyBirthdayAppointments) .Concat(ConferenceAppointments) .Concat(MeetingAppointments) .Concat(PhoneCallsAppointments) .Concat(CarWashAppointments) .Concat(TrainingAppointments) .Concat(PayBillsAppointments) .Concat(DentistAppointments) .Concat(RestaurantAppointments) .ToList(); int id = 0; foreach (TeamAppointment appt in AllAppointments) { appt.Id = id++; } }
/// <summary> /// Se esse torneio deve ou não aparecer no menu, com relação a data em que está sendo listado /// </summary> public bool ShouldAppear(DateTime date) { return((Start.AddDays(-14) <= date) && (date <= End.AddDays(14))); }
protected override String DoIt() { StringBuilder Sql = new StringBuilder(); string newcon = ""; String date = string.Format("{0:dd/MM/yy}", today); int Record_id = GetRecord_ID(); X_C_Contract con = new X_C_Contract(GetCtx(), Record_id, Get_TrxName()); if (Record_id != 0) { Sql.Append("SELECT RenewalType FROM C_Contract WHERE C_Contract_ID = " + Record_id + " AND RenewContract = 'N' AND IsActive = 'Y' AND AD_Client_ID = " + GetAD_Client_ID()); string renewType = Util.GetValueOfString(DB.ExecuteScalar(Sql.ToString(), null, Get_TrxName())); if (renewType == "M") { Sql.Clear(); Sql.Append("SELECT C_Contract_ID FROM C_Contract WHERE C_Contract_ID=" + Record_id + " AND RenewContract = 'N' AND AD_Client_ID = " + GetAD_Client_ID()); } else { Sql.Clear(); Sql.Append("SELECT C_Contract_ID FROM C_Contract WHERE (EndDate- NVL(CancelBeforeDays,0)) <= SYSDATE AND C_Contract_ID=" + Record_id + " AND RenewContract = 'N' AND AD_Client_ID = " + GetAD_Client_ID()); } } else { Sql.Clear(); Sql.Append("SELECT C_Contract_ID FROM C_Contract WHERE (EndDate- NVL(CancelBeforeDays,0)) <= SYSDATE AND RenewalType='A' AND RenewContract = 'N' AND AD_Client_ID = " + GetAD_Client_ID()); } IDataReader dr = DB.ExecuteReader(Sql.ToString(), null, Get_TrxName()); int count = 0; decimal Listprice = 0, Stdprice = 0, TotalRate = 0; int cycles = 0, duration = 0, frequency = 0, months = 0; DateTime? CDate = null; DateTime OldStart, Start, endDate; MPriceList priceList = null; MTax tax = null; X_C_Contract contact = null; X_C_Contract New = null; ValueNamePair pp = null; try { while (dr.Read()) { contact = new X_C_Contract(GetCtx(), Util.GetValueOfInt(dr[0]), Get_TrxName()); if (contact.GetRenewalType() == "M") { // SI_0772: By Clicking on Renew Contract, System is throwing an error as 'NoContractReNewed'. CDate = contact.GetCancellationDate(); cycles = Util.GetValueOfInt(contact.GetCycles()); if (CDate != null) { continue; } New = new X_C_Contract(GetCtx(), 0, Get_TrxName()); New.SetRefContract(contact.GetDocumentNo()); New.SetC_Order_ID(contact.GetC_Order_ID()); New.SetC_OrderLine_ID(contact.GetC_OrderLine_ID()); OldStart = (DateTime)(contact.GetStartDate()); Start = (DateTime)(contact.GetEndDate()); New.SetStartDate(Start.AddDays(1)); New.SetC_BPartner_ID(contact.GetC_BPartner_ID()); New.SetBill_Location_ID(contact.GetBill_Location_ID()); New.SetBill_User_ID(contact.GetBill_User_ID()); New.SetSalesRep_ID(contact.GetSalesRep_ID()); New.SetC_ConversionType_ID(contact.GetC_ConversionType_ID()); New.SetC_PaymentTerm_ID(contact.GetC_PaymentTerm_ID()); frequency = contact.GetC_Frequency_ID(); New.SetC_Frequency_ID(frequency); // Get No Of Months from Frequency months = Util.GetValueOfInt(DB.ExecuteScalar("SELECT NoOfMonths FROM C_Frequency WHERE C_Frequency_ID=" + frequency, null, Get_TrxName())); duration = months * cycles; endDate = New.GetStartDate().Value.AddMonths(duration); endDate = endDate.AddDays(-1); New.SetEndDate(endDate); New.SetTotalInvoice(cycles); if (Record_id != 0) { // JID_1124: System has to pick the Pricelist in Service Contract as defined in Renewal Pricelist. also need to pick Price from Latest Valid From Date Version New.SetM_PriceList_ID(contact.GetRef_PriceList_ID()); priceList = new MPriceList(GetCtx(), contact.GetRef_PriceList_ID(), Get_TrxName()); Sql.Clear(); Sql.Append("SELECT pp.PriceList, pp.PriceStd FROM M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID" + " WHERE pp.M_Product_ID=" + contact.GetM_Product_ID() + " AND plv.IsActive='Y' AND plv.M_PriceList_ID=" + contact.GetRef_PriceList_ID() + " AND plv.VALIDFROM <= SYSDATE ORDER BY plv.VALIDFROM DESC"); DataSet ds = DB.ExecuteDataset(Sql.ToString(), null, Get_TrxName()); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { Listprice = Util.GetValueOfDecimal(ds.Tables[0].Rows[0]["PriceList"]); Stdprice = Util.GetValueOfDecimal(ds.Tables[0].Rows[0]["PriceStd"]); } else { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ProductNotOnPriceList")); } //int Version = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //Query = "SELECT PriceList FROM M_ProductPrice WHERE M_PriceList_Version_ID=" + Version + " AND M_Product_ID=" + contact.GetM_Product_ID(); //decimal Listprice = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //Query = "SELECT PriceStd FROM M_ProductPrice WHERE M_PriceList_Version_ID=" + Version + " AND M_Product_ID=" + contact.GetM_Product_ID(); //decimal Stdprice = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //if (Stdprice == 0 && Listprice == 0) //{ // dr.Close(); // return Msg.GetMsg(GetCtx(), "ProductNotINPriceList"); //} New.SetPriceEntered(Stdprice); New.SetPriceActual(Stdprice); New.SetPriceList(Listprice); } else { priceList = new MPriceList(GetCtx(), contact.GetM_PriceList_ID(), Get_TrxName()); New.SetM_PriceList_ID(contact.GetM_PriceList_ID()); New.SetPriceEntered(contact.GetPriceEntered()); New.SetPriceActual(contact.GetPriceActual()); New.SetPriceList(contact.GetPriceList()); } New.SetC_Currency_ID(priceList.GetC_Currency_ID()); New.SetC_UOM_ID(contact.GetC_UOM_ID()); New.SetM_Product_ID(contact.GetM_Product_ID()); New.SetM_AttributeSetInstance_ID(contact.GetM_AttributeSetInstance_ID()); New.SetQtyEntered(contact.GetQtyEntered()); New.SetC_Tax_ID(contact.GetC_Tax_ID()); New.SetC_Campaign_ID(contact.GetC_Campaign_ID()); New.SetRef_Contract_ID(contact.GetC_Contract_ID()); New.SetC_Project_ID(contact.GetC_Project_ID()); New.SetDescription(contact.GetDescription()); //New.SetTaxAmt(contact.GetTaxAmt()); New.SetCancelBeforeDays(contact.GetCancelBeforeDays()); New.SetCycles(contact.GetCycles()); New.SetRenewContract("N"); New.SetScheduleContract("N"); New.SetDocStatus("DR"); New.SetRenewalType("M"); New.SetLineNetAmt(Decimal.Multiply(New.GetPriceEntered(), New.GetQtyEntered())); //String sqltax = "SELECT Rate FROM C_Tax WHERE C_Tax_ID=" + contact.GetC_Tax_ID(); //Decimal? Rate = Util.GetValueOfDecimal(DB.ExecuteScalar(sqltax, null, Get_TrxName())); //Decimal? TotalRate = Util.GetValueOfDecimal((Util.GetValueOfDecimal(New.GetLineNetAmt()) * Util.GetValueOfDecimal(Rate)) / 100); //TotalRate = Decimal.Round(TotalRate.Value, 2); // if Surcharge Tax is selected on Tax, then set value in Surcharge Amount if (New.Get_ColumnIndex("SurchargeAmt") > 0 && tax.GetSurcharge_Tax_ID() > 0) { Decimal surchargeAmt = Env.ZERO; // Calculate Surcharge Amount TotalRate = tax.CalculateSurcharge(New.GetLineNetAmt(), priceList.IsTaxIncluded(), priceList.GetStandardPrecision(), out surchargeAmt); New.SetTaxAmt(TotalRate); New.SetSurchargeAmt(surchargeAmt); } else { // Calculate Tax Amount tax = MTax.Get(GetCtx(), contact.GetC_Tax_ID()); TotalRate = tax.CalculateTax(New.GetLineNetAmt(), priceList.IsTaxIncluded(), priceList.GetPricePrecision()); New.SetTaxAmt(TotalRate); } // Calculate Discount % Decimal?dis = Decimal.Multiply(Decimal.Divide(Decimal.Subtract(New.GetPriceList(), New.GetPriceEntered()), New.GetPriceList()), 100); New.SetDiscount(dis); // Set Grand Total Amount if (priceList.IsTaxIncluded()) { New.SetGrandTotal(New.GetLineNetAmt()); } else { if (New.Get_ColumnIndex("SurchargeAmt") > 0) { New.SetGrandTotal(Decimal.Add(Decimal.Add(New.GetLineNetAmt(), New.GetTaxAmt()), New.GetSurchargeAmt())); } else { New.SetGrandTotal(Decimal.Add(New.GetLineNetAmt(), New.GetTaxAmt())); } } if (contact.GetBillStartDate() != null) { New.SetBillStartDate(contact.GetBillStartDate().Value.AddMonths(contact.GetTotalInvoice())); } else { New.SetBillStartDate(New.GetStartDate()); } if (New.Save()) { newcon = New.GetDocumentNo(); count++; if (Record_id != 0) { contact.SetRef_Contract_ID(New.GetC_Contract_ID()); contact.SetRenewContract("Y"); if (!contact.Save()) { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } } } else { dr.Close(); Get_TrxName().Rollback(); pp = VLogger.RetrieveError(); if (pp != null) { return(!String.IsNullOrEmpty(pp.GetName()) ? pp.GetName() : Msg.GetMsg(GetCtx(), "ContractNotRenew")); } else { return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } } } else { // SI_0772: By Clicking on Renew Contract, System is throwing an error as 'NoContractReNewed'. CDate = contact.GetCancellationDate(); cycles = contact.GetCycles(); if (CDate != null) { continue; } New = new X_C_Contract(GetCtx(), 0, Get_TrxName()); New.SetRefContract(contact.GetDocumentNo()); New.SetC_Order_ID(contact.GetC_Order_ID()); New.SetC_OrderLine_ID(contact.GetC_OrderLine_ID()); OldStart = (DateTime)(contact.GetStartDate()); Start = (DateTime)(contact.GetEndDate()); New.SetStartDate(Start.AddDays(1)); frequency = contact.GetC_Frequency_ID(); // Get No Of Months from Frequency months = Util.GetValueOfInt(DB.ExecuteScalar("SELECT NoOfMonths FROM C_Frequency WHERE C_Frequency_ID=" + frequency, null, Get_TrxName())); duration = months * cycles; endDate = New.GetStartDate().Value.AddMonths(duration); endDate = endDate.AddDays(-1); New.SetEndDate(endDate); New.SetC_BPartner_ID(contact.GetC_BPartner_ID()); New.SetBill_Location_ID(contact.GetBill_Location_ID()); New.SetBill_User_ID(contact.GetBill_User_ID()); New.SetSalesRep_ID(contact.GetSalesRep_ID()); New.SetC_ConversionType_ID(contact.GetC_ConversionType_ID()); New.SetC_PaymentTerm_ID(contact.GetC_PaymentTerm_ID()); New.SetC_Frequency_ID(frequency); // invoice Count Start if (Record_id != 0) { if (contact.GetRef_PriceList_ID() == 0) { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "FirstSelectPriceList")); } New.SetM_PriceList_ID(contact.GetRef_PriceList_ID()); priceList = new MPriceList(GetCtx(), contact.GetRef_PriceList_ID(), Get_TrxName()); Sql.Clear(); Sql.Append("SELECT pp.PriceList, pp.PriceStd FROM M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID" + " WHERE pp.M_Product_ID=" + contact.GetM_Product_ID() + " AND plv.IsActive='Y' AND plv.M_PriceList_ID=" + contact.GetRef_PriceList_ID() + " AND plv.VALIDFROM <= SYSDATE ORDER BY plv.VALIDFROM DESC"); DataSet ds = DB.ExecuteDataset(Sql.ToString(), null, Get_TrxName()); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { Listprice = Util.GetValueOfDecimal(ds.Tables[0].Rows[0]["PriceList"]); Stdprice = Util.GetValueOfDecimal(ds.Tables[0].Rows[0]["PriceStd"]); } else { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ProductNotOnPriceList")); } //String Query = "Select M_PriceList_Version_id from M_PriceList_Version where IsActive='Y' and M_PriceList_Id=" + contact.GetRef_PriceList_ID(); //int Version = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //Query = "Select PriceList,PriceStd from M_ProductPrice where M_PriceList_Version_id=" + Version + " and M_Product_ID=" + contact.GetM_Product_ID(); //decimal Listprice = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //Query = "Select PriceList,PriceStd from M_ProductPrice where M_PriceList_Version_id=" + Version + " and M_Product_ID=" + contact.GetM_Product_ID(); //decimal Stdprice = Util.GetValueOfInt(DB.ExecuteScalar(Query)); //if (Stdprice == 0 && Listprice == 0) //{ // return Msg.GetMsg(GetCtx(), "ProductNotINPriceList"); //} New.SetPriceEntered(Stdprice); New.SetPriceActual(Stdprice); New.SetPriceList(Listprice); } else { priceList = new MPriceList(GetCtx(), contact.GetM_PriceList_ID(), Get_TrxName()); New.SetM_PriceList_ID(contact.GetM_PriceList_ID()); New.SetPriceActual(contact.GetPriceActual()); New.SetPriceList(contact.GetPriceList()); New.SetPriceEntered(contact.GetPriceEntered()); } New.SetTotalInvoice(contact.GetCycles()); New.SetC_Currency_ID(priceList.GetC_Currency_ID()); New.SetC_UOM_ID(contact.GetC_UOM_ID()); New.SetM_Product_ID(contact.GetM_Product_ID()); New.SetM_AttributeSetInstance_ID(contact.GetM_AttributeSetInstance_ID()); New.SetQtyEntered(contact.GetQtyEntered()); New.SetC_Tax_ID(contact.GetC_Tax_ID()); New.SetC_Campaign_ID(contact.GetC_Campaign_ID()); New.SetRef_Contract_ID(contact.GetC_Contract_ID()); New.SetC_Project_ID(contact.GetC_Project_ID()); New.SetDescription(contact.GetDescription()); New.SetCancelBeforeDays(contact.GetCancelBeforeDays()); New.SetCycles(contact.GetCycles()); New.SetRenewContract("N"); New.SetScheduleContract("Y"); New.SetRenewalType("A"); New.SetDocStatus("DR"); New.SetLineNetAmt(Decimal.Multiply(New.GetPriceEntered(), New.GetQtyEntered())); // Calculate Tax Amount tax = MTax.Get(GetCtx(), contact.GetC_Tax_ID()); // if Surcharge Tax is selected on Tax, then set value in Surcharge Amount if (New.Get_ColumnIndex("SurchargeAmt") > 0 && tax.GetSurcharge_Tax_ID() > 0) { Decimal surchargeAmt = Env.ZERO; // Calculate Surcharge Amount TotalRate = tax.CalculateSurcharge(New.GetLineNetAmt(), priceList.IsTaxIncluded(), priceList.GetStandardPrecision(), out surchargeAmt); New.SetTaxAmt(TotalRate); New.SetSurchargeAmt(surchargeAmt); } else { TotalRate = tax.CalculateTax(New.GetLineNetAmt(), priceList.IsTaxIncluded(), priceList.GetPricePrecision()); New.SetTaxAmt(TotalRate); } // Calculate Discount % Decimal?dis = Decimal.Multiply(Decimal.Divide(Decimal.Subtract(New.GetPriceList(), New.GetPriceEntered()), New.GetPriceList()), 100); New.SetDiscount(dis); // Set Grand Total Amount if (priceList.IsTaxIncluded()) { New.SetGrandTotal(New.GetLineNetAmt()); } else { if (New.Get_ColumnIndex("SurchargeAmt") > 0) { New.SetGrandTotal(Decimal.Add(Decimal.Add(New.GetLineNetAmt(), New.GetTaxAmt()), New.GetSurchargeAmt())); } else { New.SetGrandTotal(Decimal.Add(New.GetLineNetAmt(), New.GetTaxAmt())); } } if (contact.GetBillStartDate() != null) { New.SetBillStartDate(contact.GetBillStartDate().Value.AddMonths(contact.GetTotalInvoice())); } else { New.SetBillStartDate(New.GetStartDate()); } if (New.Save()) { newcon = New.GetDocumentNo(); count++; contact.SetRef_Contract_ID(New.GetC_Contract_ID()); contact.SetRenewContract("Y"); if (!contact.Save()) { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } if (!EnterSchedules(New.GetC_Contract_ID(), cycles)) { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } New.SetProcessed(true); if (!New.Save()) { dr.Close(); Get_TrxName().Rollback(); return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } } else { dr.Close(); Get_TrxName().Rollback(); pp = VLogger.RetrieveError(); if (pp != null) { return(!String.IsNullOrEmpty(pp.GetName()) ? pp.GetName() : Msg.GetMsg(GetCtx(), "ContractNotRenew")); } else { return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } } } } dr.Close(); if (count != 0 && Record_id != 0) { return(Msg.GetMsg(GetCtx(), "ContractReNewed") + ": " + newcon); } if (count != 0) { return(Msg.GetMsg(GetCtx(), "ContractReNewed")); } return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); } catch { if (dr != null) { dr.Close(); dr = null; } } finally { if (dr != null) { dr.Close(); dr = null; } } return(Msg.GetMsg(GetCtx(), "ContractNotRenew")); }
public DateTime Next() { return(Start.AddDays(Gen.Next(Range)).AddHours(Gen.Next(0, 24)).AddMinutes(Gen.Next(0, 60)).AddSeconds(Gen.Next(0, 60))); }
public DateRange Slide(int days) { return(new DateRange(Start.AddDays(days), End.AddDays(days))); }