Example #1
0
        protected string GetValueCss(object container)
        {
            MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
            if ((val.Approved == false) && !val.FilesAttached)
            {
                return(string.Empty);
            }
            string ret = "class='";

            if (val.Approved == true)
            {
                ret += "tick";
            }
            else
            if (val.Approved == null)
            {
                ret += "rick";
                if (val.ReviewUpdated)
                {
                    ret += "-up";
                }
            }
            if (val.FilesAttached)
            {
                if (val.Approved != false)
                {
                    ret += "-";
                }
                ret += "clip";
            }
            ret += "'";
            return(ret);
        }
Example #2
0
        protected string GetClientId(object container)
        {
            System.Web.UI.WebControls.RepeaterItem ri  = container as System.Web.UI.WebControls.RepeaterItem;
            MetricTrac.Bll.MetricValue.Extend      val = ri.DataItem as MetricTrac.Bll.MetricValue.Extend;
            string ClientId = String.Empty;

            switch (val.MetricDataTypeID)
            {
            case 2:
                System.Web.UI.WebControls.TextBox tbValue = (System.Web.UI.WebControls.TextBox)ri.FindControl("tbValue");
                ClientId = tbValue.ClientID;
                break;

            case 3:
                System.Web.UI.WebControls.CheckBox chbValue = (System.Web.UI.WebControls.CheckBox)ri.FindControl("chbValue");
                ClientId = chbValue.ClientID;
                break;

            case 4:
                Telerik.Web.UI.RadDatePicker rdpDateValue = (Telerik.Web.UI.RadDatePicker)ri.FindControl("rdpDateValue");
                ClientId = rdpDateValue.ClientID;
                break;

            case 1:
            default:
                Telerik.Web.UI.RadNumericTextBox rntValue = (Telerik.Web.UI.RadNumericTextBox)ri.FindControl("rntValue");
                ClientId = rntValue.ClientID;
                break;
            }
            return(ClientId);
        }
Example #3
0
        protected string GetValueTitle(object container)
        {
            MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
            string title = String.Empty;

            if (val.IsCalculated == true)
            {
                title = "Calc value";
                if (val.MissedCalc)
                {
                    title += " | Some input values missed";
                }
            }
            else
            {
                title = "Input value";
            }
            switch (val.Approved)
            {
            case null:
                title += (val.ReviewUpdated) ? " | Under Review (Updated)" : " | Under Review";
                break;

            case true:
                title += " | Approved";
                break;

            case false:
            default:
                title += " | Pending";
                break;
            }
            return(title);
        }
Example #4
0
        protected string GetEditUrl(object container)
        {
            System.Web.UI.WebControls.RepeaterItem ri  = container as System.Web.UI.WebControls.RepeaterItem;
            MetricTrac.Bll.MetricValue.Extend      val = ri.DataItem as MetricTrac.Bll.MetricValue.Extend;
            int BackPageIndex = 1;

            switch (DataMode)
            {
            case Mode.Input:
                BackPageIndex = 1;
                break;

            case Mode.Approve:
                BackPageIndex = 2;
                break;

            default:
                BackPageIndex = 1;
                break;
            }
            return("MetricInputEdit.aspx?MetricID=" + val.MetricID +
                   "&Date=" + val.Date.ToString("MM-dd-yyyy") +
                   "&OrgLocationID=" + LastMetricMetricValue.OrgLocationID +
                   "&Mode=" + DataMode.ToString() +
                   "&BulkEdit=True" +
                   "&BackPage=" + BackPageIndex.ToString());
        }
Example #5
0
        protected string GetEditUrl(object container)
        {
            MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
            int BackPageIndex = 4;

            switch (DataMode)
            {
            case Mode.Input:
                BackPageIndex = 3;
                break;

            case Mode.View:
                BackPageIndex = 4;
                break;

            case Mode.Approve:
                BackPageIndex = 5;
                break;

            default:
                BackPageIndex = 4;
                break;
            }
            return("MetricInputEdit.aspx?MetricID=" + val.MetricID +
                   "&Date=" + val.Date.ToString("MM-dd-yyyy") +
                   "&OrgLocationID=" + LastMetricMetricValue.OrgLocationID +
                   "&Mode=" + DataMode.ToString() +
                   "&BackPage=" + BackPageIndex.ToString());
        }
Example #6
0
 protected string GetEditUrl(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return("MetricInputEdit.aspx?MetricID=" + val.MetricID +
            "&Date=" + val.Date.ToString("MM-dd-yyyy") +
            "&OrgLocationID=" + LastMetricOrgValue.OrgLocationID +
            "&Mode=" + DataMode.ToString() +
            "&BackPage=6");
 }
Example #7
0
        public static string BuildLogMessageBody(Bll.MetricValue.Extend OldValue, MetricTrac.Bll.MetricValue.Extend NewValue, string message, Micajah.Common.Security.UserContext context, Bll.Mc_User.Extend e, MetricTrac.Bll.MetricValueChangeTypeEnum changeType)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("User");
            if (context != null)
            {
                sb.Append(": " + context.FirstName + " " + context.LastName);
            }
            sb.Append(" ");
            switch (changeType)
            {
            case MetricTrac.Bll.MetricValueChangeTypeEnum.StatusChanged:
                sb.Append("change value status from \"" + GetStatusName(OldValue.Approved) + "\" to \"" + GetStatusName(NewValue.Approved) + "\"");
                break;

            case MetricTrac.Bll.MetricValueChangeTypeEnum.CommentToDataCollector:
                break;

            case MetricTrac.Bll.MetricValueChangeTypeEnum.NoteChanged:
                sb.Append("change value note from \"" + OldValue.Notes + "\" to \"" + NewValue.Notes + "\" ");
                break;

            case MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered:
                sb.Append("enter value " + NewValue.Value + "\" ");
                break;

            case MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged:
            default:
                sb.Append("change Value from \"" + OldValue.Value + "\" to \"" + NewValue.Value + "\" ");
                break;
            }
            sb.Append("<br />");
            if (changeType != MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged)
            {
                sb.Append("Comment to Data Collector: " + HttpUtility.HtmlEncode(message) + "<br />");
            }
            else
            {
                sb.Append("Note: " + message + "<br />");
            }
            if (e != null)
            {
                sb.Append("Data Collector: " + e.FullName);
            }
            sb.Append("<br />");
            if (NewValue != null)
            {
                sb.Append("Metric Value:<br />");
                sb.Append("Metric - " + NewValue.MetricName + "<br />");
                sb.Append("Org Location - " + NewValue.OrgLocationFullName + "<br />");
                sb.Append("Date - " + NewValue.Period + "<br />");
                sb.Append("Value - " + NewValue.Value + " " + NewValue.ValueInputUnitOfMeasureName + "<br />");
            }
            return(sb.ToString());
        }
Example #8
0
 protected bool IsEditValue(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     if (DataMode == Mode.Input)
     {
         return(!val.IsAbsent);
     }
     else
     {
         return(val.Value != null);
     }
 }
Example #9
0
 protected bool IsEditValue(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     if (DataMode == Mode.Input)
     {
         return(val.CollectionEnabled);
     }
     else
     {
         return(val.Value != null && !(val.Approved == true && DataMode == Mode.Approve) && !(val.IsTotalAgg == true && DataMode == Mode.View));
     }
 }
Example #10
0
        protected string GetEmptyStyle(object container)
        {
            string style = String.Empty;

            MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
            if (val.IsAbsent)
            {
                style = " absent";
            }
            else
            if (val.Value == null)
            {
                style = " empty";
            }
            return(style);
        }
Example #11
0
        protected string GetValueCss(object container)
        {
            MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
            string ret = "class='";

            if (DataMode == Mode.Approve && val.Approved == true)
            {
                return("class='empty-css'");
            }
            if (val.IsCalculated == true && val.MissedCalc)
            {
                ret += "rick";
            }
            else
            {
                if ((val.Approved == false) && !val.FilesAttached)
                {
                    return("class='empty-css'");
                }
                if (val.Approved == true)
                {
                    ret += "tick";
                }
                else
                if (val.Approved == null)
                {
                    ret += "rick";
                    if (val.ReviewUpdated)
                    {
                        ret += "-up";
                    }
                }
            }
            if (val.FilesAttached)
            {
                if (val.Approved != false)
                {
                    ret += "-";
                }
                ret += "clip";
            }
            ret += "'";
            return(ret);
        }
Example #12
0
 protected int GetElementType(object container)
 {
     System.Web.UI.WebControls.RepeaterItem ri  = container as System.Web.UI.WebControls.RepeaterItem;
     MetricTrac.Bll.MetricValue.Extend      val = ri.DataItem as MetricTrac.Bll.MetricValue.Extend;
     return(val.MetricDataTypeID);
 }
Example #13
0
 protected bool IsCollectingValue(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(val.CollectionEnabled);
 }
Example #14
0
 protected bool IsEditValue(object container)
 {
     System.Web.UI.WebControls.RepeaterItem ri  = container as System.Web.UI.WebControls.RepeaterItem;
     MetricTrac.Bll.MetricValue.Extend      val = ri.DataItem as MetricTrac.Bll.MetricValue.Extend;
     return((DataMode == Mode.Input) ? val.CollectionEnabled : (val.Value != null));
 }
Example #15
0
        protected void ldsMetricValue_Updating(object sender, LinqDataSourceUpdateEventArgs e)
        {
            // save previous value
            MetricTrac.Bll.MetricValue.Extend OldMetricValue = MVS;
            // get new data
            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();
            }
            ValueArgument = Value;
            Guid?ActualUoMID = null;

            if (!String.IsNullOrEmpty(ddlInputUnitOfMeasure.SelectedValue))
            {
                ActualUoMID = new Guid(ddlInputUnitOfMeasure.SelectedValue);
            }
            string CustomMetricAlias = null; // if pass null to Isert/Update - nothing changed. It's possible if custom names disabled or bulk edit
            string CustomMetricCode  = null;

            if (MVS.AllowMetricCustomNames)
            {
                CustomMetricAlias = tbAlias.Text;
                CustomMetricCode  = tbCode.Text;
            }

            bool?Approved = false;

            switch (ddlApprovalStatus.SelectedValue)
            {
            case "":
                Approved = null;
                break;

            case "True":
                Approved = true;
                break;

            case "False":
            default:
                Approved = false;
                break;
            }
            ValueArgument = Value + "|" + Approved.ToString();
            string comments     = tbComments.Text;
            string Notes        = ((Micajah.Common.WebControls.TextBox)mfMetricValue.FindFieldControl("Notes")).Text;
            Guid   CurentUserId = Micajah.Common.Security.UserContext.Current.UserId;
            //------------------------------

            Guid _ValueID = Bll.MetricValue.InsertOrUpdate(
                MetricID,
                OperationDate,
                OrgLocationID,
                !FilesUpload.IsEmpty,
                Mode == DataMode.Approve,
                ActualUoMID,
                OldMetricValue.Value,
                Value,
                OldMetricValue.Approved,
                Approved,
                CurentUserId,
                Notes,
                CustomMetricAlias,
                CustomMetricCode);

            if (_ValueID != Guid.Empty)
            {
                FilesUpload.LocalObjectId = _ValueID.ToString();
                if (!FilesUpload.AcceptChanges())
                {
                    if (FilesUpload.ErrorOccurred)
                    {
                        string _errorMessage = String.Empty;
                        foreach (string s in FilesUpload.ErrorMessages)
                        {
                            _errorMessage += s + "\n";
                        }
                        this.ErrorMessage = _errorMessage;
                    }
                }
            }
            else // change this error handler after adding central error tracker
            {
                this.ErrorMessage = "Unable to save changes. Please, try again later.";
            }
            Bll.MetricValue.Extend NewMetricValue = Bll.MetricValue.Get(MetricID, OperationDate, OrgLocationID);
            Bll.Mc_User.Extend     mue            = Bll.Mc_User.GetValueInputUser(OldMetricValue.MetricValueID);
            // build mail to data collector if status or comment were changed
            if ((Mode == DataMode.Approve) && ((!String.IsNullOrEmpty(comments)) || (OldMetricValue.Approved != NewMetricValue.Approved)))
            {
                string MailCaption = OldMetricValue.Approved != NewMetricValue.Approved ? "MetricTrac - Value Status is changed" : "SustainApp - Value has new comment from Data Approver";
                if (OldMetricValue.Approved != NewMetricValue.Approved)
                {
                    Bll.MetricValueChangeLog.LogChange(NewMetricValue.MetricValueID,
                                                       Bll.MetricValueChangeTypeEnum.StatusChanged,
                                                       OldMetricValue.ApprovalStatus,
                                                       NewMetricValue.ApprovalStatus,
                                                       Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, comments, Micajah.Common.Security.UserContext.Current, mue, Bll.MetricValueChangeTypeEnum.StatusChanged));
                }
                else
                {
                    Bll.MetricValueChangeLog.LogChange(NewMetricValue.MetricValueID,
                                                       Bll.MetricValueChangeTypeEnum.CommentToDataCollector,
                                                       null,
                                                       comments,
                                                       Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, comments, Micajah.Common.Security.UserContext.Current, mue, Bll.MetricValueChangeTypeEnum.CommentToDataCollector));
                }
                if (NewMetricValue.Approved == null && mue != null)
                {
                    Utils.Mail.Send(mue.Email, mue.FullName, MailCaption, Utils.Mail.BuildEmailBody(OldMetricValue, NewMetricValue, comments, Micajah.Common.Security.UserContext.Current));
                }
            }


            // record in change log
            // first time value entered
            if (OldMetricValue.MetricValueID == Guid.Empty)
            {
                Bll.MetricValueChangeLog.LogChange(NewMetricValue.MetricValueID,
                                                   MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered,
                                                   String.Empty,
                                                   NewMetricValue.Value,
                                                   Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, Notes, Micajah.Common.Security.UserContext.Current, mue, MetricTrac.Bll.MetricValueChangeTypeEnum.ValueEntered));
            }
            else
            {
                // value changed
                if (OldMetricValue.Value != NewMetricValue.Value)
                {
                    Bll.MetricValueChangeLog.LogChange(MVS.MetricValueID,
                                                       MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged,
                                                       OldMetricValue.Value,
                                                       NewMetricValue.Value,
                                                       Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, Notes, Micajah.Common.Security.UserContext.Current, mue, MetricTrac.Bll.MetricValueChangeTypeEnum.ValueChanged));
                }
                // notes changed
                if (OldMetricValue.Notes != NewMetricValue.Notes)
                {
                    Bll.MetricValueChangeLog.LogChange(MVS.MetricValueID,
                                                       MetricTrac.Bll.MetricValueChangeTypeEnum.NoteChanged,
                                                       OldMetricValue.Notes,
                                                       NewMetricValue.Notes,
                                                       Utils.Mail.BuildLogMessageBody(OldMetricValue, NewMetricValue, Notes, Micajah.Common.Security.UserContext.Current, mue, MetricTrac.Bll.MetricValueChangeTypeEnum.NoteChanged));
                }
            }

            e.Cancel = true;
        }
Example #16
0
        protected void rpMetricValue_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType < ListItemType.Item || e.Item.ItemType > ListItemType.EditItem)
            {
                return;
            }
            MetricTrac.Bll.MetricValue.Extend      MVS               = (MetricTrac.Bll.MetricValue.Extend)e.Item.DataItem;
            Telerik.Web.UI.RadNumericTextBox       rntValue          = (Telerik.Web.UI.RadNumericTextBox)e.Item.FindControl("rntValue");
            System.Web.UI.WebControls.TextBox      tbValue           = (System.Web.UI.WebControls.TextBox)e.Item.FindControl("tbValue");
            System.Web.UI.WebControls.CheckBox     chbValue          = (System.Web.UI.WebControls.CheckBox)e.Item.FindControl("chbValue");
            Telerik.Web.UI.RadDatePicker           rdpDateValue      = (Telerik.Web.UI.RadDatePicker)e.Item.FindControl("rdpDateValue");
            System.Web.UI.WebControls.DropDownList ddlApprovalStatus = (System.Web.UI.WebControls.DropDownList)e.Item.FindControl("ddlApprovalStatus");
            ddlApprovalStatus.Attributes.Add("onchange", "valueChanged();return false;");
            if ((DataMode == Mode.Approve) && (MVS.Value != null))
            {
                ListsStringArray += ddlApprovalStatus.ClientID + "|";
            }
            bool IsDataTypeChanged = false;
            bool IsNewRecord       = false;

            if (MVS.MetricValueID == Guid.Empty)
            {
                IsNewRecord = true;
            }
            else
            if (MVS.MetricDataTypeID != MVS.ActualMetricDataTypeID)
            {
                IsDataTypeChanged = true;
            }
            switch (LastMetricMetricValue.MetricDataTypeID)
            {
            case 2:    //Text
                tbValue.Visible  = true;
                rntValue.Visible = chbValue.Visible = rdpDateValue.Visible = false;
                tbValue.Text     = String.Empty;
                if (!IsDataTypeChanged)
                {
                    tbValue.Text = MVS.Value;
                }
                break;

            case 3:    //Bool - checkbox
                chbValue.Visible = true;
                rntValue.Visible = tbValue.Visible = rdpDateValue.Visible = false;
                chbValue.Checked = false;
                if (!IsDataTypeChanged)
                {
                    chbValue.Checked = MVS.Value == bool.TrueString;
                }
                break;

            case 4:    //Date
                rdpDateValue.Visible      = true;
                rntValue.Visible          = tbValue.Visible = chbValue.Visible = false;
                rdpDateValue.SelectedDate = DateTime.Now;
                DateTime _dt = DateTime.Now;
                if (!IsDataTypeChanged)
                {
                    if (DateTime.TryParse(MVS.Value, out _dt))
                    {
                        rdpDateValue.SelectedDate = _dt;
                    }
                }
                break;

            case 1:    //Numeric
            default:
                rntValue.Visible  = true;
                rntValue.ReadOnly = LastMetricMetricValue.MetricTypeID > 1;
                tbValue.Visible   = chbValue.Visible = rdpDateValue.Visible = false;
                rntValue.Text     = String.Empty;
                if ((!IsDataTypeChanged) && ((MVS.UnitOfMeasureID == MVS.MetricUnitOfMeasureID) || IsNewRecord))
                {
                    double _Value = double.NaN;
                    if (double.TryParse(MVS.Value, out _Value))
                    {
                        rntValue.Value = _Value;
                    }
                }

                // Range label
                if ((MVS.NOMinValue != null) || (MVS.NOMaxValue != null) || (MVS.NODecPlaces != null))
                {
                    int defPlaces = 2;
                    if (MVS.NODecPlaces != null)
                    {
                        rntValue.NumberFormat.DecimalDigits = (int)MVS.NODecPlaces;
                        defPlaces = (int)MVS.NODecPlaces;
                    }
                    if (MVS.NOMinValue != null)
                    {
                        rntValue.MinValue = decimal.ToDouble((decimal)MVS.NOMinValue);
                    }
                    if (MVS.NOMaxValue != null)
                    {
                        rntValue.MaxValue = decimal.ToDouble((decimal)MVS.NOMaxValue);
                    }
                }
                break;
            }
        }
Example #17
0
 protected bool IsEmptyValue(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(val.Value == null || (DataMode == Mode.Approve && val.Approved == true));
 }
Example #18
0
 protected bool IsTotalValue(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(val.IsTotalAgg);
 }
Example #19
0
 protected string GetValueCell(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(Bll.MetricValue.FormatValue(val, (DataMode == Mode.Approve && val.Approved == true)));
 }
Example #20
0
 protected string GetValueCell(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(Bll.MetricValue.FormatValue(val) + "&nbsp;" + val.ValueInputUnitOfMeasureName);
 }
Example #21
0
 protected string GetValueCell(object container)
 {
     MetricTrac.Bll.MetricValue.Extend val = GetValue(container);
     return(Bll.MetricValue.FormatValue(val));
 }