This commit is contained in:
199
source/WBI/schedule.aspx.cs
Normal file
199
source/WBI/schedule.aspx.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using Infragistics.WebUI.Shared;
|
||||
using GZTW.AyaNova.BLL;
|
||||
|
||||
public partial class schedule : BaseThemePage
|
||||
{
|
||||
|
||||
private AyaScheduleProvider ays = new AyaScheduleProvider();
|
||||
#region PageEvents
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (Util.CurrentUser.IsClientOrHeadOfficeAccount)
|
||||
{
|
||||
Util.Denied(Context);
|
||||
}
|
||||
// connect the custom data provider to the web schedule info object
|
||||
DropDownList users = (DropDownList)tbMain.FindItemByValue("USER").FindControl("cbSchedUsers");
|
||||
//Set the active user selected in the combo (for postbacks)
|
||||
if (users.SelectedValue != "")
|
||||
ays.ActiveUserID = new Guid(users.SelectedValue);
|
||||
|
||||
//Set the userid hidden form variable so that
|
||||
//the create new record javascript can pass that id
|
||||
//as an url paramter to create new workorder or sched marker
|
||||
this.activeuserid.Value = ays.ActiveUserID.ToString();
|
||||
|
||||
//Tell the schedule provider which info object to use
|
||||
ays.WebScheduleInfo = this.info;
|
||||
Util.Localize(tbMain);
|
||||
|
||||
if (AyaBizUtils.MRU.IsDirty)
|
||||
AyaBizUtils.MRU.Save();
|
||||
//case 535 Initialize MRU list
|
||||
Util.MRUFillList(this.tbMain.Items.FindItemByValue("MNUMRU"));
|
||||
|
||||
//case 991
|
||||
this.tbMain.Items.FindItemByValue("NEWSM").Visible = AyaBizUtils.Right(RootObjectTypes.ScheduleMarker) > (int)SecurityLevelTypes.ReadOnly;
|
||||
this.tbMain.Items.FindItemByValue("NEWWO").Visible = AyaBizUtils.Right(RootObjectTypes.WorkorderService) > (int)SecurityLevelTypes.ReadOnly;
|
||||
|
||||
|
||||
if (this.IsPostBack)
|
||||
return;
|
||||
|
||||
LoadSchedUsers();
|
||||
|
||||
// Set a start date for the schedule on fresh open
|
||||
this.info.ActiveDayUtc = new SmartDate(DBUtil.CurrentWorkingDateTime);//case 1163
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region sched users list
|
||||
private void LoadSchedUsers()
|
||||
{
|
||||
DropDownList users = (DropDownList)tbMain.FindItemByValue("USER").FindControl("cbSchedUsers");
|
||||
users.Items.Clear();
|
||||
DataTable dtUsers = Util.GetDataBiz("UserPickListScheduleable", Guid.Empty, true, Guid.Empty, null,true);
|
||||
foreach (DataRow dr in dtUsers.Rows)
|
||||
{
|
||||
if((Guid)dr["Value"]!=Guid.Empty)
|
||||
users.Items.Add(new ListItem(dr["Display"].ToString(), dr["Value"].ToString()));
|
||||
}
|
||||
users.Items.Add(new ListItem("Unassigned", Guid.Empty.ToString()));
|
||||
|
||||
if (Util.CurrentUser.IsScheduleable)
|
||||
ays.ActiveUserID = Util.CurrentUserID;
|
||||
else
|
||||
ays.ActiveUserID = Guid.Empty;
|
||||
|
||||
users.SelectedValue = ays.ActiveUserID.ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
protected void cbSchedUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
DropDownList users = (DropDownList)tbMain.FindItemByValue("USER").FindControl("cbSchedUsers");
|
||||
if (users.SelectedValue != "")
|
||||
ays.ActiveUserID = new Guid(users.SelectedValue);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Menu items
|
||||
|
||||
protected void tbMain_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Item.Value.StartsWith("MRU"))
|
||||
{
|
||||
TypeAndID tid = TypeAndID.Parse(e.Item.Value.Replace("MRU", ""));
|
||||
Util.OpenEditWindow(this.Page, tid.RootObjectType, tid.ID);
|
||||
return;
|
||||
}
|
||||
//Currently the infragistics schedule controls only
|
||||
//know what day it is, not the time
|
||||
//so will use their date if set, but always
|
||||
//start time at 12:00pm to 12:30pm
|
||||
System.DateTime refdate = DBUtil.CurrentWorkingDateTime;
|
||||
if (!info.ActiveDayUtc.IsEmpty)
|
||||
{
|
||||
refdate = info.ActiveDayUtc.Value.ToLocalTime();
|
||||
}
|
||||
|
||||
DateTime dt = new DateTime(refdate.Year, refdate.Month, refdate.Day, 12, 0, 0);
|
||||
|
||||
switch (e.Item.Value)
|
||||
{
|
||||
case "NEWSM":
|
||||
{
|
||||
|
||||
ScheduleMarker sm = ScheduleMarker.NewItem();
|
||||
sm.StartDate = dt;
|
||||
sm.StopDate = dt.AddMinutes(30);
|
||||
|
||||
//have sm init to user and current user to save
|
||||
//time for entry
|
||||
if (ays.ActiveUserID != Guid.Empty)
|
||||
{
|
||||
sm.SourceID = ays.ActiveUserID;
|
||||
sm.ScheduleMarkerSourceType = ScheduleMarkerSourceTypes.User;
|
||||
}
|
||||
Session["schedulemarker"] = sm;
|
||||
|
||||
Response.Write("<script>window.open('ScheduleMarkerEdit.aspx?id=" + sm.ID.ToString() + "','_blank');</script>");
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
case "NEWWO":
|
||||
{
|
||||
// "WorkorderNew.aspx?usr="+document.getElementById("activeuserid").value+"&st="+dt.getFullYear()+"-"+dt.getMonth()+"-"+dt.getDate()+"-"+dt.getHours() + "-"+dt.getMinutes();
|
||||
|
||||
//case 1057
|
||||
Session["ActiveObjectType"] = RootObjectTypes.WorkorderService;
|
||||
|
||||
string sparam = "";
|
||||
if (ays.ActiveUserID != Guid.Empty)
|
||||
{
|
||||
sparam = "usr=" + ays.ActiveUserID + "&";
|
||||
}
|
||||
//corresponding javascript method has zero based months so need to
|
||||
//subtract 1 from the month portion in order for the workordernew to handle the date identically
|
||||
sparam = sparam + "st=" + dt.Year.ToString() + "-" + ((dt.Month) - 1).ToString() + "-" + dt.Day.ToString() + "-" + dt.Hour.ToString() + "-" + dt.Minute.ToString();
|
||||
Response.Write("<script>window.open('WorkorderNew.aspx?" + sparam + "','_blank');</script>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
case "SERVICE":
|
||||
{
|
||||
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
||||
//case 58
|
||||
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.Service);
|
||||
return;
|
||||
}
|
||||
|
||||
case "QUOTE":
|
||||
{
|
||||
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
||||
//case 58
|
||||
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.Quote);
|
||||
return;
|
||||
}
|
||||
|
||||
case "PM":
|
||||
{
|
||||
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
||||
//case 58
|
||||
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.PreventiveMaintenance);
|
||||
|
||||
return;
|
||||
}
|
||||
case "MNUWIKI":
|
||||
{
|
||||
//open global object wiki page
|
||||
Util.OpenWikiPage(this.Page, new TypeAndID(RootObjectTypes.Global, Address.GlobalAddressID));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user