Beispiel #1
0
        protected void gridLabUnits_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                List <ParameterResultConfig> configs = this.UnitConfig;

                ParameterResultConfig _config = configs.ElementAt(e.RowIndex);


                if (_config.Id > 0)
                {
                    _config.DeleteFlag = true;
                }
                else
                {
                    configs.RemoveAt(e.RowIndex);
                }
                this.UnitConfig = configs;
                this.BindParameterConfig();
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ref ex);
            }
        }
Beispiel #2
0
        void BindParameterConfig()
        {
            try
            {
                List <ParameterResultConfig> configs = this.UnitConfig;

                if (configs.Count == 0)
                {
                    ParameterResultConfig param = new ParameterResultConfig()
                    {
                        Id = -1, DeleteFlag = true, ParameterId = this.ParameterId
                    };
                    List <ParameterResultConfig> ie = new List <ParameterResultConfig>();
                    ie.Add(param);

                    gridLabUnits.DataSource = ie;
                    gridLabUnits.DataBind();
                    gridLabUnits.Rows[0].Visible = false;
                }
                else
                {
                    this.gridLabUnits.DataSource = configs.Where(c => c.DeleteFlag == false);
                    this.gridLabUnits.DataBind();
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ref ex);
            }
        }
Beispiel #3
0
        private void BindConfigPlaceHolder()
        {
            ParameterResultConfig param = new ParameterResultConfig()
            {
                Id = -1, DeleteFlag = true, ParameterId = -1, ResultUnit = new ResultUnit()
                {
                    Id = -1, Text = "PlaceHolder"
                }
            };
            List <ParameterResultConfig> ie = new List <ParameterResultConfig>();

            ie.Add(param);

            gridLabUnits.DataSource = ie;
            gridLabUnits.DataBind();
            gridLabUnits.Rows[0].Visible = false;
        }
Beispiel #4
0
        protected void gridLabUnits_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                DropDownList ddlNewUnitName = (DropDownList)e.Row.FindControl("ddlNewUnitName");

                ddlNewUnitName.DataSource     = (IEnumerable <ResultUnit>)base.Session[SessionKey.ResultUnit];
                ddlNewUnitName.DataTextField  = "Text";
                ddlNewUnitName.DataValueField = "Id";
                ddlNewUnitName.DataBind();
                ddlNewUnitName.Items.Insert(0, new ListItem("Select", "-1"));
            }
            else if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                ParameterResultConfig rowView        = (ParameterResultConfig)e.Row.DataItem;
                DropDownList          ddEditUnitName = (DropDownList)e.Row.FindControl("ddEditUnitName");
                ddEditUnitName.DataSource     = (IEnumerable <ResultUnit>)base.Session[SessionKey.ResultUnit];
                ddEditUnitName.DataTextField  = "Text";
                ddEditUnitName.DataValueField = "Id";
                ddEditUnitName.DataBind();
                ddEditUnitName.Items.Insert(0, new ListItem("Select", "-1"));
                ddEditUnitName.SelectedValue = rowView.UnitId.ToString();
            }
        }
Beispiel #5
0
 protected void gridLabUnits_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     try
     {
         List <ParameterResultConfig> configs = this.UnitConfig;
         GridViewRow           rowView        = gridLabUnits.Rows[e.RowIndex];
         ParameterResultConfig config         = configs.ElementAt(e.RowIndex);
         if (config.Id < 1)
         {
             configs.Remove(config);
         }
         DropDownList ddEditUnitName = rowView.FindControl("ddEditUnitName") as DropDownList;
         if (ddEditUnitName.SelectedValue == "-1")
         {
             e.Cancel = true;
             ddEditUnitName.BorderColor = System.Drawing.Color.Red;
             IQCareMsgBox.NotifyAction("Please select the unit", "Error: Missing Fields", true, this, "");
             return;
         }
         {
             var duplicate = configs.DefaultIfEmpty(null).FirstOrDefault(u =>
                                                                         u.UnitId == Convert.ToInt32(ddEditUnitName.SelectedValue) &&
                                                                         u.DeleteFlag == false &&
                                                                         u.Id != config.Id);
             if (null != duplicate)
             {
                 e.Cancel = true;
                 ddEditUnitName.BorderColor = System.Drawing.Color.Red;
                 IQCareMsgBox.NotifyAction("Please select the unit", "Error: Duplicate Unit", true, this, "");
                 return;
             }
         }
         TextBox  txtEditMinBoundaryValue = rowView.FindControl("txtEditMinBoundaryValue") as TextBox;
         TextBox  txtEditMaxBoundaryValue = rowView.FindControl("txtEditMaxBoundaryValue") as TextBox;
         TextBox  txtEditMinNormalRange   = rowView.FindControl("txtEditMinNormalRange") as TextBox;
         TextBox  txtEditMaxNormalRange   = rowView.FindControl("txtEditMaxNormalRange") as TextBox;
         TextBox  txtEditDetectionLimit   = rowView.FindControl("txtEditDetectionLimit") as TextBox;
         CheckBox ckbDefault = rowView.FindControl("ckbDefault") as CheckBox;
         if (ckbDefault.Checked)
         {
             if (configs.Count > 0)
             {
                 configs.ForEach(u =>
                 {
                     u.IsDefault = false;
                 });
             }
         }
         // config.DeleteFlag = true;
         configs.Add(new ParameterResultConfig()
         {
             Id             = -1,
             ParameterId    = this.ParameterId,
             IsDefault      = ckbDefault.Checked,
             DeleteFlag     = false,
             DetectionLimit = txtEditDetectionLimit.Text == "" ? nullDecimal : Convert.ToDecimal(txtEditDetectionLimit.Text),
             MinBoundary    = txtEditMinBoundaryValue.Text == "" ? nullDecimal : Convert.ToDecimal(txtEditMinBoundaryValue.Text),
             MaxBoundary    = txtEditMaxBoundaryValue.Text == "" ? nullDecimal : Convert.ToDecimal(txtEditMaxBoundaryValue.Text),
             MinNormalRange = txtEditMinNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtEditMinNormalRange.Text),
             MaxNormalRange = txtEditMaxNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtEditMaxNormalRange.Text),
             ResultUnit     = new ResultUnit()
             {
                 Id = Convert.ToInt32(ddEditUnitName.SelectedValue), Text = ddEditUnitName.SelectedItem.Text
             }
         });
         this.UnitConfig        = configs;
         gridLabUnits.EditIndex = -1;
         this.BindParameterConfig();
     }
     catch (Exception ex)
     {
         this.ShowErrorMessage(ref ex);
     }
 }
Beispiel #6
0
        protected void gridLabUnits_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "AddItem")
                {
                    GridViewRow  row            = gridLabUnits.FooterRow;
                    DropDownList ddlNewUnitName = (DropDownList)row.FindControl("ddlNewUnitName");
                    if (!validateDropDown(ddlNewUnitName))
                    {
                        ddlNewUnitName.BorderColor = System.Drawing.Color.Red;
                        IQCareMsgBox.NotifyAction("Please select the unit", "Error: Missing Fields", true, this, "");
                        return;
                    }
                    ResultUnit unit = new ResultUnit()
                    {
                        Id = int.Parse(ddlNewUnitName.SelectedValue), Text = ddlNewUnitName.SelectedItem.Text
                    };

                    TextBox texMinBoundary = row.FindControl("txtNewMinBoundaryValue") as TextBox;

                    TextBox txtNewMaxBoundaryValue = row.FindControl("txtNewMaxBoundaryValue") as TextBox;

                    TextBox txtNewMinNormalRange = row.FindControl("txtNewMinNormalRange") as TextBox;

                    TextBox txtNewMaxNormalRange = row.FindControl("txtNewMaxNormalRange") as TextBox;

                    TextBox txtNewDetectionLimit = row.FindControl("txtNewDetectionLimit") as TextBox;

                    bool     defaultunit   = false;
                    CheckBox ckbNewDefault = row.FindControl("ckbNewDefault") as CheckBox;
                    defaultunit = ckbNewDefault.Checked;
                    List <ParameterResultConfig> _configs = this.UnitConfig;
                    if (defaultunit)
                    {
                        if (_configs.Count > 0)
                        {
                            _configs.ForEach(u =>
                            {
                                u.IsDefault = false;
                            });
                        }
                    }

                    ParameterResultConfig config = null;
                    if (_configs.Count > 0)
                    {
                        config = _configs.DefaultIfEmpty(null).FirstOrDefault(u => u.UnitId == unit.Id);
                    }
                    if (config != null)
                    {
                        config.DeleteFlag     = false;
                        config.IsDefault      = defaultunit;
                        config.DetectionLimit = txtNewDetectionLimit.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewDetectionLimit.Text);
                        config.MaxBoundary    = txtNewMaxBoundaryValue.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMaxBoundaryValue.Text);
                        config.MinBoundary    = texMinBoundary.Text == "" ? nullDecimal : Convert.ToDecimal(texMinBoundary.Text);
                        config.MaxNormalRange = txtNewMaxNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMaxNormalRange.Text);
                        config.MinNormalRange = txtNewMinNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMinNormalRange.Text);
                    }
                    else
                    {
                        config = new ParameterResultConfig()
                        {
                            ParameterId    = this.ParameterId,
                            Id             = -1,
                            DeleteFlag     = false,
                            IsDefault      = defaultunit,
                            DetectionLimit = txtNewDetectionLimit.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewDetectionLimit.Text),
                            MinBoundary    = texMinBoundary.Text == "" ? nullDecimal : Convert.ToDecimal(texMinBoundary.Text),
                            MaxBoundary    = txtNewMaxBoundaryValue.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMaxBoundaryValue.Text),
                            MinNormalRange = txtNewMinNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMinNormalRange.Text),
                            MaxNormalRange = txtNewMaxNormalRange.Text == "" ? nullDecimal : Convert.ToDecimal(txtNewMaxNormalRange.Text),
                            ResultUnit     = unit
                        };
                        _configs.Add(config);
                    };
                    this.UnitConfig = _configs;
                    this.BindParameterConfig();
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ref ex);
            }
        }