private double ServerToClientBias() { double ServerBias = -1 * System.TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).TotalMinutes; double ClientBias = TimeZone.BiasForGivenDate(DateTime.Now); return(-1 * (ClientBias - ServerBias)); }
void CompDateValue_DateTimeValueChanged(object sender, EventArgs e) { if ((CompDateValue.DateTimeValue != null)) { TimeZones tzones = new TimeZones(); TimeZone comptz = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName); DateTime newDateTime = (DateTime)(CompDateValue.DateTimeValue); newDateTime = newDateTime.AddMinutes(-1 * TimeZone.BiasForGivenDate(newDateTime)); CurrDateValue.DateTimeValue = newDateTime.AddMinutes(comptz.BiasForGivenDate(newDateTime)); } }
void CurrDateValue_DateTimeValueChanged(object sender, EventArgs e) { if ((CurrDateValue.DateTimeValue != null)) { TimeZones tzones = new TimeZones(); TimeZone comptz = tzones.FindTimeZone(CompTzSelect.SelectedValue, TimeZones.TZFindType.ftDisplayName); DateTime newDateTime = (DateTime)(CurrDateValue.DateTimeValue); newDateTime = newDateTime.AddMinutes(TimeZone.BiasForGivenDate(newDateTime)); CompDateValue.DateTimeValue = newDateTime.AddMinutes(-1 * comptz.BiasForGivenDate(newDateTime)); chkCompDltAdjust.Disabled = (!comptz.ObservervesDaylightTime); lblCompDltAdjust.Disabled = (!comptz.ObservervesDaylightTime); } }
private void BuildTimeZoneSelect(TimeZone tz, string clientTimeZone) { // option............... CompTzSelect.Items.Add(new ListItem(tz.DisplayName)); if (clientTimeZone != tz.KeyName) { return; } CompTzSelect.SelectedValue = tz.DisplayName; currTZDispName.InnerText = tz.DisplayName; currTZStdDltName.InnerText = tz.DateFallsWithinDaylightSaving(Activity.StartDate) ? tz.DaylightName : tz.StandardName; localtimezone.Value = tz.KeyName; lblLocalTimeZone.InnerText = tz.DisplayName; localbias.Value = tz.BiasForGivenDate(Activity.StartDate).ToString(); localnodltbias.Value = tz.Bias.ToString(); chkCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime); lblCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime); chkCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime); lblCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime); }
private void BuildTimeZoneSelect(TimeZone tz, string clientTimeZone) { // option............... CompTzSelect.Items.Add(new ListItem(tz.DisplayName)); if (clientTimeZone != tz.KeyName) return; CompTzSelect.SelectedValue = tz.DisplayName; currTZDispName.InnerText = tz.DisplayName; currTZStdDltName.InnerText = tz.DateFallsWithinDaylightSaving(Activity.StartDate) ? tz.DaylightName : tz.StandardName; localtimezone.Value = tz.KeyName; lblLocalTimeZone.InnerText = tz.DisplayName; localbias.Value = tz.BiasForGivenDate(Activity.StartDate).ToString(); localnodltbias.Value = tz.Bias.ToString(); chkCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime); lblCurrDltAdjust.Disabled = (!tz.ObservervesDaylightTime); chkCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime); lblCompDltAdjust.Disabled = (!tz.ObservervesDaylightTime); }
protected void Save(object sender, EventArgs e) { if (SendBy.DateTimeValue < DateTime.Now.AddDays(-1)) { return; } if (RequestedFor.LookupResultValue != null) { IContextService conserv = ApplicationContext.Current.Services.Get <IContextService>(true); Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)conserv.GetContext("TimeZone"); ILitRequest lr = EntityFactory.Create <ILitRequest>(); SLXUserService slxUserService = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService; if (slxUserService != null) { lr.RequestUser = slxUserService.GetUser(); } String[] arClientData = clientdata.Value.ToString().Split('|'); lr.RequestDate = DateTime.Now.AddMinutes(tz.BiasForGivenDate(DateTime.Now)); lr.CoverId = arClientData[0]; lr.Contact = (IContact)RequestedFor.LookupResultValue; lr.ContactName = lr.Contact.LastName + ", " + lr.Contact.FirstName; lr.Description = Description.Text; lr.SendDate = SendBy.DateTimeValue; lr.SendVia = SendVia.PickListValue; lr.Priority = Priority.PickListValue; lr.Options = PrintLiteratureList.SelectedIndex; lr.Save(); Activity act = new Activity(); act.Type = ActivityType.atLiterature; act.AccountId = lr.Contact.Account.Id.ToString(); act.AccountName = lr.Contact.Account.AccountName; act.ContactId = lr.Contact.Id.ToString(); act.ContactName = lr.ContactName; act.PhoneNumber = lr.Contact.WorkPhone; act.StartDate = (DateTime)lr.RequestDate; act.Duration = 0; act.Description = lr.Description; act.Alarm = false; act.Timeless = true; act.Rollover = false; act.UserId = lr.RequestUser.Id.ToString(); act.OriginalDate = (DateTime)lr.RequestDate; act.Save(); // save litRequest item double totalCost = 0.0; string coverId = arClientData[0]; // get cover name for (int i = 1; i < arClientData.Length; i++) { string[] clientData = arClientData[i].Split('='); string litItemId = clientData[0]; int qty = Int32.Parse(clientData[1]); // get literature item cost ILiteratureItem litItem = EntityFactory.GetById <ILiteratureItem>(litItemId); totalCost += (double)qty * (litItem.Cost.HasValue ? (double)litItem.Cost.Value : (double)0.0); // add the literature request item ILitRequestItem lrItem = EntityFactory.Create <ILitRequestItem>(); lrItem.Qty = qty; lrItem.LitRequest = lr; lrItem.LiteratureItem = litItem; lr.LitRequestItems.Add(lrItem); } lr.TotalCost = totalCost; // get cover name string coverName = GetCoverName(coverId); lr.CoverName = coverName; lr.Save(); //must make ids match, and id prop is read only, so.... SynchronizeLitRequestId(act.Id, lr.Id.ToString()); // re-get entity with new activity id lr = EntityFactory.GetById <ILitRequest>(act.Id); // process the lit request if handle fulfillment locally is checked if (chkHandleLocal.Checked) { // show printer dialog for fulfillment FulfillRequestLocally(lr); // call business rule to update the entity properties lr.FulfillLitRequest(); } else { Response.Redirect("Contact.aspx?entityId=" + lr.Contact.Id.ToString()); } } }