private void btnSave_Click(object sender, EventArgs e) { Model model = modelCRUD1.Model; try { if (!ModelHelper.Validate(model)) { CustomMessageBox.ShowError(ResourceHelper.GetResourceText("RequiredName")); return; } List <ModelFactor> factors = modelCRUD1.ModelFactors; if (factors.Count == 0) { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("AtLeastOneFactor")); return; } model = ModelHelper.Save(model); foreach (ModelFactor mf in factors) { mf.IDModel = model.IDModel; ModelFactorHelper.Save(mf); } CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk")); ViewManager.ShowStart(); ViewManager.LoadModelsMenu(); } catch (Exception exception) { CustomMessageBox.ShowError(ResourceHelper.GetResourceText("ModelSavingError") + exception.Message); } }
private void btnSaveCustomColors_Click(object sender, EventArgs e) { //Recorre todos los cuadraditos y recupera los backGround y los guarda Model model = ModelHelper.GetModel(ERMTSession.Instance.CurrentModel.IDModel); ListModelFactor = ModelFactorHelper.GetByModel(model); List <int> groupByTotals = new List <int>(); List <CustomFactorColor> listaFactorColor = new List <CustomFactorColor>(); foreach (ModelFactor modelFactor in ListModelFactor) { var factor = FactorHelper.Get(modelFactor.IDFactor); CustomFactorColor custom = new CustomFactorColor(); int totalValue = (modelFactor.ScaleMax - modelFactor.ScaleMin + 1); //Chequeo que renderize solo las escalas o rangos distintos if (!groupByTotals.Contains(totalValue)) { groupByTotals.Add(totalValue); custom.IdFactor = modelFactor.IDFactor; custom.Name = modelFactor.ScaleMin + " - " + modelFactor.ScaleMax; custom.MaxValue = modelFactor.ScaleMax; custom.MinValue = modelFactor.ScaleMin; custom.TotalValues = (modelFactor.ScaleMax - modelFactor.ScaleMin + 1); var layOut = Controls.Find("layout" + factor.IdFactor, true); if (layOut != null && layOut.Length > 0) { var lay = (FlowLayoutPanel)layOut[0]; bool primerLable = true; foreach (var control in lay.Controls) { if (control.GetType() == typeof(Label) && !primerLable) { custom.ListColors.Add(((Label)control).BackColor); } else { primerLable = false; } } listaFactorColor.Add(custom); } } } CustomFactorColorHelper.SaveFactorColorsToXML(listaFactorColor, model.IDModel); Close(); }
public Boolean FactorsChanged() { if (_model == null) { //it's a new model, then factors MUST have been added. return(true); } List <int> databaseFactors = ModelFactorHelper.GetByModel(_model).Select(mf => mf.IDFactor).ToList(); List <int> checkedFactors = (from FactorItem fi in flpFactors.Controls where fi.Checked select fi.Factor.IDFactor).ToList(); databaseFactors.Sort(); checkedFactors.Sort(); return(!databaseFactors.SequenceEqual(checkedFactors)); }
private void btnSave_Click(object sender, EventArgs e) { try { foreach (ModelFactor f in OrderedModelFactors) { ModelFactorHelper.Save(f); } CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk")); ViewManager.CloseView(); } catch (Exception exception) { CustomMessageBox.ShowError(exception.Message); } }
private void EditModelFactorsOrder() { if (ERMTSession.Instance.CurrentModel != null) { _model = ERMTSession.Instance.CurrentModel; btnSave.Visible = true; btnCancel.Visible = true; lbModelFactors.Items.Clear(); lbModelFactors.DisplayMember = "Name"; foreach (ModelFactor mf in ModelFactorHelper.GetByModel(_model).OrderBy(mf => mf.SortOrder)) { ModelFactorAux aux = new ModelFactorAux { ModelFactor = mf, Name = FactorHelper.Get(mf.IDFactor).Name }; lbModelFactors.Items.Add(aux); } } }
private void LoadFactors(List <ModelFactor> list) { List <Factor> allFactors = FactorHelper.GetAll(); flpFactors.Controls.Clear(); foreach (Factor factor in allFactors) { FactorItem control = new FactorItem(); ModelFactor aux = ModelFactorHelper.GetNew(); aux.IDFactor = factor.IdFactor; aux.IDModel = _model.IDModel; if (!factor.CumulativeFactor) { aux.Interval = factor.Interval; aux.ScaleMin = factor.ScaleMin; aux.ScaleMax = factor.ScaleMax; aux.Weight = 100; } foreach (ModelFactor modelFactor in list) { if (factor.IdFactor == modelFactor.IDFactor) { control.Checked = true; if (factor.CumulativeFactor) { break; } aux.Interval = modelFactor.Interval; aux.ScaleMin = modelFactor.ScaleMin; aux.ScaleMax = modelFactor.ScaleMax; aux.Weight = modelFactor.Weight; break; } } control.Factor = aux; control.Editing = _editing; flpFactors.Controls.Add(control); } }
private void btnSave_Click(object sender, EventArgs e) { if (modelCRUD1.FactorsChanged() && CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("FactorsChangedMessage"), CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo) == CustomMessageBoxReturnValue.Cancel) { return; } try { Model model = modelCRUD1.Model; if (!ModelHelper.Validate(model)) { CustomMessageBox.ShowError(ResourceHelper.GetResourceText("RequiredName")); return; } List <ModelFactor> factors = modelCRUD1.ModelFactors; if (!factors.Any()) { CustomMessageBox.ShowError(ResourceHelper.GetResourceText("AtLeastOneFactor")); return; } model = ModelHelper.Save(model); foreach (ModelFactor mf in factors) { mf.IDModel = model.IDModel; ModelFactorHelper.Save(mf); } CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk")); ViewManager.LoadModelsMenu(); ViewManager.ShowStart(); EventManager.RaiseModelUpdated(); } catch (Exception exception) { CustomMessageBox.ShowError(exception.Message); } }
private void CreateListScuards() { List <XElement> listaElement = CustomFactorColorHelper.GetFactorColorsFromXML(ERMTSession.Instance.CurrentModel.IDModel); //Create and initialize a GroupBox and a Button control. Model model = ModelHelper.GetModel(ERMTSession.Instance.CurrentModel.IDModel); ListModelFactor = ModelFactorHelper.GetByModel(model); List <int> groupByTotals = new List <int>(); foreach (ModelFactor listFactor in ListModelFactor) { FlowLayoutPanel layout = new FlowLayoutPanel(); int totalValue = (listFactor.ScaleMax - listFactor.ScaleMin + 1); //FActor que no sean acumulativos if (totalValue > 1) { //Chequeo que renderize solo las escalas o rangos distintos var factorsColors = (from c in listaElement from cColors in c.Descendants("Colors") where (int)c.Element("TotalValues") == totalValue select cColors).ToList(); if (!groupByTotals.Contains(totalValue)) { groupByTotals.Add(totalValue); layout.Name = "layout" + listFactor.IDFactor; layout.Dock = DockStyle.None; //layout.BorderStyle = BorderStyle.FixedSingle; layout.Size = new Size(415, 49); Label lbl = new Label { Text = listFactor.ScaleMin + " - " + listFactor.ScaleMax, Name = listFactor.ScaleMin + " - " + listFactor.ScaleMax, Visible = true }; layout.Controls.Add(lbl); for (int i = 1; i <= totalValue; i++) { Label labelColorFactor = new Label { AutoSize = true, BackColor = factorsColors.Count > 0 ? ColorTranslator.FromHtml(factorsColors[0].Elements().ToList()[i - 1].Value) : Color.White, BorderStyle = BorderStyle.Fixed3D, Name = "lblColorFactor" + listFactor.IDFactor + i, Size = new Size(18, 15) }; labelColorFactor.Click += labelColorFactor_Click; labelColorFactor.TabIndex = i; labelColorFactor.Text = " "; layout.Controls.Add(labelColorFactor); } flowLayoutPanel1.Controls.Add(layout); } } } }