void saveErrorRang(errorrangset et)
        {
            errorrangset er = new errorrangset();

            er = et;
            try
            {
                er.speciesID    = this.cb_species.SelectedValue.ToString();
                er.speciesname  = (this.cb_species.SelectedItem as wrenchspecies).speciesName;
                er.rangmax      = Convert.ToDecimal(this.tb_max.Text.Trim());
                er.rangmin      = Convert.ToDecimal(this.tb_min.Text.Trim());
                er.errorrangMax = Convert.ToDecimal(this.tb_errormax.Text.Trim());
                er.errorrangMin = Convert.ToDecimal(this.tb_errormin.Text.Trim());
                er.errorrang    = _errorrangset.errorrangMin.ToString() + "~" + _errorrangset.errorrangMax.ToString();
                er.rangvalue    = this.tb_min.Text.Trim() + "~" + this.tb_max.Text.Trim();
            }
            catch
            {
                MessageAlert.Error("请填写正确的数值!"); return;
            }
            if (!string.IsNullOrEmpty(er.guid))
            {
                if (errorset.FindIndex(p => p.guid == er.guid) >= 0)
                {
                    errorset.RemoveAt(errorset.FindIndex(p => p.guid == er.guid));
                }
            }
            else
            {
                er.guid = Guid.NewGuid().ToString();
            }

            List <errorrangset> esl = errorset.FindAll(p => p.speciesname == er.speciesname);

            foreach (errorrangset e in esl)
            {
                if ((e.rangmin < er.rangmax && er.rangmax <= e.rangmax) || (e.rangmin <= er.rangmin && er.rangmin < e.rangmax))
                {
                    MessageAlert.Alert("设置数值范围重合!");
                    return;
                }
                if ((er.rangmax >= e.rangmax) && (er.rangmin <= e.rangmin))
                {
                    MessageAlert.Alert("设置数值范围重合!");
                    return;
                }
            }

            errorset.Add(er);
            if (SerializeXML <errorrangset> .exit())
            {
                SerializeXML <errorrangset> .del();
            }
            SerializeXML <errorrangset> .SaveList(errorset);

            getErrorRanng();
            Clear();
        }
 void Clear()
 {
     _errorrangset = null;
     isadd         = true;
     this.tb_errormax.Clear();
     this.tb_errormin.Clear();
     this.tb_max.Clear();
     this.tb_min.Clear();
 }
 private void editer_Click(object sender, RoutedEventArgs e)
 {
     if (this.dg_set.SelectedIndex < 0)
     {
         return;
     }
     _errorrangset = dg_set.SelectedItem as errorrangset;
     isadd         = false;
     showerrorset(_errorrangset);
 }
 private void bt_sub_Click(object sender, RoutedEventArgs e)
 {
     if (!IsRight())
     {
         return;
     }
     if (isadd)
     {
         _errorrangset = new errorrangset();
     }
     saveErrorRang(_errorrangset);
 }
        private void del_Click(object sender, RoutedEventArgs e)
        {
            if (this.dg_set.SelectedIndex < 0)
            {
                return;
            }

            errorrangset er = this.dg_set.SelectedItem as errorrangset;

            errorset.RemoveAt(errorset.FindIndex(p => p.guid == er.guid));
            if (SerializeXML <errorrangset> .exit())
            {
                SerializeXML <errorrangset> .del();
            }
            SerializeXML <errorrangset> .SaveList(errorset);

            getErrorRanng();
        }
 void showerrorset(errorrangset e)
 {
     if (e != null)
     {
         foreach (wrenchspecies s in cb_species.Items)
         {
             if (s.guid == e.speciesID)
             {
                 cb_species.SelectedItem = s;
                 break;
             }
         }
         this.tb_errormax.Text = e.errorrangMax.ToString();
         this.tb_errormin.Text = e.errorrangMin.ToString();
         this.tb_max.Text      = e.rangmax.ToString();
         this.tb_min.Text      = e.rangmin.ToString();
     }
 }