Exemplo n.º 1
0
 /// <summary>
 /// Gets the Customers name by the customer id.
 /// </summary>
 /// <param name="CustomerID"></param>
 /// <returns></returns>
 private string GetCustomerName(Int32 CustomerID)
 {
     using (TMMModel.TMM_DEPLOYEntities oEntities = new TMMModel.TMM_DEPLOYEntities())
     {
         return((from c in oEntities.Customer
                 where c.ID == CustomerID
                 select c).First().Name);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a list of worksites for a customer based on the customerid.
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        private List <TMMModel.Customer_Worksite> GetRigsForCustomer(Int32 CustomerID)
        {
            List <TMMModel.Customer_Worksite> cList = new List <TMMModel.Customer_Worksite>();

            using (TMMModel.TMM_DEPLOYEntities oEntities = new TMMModel.TMM_DEPLOYEntities())
            {
                var customer_worksites = (from c_w in oEntities.Customer_Worksite
                                          where c_w.CustomerID == CustomerID && c_w.Active
                                          select c_w);
                cList.AddRange(customer_worksites);
            }
            return(cList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the Customer ID based on information retrieved from the login information.
        /// </summary>
        /// <returns></returns>
        private Int32 GetCustomerID()
        {
            using (TMMModel.TMM_DEPLOYEntities oEntities = new TMMModel.TMM_DEPLOYEntities())
            {
                //Use the username to get the user id.
                Int32 UID = (from U_I in oEntities.UserSecurity
                             where U_I.Username == User.Identity.Name
                             select U_I).First().UserID;

                //Use the user id to get that user's customer id.
                Int32 CustomerID = (from u_i in oEntities.UserInfo
                                    where u_i.ID == UID
                                    select u_i).First().CustomerID.Value;

                //return the customer id.
                return(CustomerID);
            }
        }
Exemplo n.º 4
0
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);

            rdpEncounterEndDate.DateInput.Attributes.Add("onclick", "TogglePopup('" + rdpEncounterEndDate.ClientID + "')");
            rdpEncounterStartDate.DateInput.Attributes.Add("onclick", "TogglePopup('" + rdpEncounterStartDate.ClientID + "')");

            Int32 uTypeID = 0;

            using (TMMModel.TMM_DEPLOYEntities oEntities = new TMMModel.TMM_DEPLOYEntities())
            {
                uTypeID = (from u_i in oEntities.UserInfo
                           where u_i.UserSecurity.Username == User.Identity.Name
                           select u_i.UserType.ID).First();
            }
            //if the usertype is not customer, redirect the user.
            if (uTypeID != Convert.ToInt32(TMMModel.UserType.Types.Customer))
            {
                Response.Redirect("/Login.aspx");
            }


            DataTool dbTool = new DataTool();

            //Page.Focus();

            DataTable dtRigs = dbTool.getRigIDs();

            if (!Page.IsPostBack)
            {
                this.rdpEncounterEndDate.SelectedDate   = DateTime.Now.Date;
                this.rdpEncounterStartDate.SelectedDate = DateTime.Now.Date.AddDays(-30);

                //Load the drop down list.
                initDropDown_BL(ddlWorksites, dtRigs, 1);

                this.rgEncounterResults.Rebind();
            }
        }