This commit is contained in:
259
source/WBI/MemoComposer.aspx.cs
Normal file
259
source/WBI/MemoComposer.aspx.cs
Normal file
@@ -0,0 +1,259 @@
|
||||
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 GZTW.AyaNova.BLL;
|
||||
using Telerik.Web.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
|
||||
public partial class MemoComposer : BaseThemePage
|
||||
{
|
||||
|
||||
|
||||
#region BizObject
|
||||
public GZTW.AyaNova.BLL.Memo mMemo;
|
||||
protected GZTW.AyaNova.BLL.Memo CurrentMemo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mMemo != null) return mMemo;
|
||||
|
||||
string idstring = Request.QueryString["id"];
|
||||
Guid oID = Guid.Empty;
|
||||
if (!string.IsNullOrEmpty(idstring))
|
||||
{
|
||||
oID = new Guid(idstring);
|
||||
mMemo = (GZTW.AyaNova.BLL.Memo)Session["memo"+idstring];
|
||||
}
|
||||
//ensure if object in session is the same as the one requested
|
||||
if (mMemo == null || (oID != Guid.Empty && mMemo.ID != oID))//Case 912
|
||||
{
|
||||
try
|
||||
{
|
||||
if (oID != Guid.Empty)
|
||||
throw new ApplicationException("MemoComposer - Memo id specified not found in session");
|
||||
else
|
||||
mMemo = GZTW.AyaNova.BLL.Memo.NewItem();
|
||||
|
||||
Session["memo"+mMemo.ID.ToString()] = mMemo;
|
||||
}
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
CloseMe();
|
||||
}
|
||||
}
|
||||
|
||||
return mMemo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Recipient list DataTable
|
||||
private DataTable dtRecipients = null;
|
||||
protected DataTable Recipients
|
||||
{
|
||||
get
|
||||
{
|
||||
if (dtRecipients != null) return dtRecipients;
|
||||
|
||||
if (Session["memoto" + CurrentMemo.ID.ToString()] != null)
|
||||
{
|
||||
dtRecipients = (DataTable)Session["memoto" + CurrentMemo.ID.ToString()];
|
||||
return dtRecipients;
|
||||
}
|
||||
|
||||
//not in session cache, create, put in cache and return
|
||||
InitializeRecipientTable();
|
||||
Session.Add("memoto" + CurrentMemo.ID.ToString(), dtRecipients);
|
||||
return dtRecipients;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeRecipientTable()
|
||||
{
|
||||
dtRecipients = new DataTable("RECIPIENTS");
|
||||
Dictionary<UserTypes, string> ut =new Dictionary<UserTypes, string>();
|
||||
ut.Add(UserTypes.Administrator, Util.LocaleText("UserTypes.Label.Administrator"));
|
||||
ut.Add(UserTypes.Schedulable, Util.LocaleText("UserTypes.Label.Schedulable"));
|
||||
ut.Add(UserTypes.NonSchedulable, Util.LocaleText("UserTypes.Label.NonSchedulable"));
|
||||
ut.Add(UserTypes.Client, Util.LocaleText("UserTypes.Label.Client"));
|
||||
ut.Add(UserTypes.HeadOffice, Util.LocaleText("UserTypes.Label.HeadOffice"));
|
||||
ut.Add(UserTypes.Utility, Util.LocaleText("UserTypes.Label.UTILITY"));
|
||||
|
||||
|
||||
|
||||
dtRecipients.Columns.Add("RECIPIENT", typeof(System.String));
|
||||
dtRecipients.Columns.Add("RECIPIENTTYPE", typeof(System.String));
|
||||
dtRecipients.Columns.Add("SUBCONTRACTOR", typeof(bool));
|
||||
dtRecipients.Columns.Add("RECIPIENTID", typeof(System.Guid));
|
||||
dtRecipients.Columns.Add("SELECTED", typeof(bool));
|
||||
|
||||
//case 2000
|
||||
//UserPickList UList = UserPickList.GetList(false);
|
||||
UserPickList UList = UserPickList.GetInternalStaffOnlyList(false);
|
||||
|
||||
foreach (UserPickList.UserPickListInfo ui in UList)
|
||||
{
|
||||
DataRow dr = dtRecipients.NewRow();
|
||||
dr["RECIPIENT"] = ui.Name;
|
||||
dr["RECIPIENTTYPE"] = ut[ui.Type];
|
||||
dr["SUBCONTRACTOR"] = ui.SubContractor;
|
||||
dr["RECIPIENTID"] = ui.ID;
|
||||
//In case of reply:
|
||||
if (CurrentMemo.ToID == ui.ID)
|
||||
dr["SELECTED"] = true;
|
||||
else
|
||||
dr["SELECTED"] = false;
|
||||
dtRecipients.Rows.Add(dr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
protected void Page_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//Get data logic
|
||||
if (this.IsPostBack && !IsAjaxCallback)//Only on a postback and not a callback
|
||||
{
|
||||
GetData();
|
||||
}
|
||||
|
||||
//Load and set data in initial form load
|
||||
//and in all postbacks that are not a result of a rad
|
||||
//manager callback
|
||||
if (!IsAjaxCallback)
|
||||
{
|
||||
//Localize the page
|
||||
Util.Localize(this.Page);
|
||||
SetData();
|
||||
Page.Title = "*"+ Util.LocaleText("O.Memo");
|
||||
lbTo.Text= Util.LocaleText("Memo.Label.ToID");
|
||||
Telerik.Web.UI.RadWindow rw = rwm.Windows[0];
|
||||
rw.NavigateUrl = "MemoToChooser.aspx?id=" + CurrentMemo.ID.ToString();
|
||||
rw.Behaviors = Telerik.Web.UI.WindowBehaviors.Maximize |
|
||||
Telerik.Web.UI.WindowBehaviors.Close |
|
||||
Telerik.Web.UI.WindowBehaviors.Resize;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update user viewed display of recipients selected
|
||||
/// called after coming back from MemoToSelector form
|
||||
/// </summary>
|
||||
private void DisplayTo()
|
||||
{
|
||||
bool bAtLeastOne = false;
|
||||
this.lblRequired.Visible = false;
|
||||
this.lblRecipients.Text = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (DataRow dr in Recipients.Rows)
|
||||
{
|
||||
if ((bool)dr["SELECTED"] == true)
|
||||
{
|
||||
bAtLeastOne = true;
|
||||
sb.Append((string)dr["RECIPIENT"] + "; ");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
this.lblRecipients.Text = sb.ToString();
|
||||
if (!bAtLeastOne)
|
||||
lblRequired.Visible = true;
|
||||
}
|
||||
|
||||
private void SetData()
|
||||
{
|
||||
edSubject.Text = CurrentMemo.Subject;
|
||||
edMessage.Text = CurrentMemo.Message;
|
||||
DisplayTo();
|
||||
|
||||
}
|
||||
|
||||
private void GetData()
|
||||
{
|
||||
|
||||
CurrentMemo.Subject = edSubject.Text;
|
||||
CurrentMemo.Message = edMessage.Text;
|
||||
}
|
||||
|
||||
protected void btnTo_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Response.Write("<script>\r\n");
|
||||
Response.Write("window.open('MemoToChooser.aspx?id=" + CurrentMemo.ID.ToString() + "');");
|
||||
Response.Write("\r\n</script>");
|
||||
}
|
||||
|
||||
protected void mnu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
||||
{
|
||||
switch (e.Item.Value)
|
||||
{
|
||||
case "SAVE":
|
||||
{
|
||||
bool bAtLeastOne=false;
|
||||
foreach (DataRow dr in Recipients.Rows)
|
||||
{
|
||||
if ((bool)dr["SELECTED"] == true)
|
||||
{
|
||||
bAtLeastOne = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAtLeastOne)
|
||||
return;
|
||||
|
||||
string subject = edSubject.Text;
|
||||
if (string.IsNullOrEmpty(subject))
|
||||
subject = "NO SUBJECT";
|
||||
|
||||
//we have a recipient, we can send
|
||||
foreach (DataRow dr in this.dtRecipients.Rows)
|
||||
{
|
||||
if ((bool)dr["SELECTED"] == true)
|
||||
{
|
||||
GZTW.AyaNova.BLL.Memo m = GZTW.AyaNova.BLL.Memo.NewItem();
|
||||
m.ToID = (Guid)dr["RECIPIENTID"];
|
||||
m.Subject = subject;
|
||||
m.Message = edMessage.Text;
|
||||
m.Save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Session.Remove("memo" + Request.QueryString["id"]);
|
||||
Session.Remove("memoto" + Request.QueryString["id"]);
|
||||
CloseMe();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user