Code Behind:

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;

public partial class Entry : clsCommon
{
  public bool blnDirector = Convert.ToBoolean(new clsActiveDirectory
(false).IsInGroup("HOURSC.DL Directors"));
  public bool blnManager = Convert.ToBoolean(new clsActiveDirectory
(false).IsInGroup("HOURSC.DL Managers"));
  public bool blnITS_Dev = Convert.ToBoolean(new clsActiveDirectory
(false).IsInGroup("HRSC_ITS_Dev"));

  protected void Page_Load(object sender, EventArgs e)
  {
    if (!(IsPostBack))
      litList.Text = "<span style=\"font-size: 16pt; color:
#003366\">" + configurationValue("appName") + " - New PTO Request </
span>";
  }

  protected void fvEntry_ItemInserted(object sender,
FormViewInsertedEventArgs e)
  {
    Response.Redirect("~/?msg=Requested+Submitted!");
  }

  protected void InsertCancelButton_Click(object sender, EventArgs e)
  {
    Response.Redirect("~/?msg=Requested+Not+Submitted!");
  }

  protected void hfUserID_Init(object sender, EventArgs e)
  {
    HiddenField hf = sender as HiddenField;
    hf.Value =
System.Web.HttpContext.Current.Request.ServerVariables.Get
("AUTH_USER").ToUpper().Trim().Replace("ABC\\", "");
    string strUserEmulator =
System.Configuration.ConfigurationManager.AppSettings.Get
("UserEmulator") ?? "";
    if (strUserEmulator.IndexOf(",") >= 0)
    {
      string[] arUser = strUserEmulator.Split(',');
      if (hf.Value == arUser[0]) hf.Value = arUser[1];
    }
  }

  protected void ddlRequestType_DataBound(object sender, EventArgs e)
  {
    DropDownList ddl = (DropDownList)sender;
    ddl.Items.Insert(0, new ListItem("Select...", "0"));
  }

  protected void cvTypeValidate_ServerValidate(object source,
ServerValidateEventArgs args)
  {
    args.IsValid = (Convert.ToInt32(args.Value) != 0);
  }

  protected void cvUserValidate_ServerValidate(object source,
ServerValidateEventArgs args)
  {
    _App_Controls_ctlUserNameSelect Usr =
(_App_Controls_ctlUserNameSelect)fvEntry.FindControl("ctlUserName");
    args.IsValid = (Usr.IsEmp);
  }

  protected void ctlUserName_Load(object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
      _App_Controls_ctlUserNameSelect Usr =
(_App_Controls_ctlUserNameSelect)fvEntry.FindControl("ctlUserName");
      Usr.Text = hfUserID.Value;
      Usr.ReadOnly = ((blnDirector) || (blnManager)) ? true : false;
    }
  }

  protected void ctlUserName_Refresh(object sender, EventArgs e)
  {
    _App_Controls_ctlUserNameSelect Usr =
(_App_Controls_ctlUserNameSelect)fvEntry.FindControl("ctlUserName");

    hfPrivateOrPublic.Value = (((blnManager) || (blnDirector)) &&
(hfUserID.Value == Usr.Text)) ? "Public" : "Private";
  }

  protected void fvEntry_Init(object sender, EventArgs e)
  {
    FormView fv = (FormView)sender;
    switch (Request.QueryString["Type"])
    {
      case "New":
        fv.DefaultMode = FormViewMode.Insert;
        break;
      case "Exist":
      default:
        fv.DefaultMode = FormViewMode.ReadOnly;
        break;
    }
  }

  protected void fvEntry_ItemInserting(object sender,
FormViewInsertEventArgs e)
  {
    _App_Controls_ctlUserNameSelect Usr =
(_App_Controls_ctlUserNameSelect)fvEntry.FindControl("ctlUserName");

    hfRequestType.Value = ((DropDownList)fvEntry.Row.FindControl
("ddlRequestType")).SelectedValue;

    string strMgr = new clsSQLServer("cHuman").getOneField
("txtManager", "vwEmployeeManager", "txtUserID", Usr.Text);

    hfApproved.Value = (strMgr == new clsActiveDirectory().userName) ?
"1" : "0";
    hfProcessed.Value = (strMgr == new clsActiveDirectory
().userName) ? "1" : "0";
    hfProcessDate.Value = (strMgr == new clsActiveDirectory
().userName) ? DateTime.Now.ToString() : null;
    hfProcessedBy.Value = (strMgr == new clsActiveDirectory
().userName) ? hfUserID.Value : null;
  }
}

Reply via email to