Exemple #1
0
 void ReBind()
 {
     LastFrequencyMetric = GetData();
     foreach (MetricTrac.Bll.MetricOrgValue mmv in LastFrequencyMetric.Metrics)
     {
         mmv.OrgLocationFullName = MetricTrac.Bll.Mc_EntityNode.GetHtmlFullName(mmv.OrgLocationFullName);
     }
     rMetric.DataSource = LastFrequencyMetric.Metrics;
     rMetric.DataBind();
 }
Exemple #2
0
        /*protected void lbSave_Click(object sender, EventArgs e)
         * {
         *  int i = 0;
         *  LastFrequencyMetric = GetData();
         *  foreach (RepeaterItem ri in rMetric.Items)
         *  {
         *      MetricOrgValue mov = LastFrequencyMetric.Metrics[i];
         *      DateTime iTime = DateTime.Now;
         *      DropDownList ddlInputUnitOfMeasure = (DropDownList)ri.FindControl("ddlInputUnitOfMeasure");
         *      HiddenField hfUoM = (HiddenField)ri.FindControl("hfUoM");
         *      HiddenField hfMetric = (HiddenField)ri.FindControl("hfMetric");
         *      HiddenField hfOrgLocation = (HiddenField)ri.FindControl("hfOrgLocation");
         *      Repeater r = (Repeater)ri.FindControl("rMericValue");
         *
         *      Guid? ActualUoMID = null;
         *      if (ddlInputUnitOfMeasure.Visible)
         *      {
         *          if (!String.IsNullOrEmpty(ddlInputUnitOfMeasure.SelectedValue))
         *              ActualUoMID = new Guid(ddlInputUnitOfMeasure.SelectedValue);
         *      }
         *      else
         *      {
         *          if (!String.IsNullOrEmpty(hfUoM.Value))
         *              ActualUoMID = new Guid(hfUoM.Value);
         *      }
         *      Guid oMetricID = new Guid(hfMetric.Value);
         *      Guid oOrgLocationID = new Guid(hfOrgLocation.Value);
         *      int j = 0;
         *      foreach (RepeaterItem rri in r.Items)
         *      {
         *          DateTime jTime = DateTime.Now;
         *          HiddenField hfDate = (HiddenField)rri.FindControl("hfDate");
         *          DateTime oDate = DateTime.Parse(hfDate.Value);
         *          Telerik.Web.UI.RadNumericTextBox rntValue = (Telerik.Web.UI.RadNumericTextBox)rri.FindControl("rntValue");
         *          System.Web.UI.WebControls.TextBox tbValue = (System.Web.UI.WebControls.TextBox)rri.FindControl("tbValue");
         *          System.Web.UI.WebControls.CheckBox chbValue = (System.Web.UI.WebControls.CheckBox)rri.FindControl("chbValue");
         *          Telerik.Web.UI.RadDatePicker rdpDateValue = (Telerik.Web.UI.RadDatePicker)rri.FindControl("rdpDateValue");
         *          System.Web.UI.WebControls.DropDownList ddlApprovalStatus = (System.Web.UI.WebControls.DropDownList)rri.FindControl("ddlApprovalStatus");
         *
         *          Bll.MetricValue.Extend OldMetricValue = mov.MetricValues[j];
         *          string Value = String.Empty;
         *          if (rntValue.Visible)
         *              Value = rntValue.Value.ToString();
         *          else
         *              if (tbValue.Visible)
         *                  Value = tbValue.Text;
         *              else
         *                  if (chbValue.Visible)
         *                      Value = chbValue.Checked ? bool.TrueString : bool.FalseString;
         *                  else
         *                      if (rdpDateValue.Visible)
         *                          Value = rdpDateValue.SelectedDate.ToString();
         *
         *          bool? Approved = OldMetricValue.Approved;
         *          if (DataMode == Mode.Approve)
         *              switch (ddlApprovalStatus.SelectedValue)
         *              {
         *                  case "":
         *                      Approved = null;
         *                      break;
         *                  case "True":
         *                      Approved = true;
         *                      break;
         *                  case "False":
         *                  default:
         *                      Approved = false;
         *                      break;
         *              }
         *
         *          if (((!String.IsNullOrEmpty(Value) || (OldMetricValue.MetricValueID != Guid.Empty && String.IsNullOrEmpty(Value))) && Value != OldMetricValue.Value)
         ||
         ||             (DataMode == Mode.Approve && Approved != OldMetricValue.Approved))
         ||         {
         ||             Guid CurentUserId = Micajah.Common.Security.UserContext.Current.UserId;
         ||             Guid _ValueID = Bll.MetricValue.InsertOrUpdate(
         ||                 oMetricID,
         ||                 oDate,
         ||                 oOrgLocationID,
         ||                 OldMetricValue.FilesAttached,
         ||                 false,
         ||                 ActualUoMID,
         ||                 OldMetricValue.Value,
         ||                 Value,
         ||                 OldMetricValue.Approved,
         ||                 Approved,
         ||                 CurentUserId,
         ||                 OldMetricValue.Notes,
         ||                 null,
         ||                 null);
         ||
         ||             Bll.MetricValue.Extend NewMetricValue = Bll.MetricValue.Get(oMetricID, oDate, oOrgLocationID);
         ||             Bll.Mc_User.Extend mue = Bll.Mc_User.GetValueInputUser(OldMetricValue.MetricValueID);
         ||             // build mail to data collector if status or comment were changed
         ||             if ((DataMode == Mode.Approve) && (OldMetricValue.Approved != NewMetricValue.Approved))
         ||             {
         ||                 Bll.MetricValueChangeLog.LogChange(NewMetricValue.MetricValueID,
         ||                     Bll.MetricValueChangeTypeEnum.StatusChanged,
         ||                     OldMetricValue.ApprovalStatus,
         ||                     NewMetricValue.ApprovalStatus,
         ||                     Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, String.Empty, Micajah.Common.Security.UserContext.Current, mue, Bll.MetricValueChangeTypeEnum.StatusChanged));
         ||                 if (NewMetricValue.Approved == null)
         ||                     Utils.Mail.Send(mue.Email, mue.FullName, "MetricTrac - Value Status is changed", Utils.Mail.BuildEmailBody(OldMetricValue, NewMetricValue, String.Empty, Micajah.Common.Security.UserContext.Current));
         ||             }
         ||             // record in change log
         ||             if (OldMetricValue.MetricValueID == Guid.Empty)
         ||                 Bll.MetricValueChangeLog.LogChange(NewMetricValue.MetricValueID,
         ||                     MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered,
         ||                     String.Empty,
         ||                     NewMetricValue.Value,
         ||                     Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, "Bulk Edit", Micajah.Common.Security.UserContext.Current, mue, MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered));
         ||             else
         ||                 if (OldMetricValue.Value != NewMetricValue.Value)
         ||                     Bll.MetricValueChangeLog.LogChange(OldMetricValue.MetricValueID,
         ||                         MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged,
         ||                         OldMetricValue.Value,
         ||                         NewMetricValue.Value,
         ||                         Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, "Bulk Edit", Micajah.Common.Security.UserContext.Current, mue, MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged));
         ||         }
         ||         LogTime += "    value " + j.ToString() + " time  " + ((TimeSpan)(DateTime.Now - jTime)).TotalMilliseconds;
         ||         j++;
         ||     }
         ||     LogTime += "Row " + i.ToString() + " time  " + ((TimeSpan)(DateTime.Now - iTime)).TotalMilliseconds + "<br />";
         ||     i++;
         || }
         || if (DataMode == Mode.Input)
         ||     Response.Redirect("MetricInputList.aspx");
         || else
         || {
         ||     if (Micajah.Common.Security.UserContext.Breadcrumbs.Exists(r => r.Name.Contains("Approve Data"))) // TODO: change to redirect to parent
         ||         Response.Redirect("ApproveDataList.aspx");
         ||     else
         ||         Response.Redirect("ApproveWorkList.aspx");
         || }
         ||}*/

        protected void btnSwitch_Click(object sender, EventArgs e)
        {
            DateTime CurrentDateNormalized = Bll.Frequency.GetNormalizedDate(FrequencyID, CurrentDate);

            if (hfSwitch.Value.Equals("0"))
            {
                hfSwitch.Value = "1";
                DateTime ZeroDate = new DateTime(2000, 1, 1);
                if (MetricID != null)
                {
                    Metric.Extend metric = Metric.Get((Guid)MetricID);
                    if (metric.CollectionStartDate != null)
                    {
                        ZeroDate = (DateTime)metric.CollectionStartDate;
                    }
                    FrequencyFirstDate = Bll.Frequency.GetNormalizedDate(FrequencyID, ZeroDate);
                }
                else if (OrgLocationID != null)
                {
                    LastFrequencyMetric = GetData();
                    DateTime MetricMinDate = DateTime.MaxValue;
                    foreach (MetricOrgValue mov in LastFrequencyMetric.Metrics)
                    {
                        if (mov.CollectionStartDate != null)
                        {
                            if (MetricMinDate > mov.CollectionStartDate)
                            {
                                MetricMinDate = (DateTime)mov.CollectionStartDate;
                            }
                        }
                    }
                    if (MetricMinDate == DateTime.MaxValue)
                    {
                        MetricMinDate = ZeroDate;
                    }
                    FrequencyFirstDate = Bll.Frequency.GetNormalizedDate(FrequencyID, MetricMinDate);
                }
                FrequencyFirstDate = MetricTrac.Bll.Frequency.AddPeriod(FrequencyFirstDate, FrequencyID, 12);
                if (FrequencyFirstDate > CurrentDateNormalized)
                {
                    FrequencyFirstDate = CurrentDateNormalized;
                }
            }
            else if (hfSwitch.Value.Equals("1"))
            {
                hfSwitch.Value     = "0";
                FrequencyFirstDate = CurrentDateNormalized;
            }
        }
Exemple #3
0
        private void SaveBulkValues()
        {
            int i = 0;

            LastFrequencyMetric = GetData();
            List <Bll.MetricValue.Extend>   NewValues = new List <MetricValue.Extend>();
            List <Bll.MetricValue.Extend>   OldValues = new List <MetricValue.Extend>();
            List <Bll.MetricOrgLocationUoM> MetricOrgLocationUoMList = new List <Bll.MetricOrgLocationUoM>();

            foreach (RepeaterItem ri in rMetric.Items)
            {
                MetricOrgValue mov   = LastFrequencyMetric.Metrics[i];
                DateTime       iTime = DateTime.Now;
                DropDownList   ddlInputUnitOfMeasure = (DropDownList)ri.FindControl("ddlInputUnitOfMeasure");
                HiddenField    hfUoM         = (HiddenField)ri.FindControl("hfUoM");
                HiddenField    hfMetric      = (HiddenField)ri.FindControl("hfMetric");
                HiddenField    hfOrgLocation = (HiddenField)ri.FindControl("hfOrgLocation");
                Repeater       r             = (Repeater)ri.FindControl("rMericValue");

                Guid?ActualUoMID = null;
                if (ddlInputUnitOfMeasure.Visible)
                {
                    if (!String.IsNullOrEmpty(ddlInputUnitOfMeasure.SelectedValue))
                    {
                        ActualUoMID = new Guid(ddlInputUnitOfMeasure.SelectedValue);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(hfUoM.Value))
                    {
                        ActualUoMID = new Guid(hfUoM.Value);
                    }
                }
                Guid oMetricID      = new Guid(hfMetric.Value);
                Guid oOrgLocationID = new Guid(hfOrgLocation.Value);

                Bll.MetricOrgLocationUoM muom = new Bll.MetricOrgLocationUoM();
                muom.MetricID             = oMetricID;
                muom.OrgLocationID        = oOrgLocationID;
                muom.InputUnitOfMeasureID = ActualUoMID;
                MetricOrgLocationUoMList.Add(muom);

                int j = 0;
                foreach (RepeaterItem rri in r.Items)
                {
                    DateTime    jTime  = DateTime.Now;
                    HiddenField hfDate = (HiddenField)rri.FindControl("hfDate");
                    DateTime    oDate  = DateTime.Parse(hfDate.Value);
                    Telerik.Web.UI.RadNumericTextBox       rntValue          = (Telerik.Web.UI.RadNumericTextBox)rri.FindControl("rntValue");
                    System.Web.UI.WebControls.TextBox      tbValue           = (System.Web.UI.WebControls.TextBox)rri.FindControl("tbValue");
                    System.Web.UI.WebControls.CheckBox     chbValue          = (System.Web.UI.WebControls.CheckBox)rri.FindControl("chbValue");
                    Telerik.Web.UI.RadDatePicker           rdpDateValue      = (Telerik.Web.UI.RadDatePicker)rri.FindControl("rdpDateValue");
                    System.Web.UI.WebControls.DropDownList ddlApprovalStatus = (System.Web.UI.WebControls.DropDownList)rri.FindControl("ddlApprovalStatus");

                    Bll.MetricValue.Extend OldMetricValue = mov.MetricValues[j];
                    string Value = String.Empty;
                    if (rntValue.Visible)
                    {
                        Value = rntValue.Value.ToString();
                    }
                    else
                    if (tbValue.Visible)
                    {
                        Value = tbValue.Text;
                    }
                    else
                    if (chbValue.Visible)
                    {
                        Value = chbValue.Checked ? bool.TrueString : bool.FalseString;
                    }
                    else
                    if (rdpDateValue.Visible)
                    {
                        Value = rdpDateValue.SelectedDate.ToString();
                    }

                    bool?Approved = OldMetricValue.Approved;
                    if (DataMode == Mode.Approve)
                    {
                        switch (ddlApprovalStatus.SelectedValue)
                        {
                        case "":
                            Approved = null;
                            break;

                        case "True":
                            Approved = true;
                            break;

                        case "False":
                        default:
                            Approved = false;
                            break;
                        }
                    }

                    if (
                        (
                            (
                                !String.IsNullOrEmpty(Value)
                                ||
                                (OldMetricValue.MetricValueID != Guid.Empty && String.IsNullOrEmpty(Value))
                            ) &&
                            Value != OldMetricValue.Value
                        )
                        ||
                        (DataMode == Mode.Approve && Approved != OldMetricValue.Approved))
                    {
                        MetricValue.Extend nv = new MetricValue.Extend();
                        nv.MetricID             = oMetricID;
                        nv.Date                 = oDate;
                        nv.OrgLocationID        = oOrgLocationID;
                        nv.InputUnitOfMeasureID = ActualUoMID;
                        nv.Value                = Value;
                        nv.Approved             = Approved;
                        // additional fields
                        nv.Period              = Frequency.GetPeriodName(oDate, FrequencyID);
                        nv.MetricName          = mov.Name;
                        nv.OrgLocationFullName = mov.OrgLocationFullName;
                        nv.Notes = OldMetricValue.Notes;
                        nv.ValueInputUnitOfMeasureName = mov.OrgLocationUnitOfMeasureName;
                        NewValues.Add(nv);

                        OldValues.Add(OldMetricValue);
                    }
                    LogTime += "    value " + j.ToString() + " time  " + ((TimeSpan)(DateTime.Now - jTime)).TotalMilliseconds;
                    j++;
                }
                LogTime += "Row " + i.ToString() + " time  " + ((TimeSpan)(DateTime.Now - iTime)).TotalMilliseconds + "<br />";
                i++;
            }
            Bll.MetricValue.SaveBulkValues(MetricOrgLocationUoMList, NewValues, OldValues, Micajah.Common.Security.UserContext.Current, DataMode == Mode.Input);
        }