예제 #1
0
        private bool AccountTypesAreValid()
        {
            var result = !string.IsNullOrEmpty(ReportPage.GetSelectedAccountTypes(cblAccountType));

            phAccountTypeMessage.Visible = !result;
            return(result);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!CurrentUser.HasPriv(AuthTypes))
            {
                Session.Abandon();
                Response.Redirect(Session["NoAccess"].ToString() + "?Action=Exit");
            }

            hidVarAccountTypes.Value = ReportPage.GetSelectedAccountTypes(cblAccountType);

            if (!Page.IsPostBack)
            {
                CreateAccountCheckList(cblAccountType);
                var options = ReadReportOptionsFromCookie <ToolUsageSummaryOptions>(COOKIE_NAME); //ReportPage.ReadReportOptionsFromCookie(Request, cblAccountType, COOKIENAME);
                ApplyOptions(options);
            }
        }
예제 #3
0
        private DataTable GetData()
        {
            DateTime sDate = pp1.SelectedPeriod;
            DateTime eDate = sDate.AddMonths(Convert.ToInt32(txtMonths.Text));

            //IList<AccountType> allAccountTypes = DA<AccountType>.All();

            if (sDate > DateTime.Now.Date)
            {
                return(null);
            }

            if (sDate <= DateTime.Now.Date && eDate > DateTime.Now.Date && !Convert.ToBoolean(Session["Updated"]))
            {
                WriteData writeData = new WriteData(Provider);
                writeData.UpdateTables(BillingCategory.Tool, UpdateDataType.DataClean);
                Session["Updated"] = true;
            }

            if (eDate > DateTime.Now.Date)
            {
                eDate = DateTime.Now.Date.AddDays(1); // otherwise percentages are skewed
            }
            totalHours = eDate.Subtract(sDate).TotalHours;

            // create table to store data
            bool includeForgiven = rdoCharged.Checked ? chkIncludeForgiven.Checked : true;
            bool showPercentages = chkShowPercentOfTotal.Checked;

            hidShowPercentOfTotal.Value = showPercentages.ToString().ToLower();
            string    sumcol = GetStatsBasedOn();
            DataTable dt     = GetToolUtilizationData(sumcol, includeForgiven, sDate, eDate, ReportPage.GetSelectedAccountTypes(cblAccountType));

            foreach (DataRow dr in dt.Rows)
            {
                dr["IdleTime"] = totalHours;
                for (int i = 1; i <= dt.Columns.Count - 2; i++)
                {
                    dr["IdleTime"] = Convert.ToDouble(dr["IdleTime"]) - Utility.ConvertTo(dr[i], 0D);
                }
                if (Convert.ToDouble(dr["IdleTime"]) < 0.0)
                {
                    dr["IdleTime"] = 0.0;
                }
            }

            Dictionary <string, double> totalColumns = new Dictionary <string, double>();

            activities = DataSession.Query <Activity>().Where(x => x.IsActive).ToArray();

            totalColumns.Add("Lab", 0);
            totalColumns.Add("ProcessTech", 0);
            totalColumns.Add("ResourceID", 0);
            foreach (var act in activities)
            {
                totalColumns.Add(act.ActivityName, 0);
            }
            totalColumns.Add("IdleTime", 0);

            List <string> keys = new List <string>(totalColumns.Keys);

            foreach (DataRow row in dt.Rows)
            {
                foreach (string k in keys)
                {
                    double value = Utility.ConvertTo(row[k], 0D);
                    totalColumns[k] += Utility.Round(value, 1);
                }
            }

            rowCount = dt.Rows.Count;

            totalRow = dt.NewRow();
            totalRow["ResourceName"] = "Total";

            foreach (KeyValuePair <string, double> kvp in totalColumns)
            {
                totalRow[kvp.Key] = kvp.Value;
            }

            return(dt);
        }