Beispiel #1
0
        public void DeleteValueById(int Id)
        {
            D_ATTRIBUTE_VALUE value = new D_ATTRIBUTE_VALUE()
            {
                ID = Id
            };

            Context.D_ATTRIBUTE_VALUE.Attach(value);
            Context.D_ATTRIBUTE_VALUE.DeleteObject(value);
            //Context.SaveChanges();
        }
        protected void btnEditValue_Click(object sender, EventArgs e)
        {
            lblResultValue.Visible = false;
            List <String> list = getCheckedValues();

            if (list.Count != 1)
            {
                writeValueError("Only one value must be selected for edit.");
            }
            else
            {
                ValueID = Int32.Parse(list.First());
                D_ATTRIBUTE_VALUE value = ApplicationContext.Current.Attributes.GetValueById(ValueID);
                if (value != null)
                {
                    txtValue.Text        = value.Value;
                    txtOrder.Text        = value.ShowOrder.ToString();
                    divValueEdit.Visible = true;
                }
            }
        }
        protected void btnSaveValue_Click(object sender, EventArgs e)
        {
            D_ATTRIBUTE_VALUE value = new D_ATTRIBUTE_VALUE();

            value.AttributeID = AttributeID;
            value.Value       = txtValue.Text;
            int order = 0;

            Int32.TryParse(txtOrder.Text, out order);
            value.ShowOrder = order;

            string operation;

            try
            {
                if (ValueID != 0)
                {
                    value.ID = ValueID;
                    ApplicationContext.Current.Attributes.UpdateValue(value);
                    operation = " updated ";
                }
                else
                {
                    ApplicationContext.Current.Attributes.InsertValue(value);
                    ValueID   = value.ID;
                    operation = " inserted ";
                }
                lblResultValue.Visible   = true;
                lblResultValue.ForeColor = Color.Green;
                lblResultValue.Text      = "Value" + operation + "correctly.";
                loadValues();
            }
            catch (Exception ex)
            {
                writeValueError(ex.Message);
            }
        }
 public void InsertValue(D_ATTRIBUTE_VALUE Value)
 {
     _attributeDAO.InsertValue(Value);
     Context.SaveChanges();
 }
 public void UpdateValue(D_ATTRIBUTE_VALUE Value)
 {
     _attributeDAO.UpdateValue(Value);
     Context.SaveChanges();
 }
Beispiel #6
0
 public void InsertValue(D_ATTRIBUTE_VALUE Value)
 {
     Context.D_ATTRIBUTE_VALUE.AddObject(Value);
     //Context.SaveChanges();
 }
Beispiel #7
0
 public void UpdateValue(D_ATTRIBUTE_VALUE Value)
 {
     Context.D_ATTRIBUTE_VALUE.Attach(Value);
     Context.ObjectStateManager.ChangeObjectState(Value, EntityState.Modified);
     //Context.SaveChanges();
 }
Beispiel #8
0
        public D_ATTRIBUTE_VALUE GetValueById(int Id)
        {
            D_ATTRIBUTE_VALUE val = Context.D_ATTRIBUTE_VALUE.Where(a => a.ID == Id).FirstOrDefault();

            return(val);
        }