예제 #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (var context = new EverythingContext())
     {
         var value = Int32.Parse(txtValue.Text);
         if (context.SysDictionaries.Any(x => x.DictionaryNO == txtDictionaryNO.Text && x.Value == value))
         {
             MessageBox.Show("the dictionay" + txtDictionaryName.Text + "already has this value");
             return;
         }
         var item = new SysDictionary
         {
             ID           = Guid.NewGuid().ToString(),
             DictionaryNO = txtDictionaryNO.Text,
             Name         = txtDictionaryName.Text,
             Value        = Int32.Parse(txtValue.Text),
             Display      = txtDisplay.Text,
             Remark       = txtRemark.Text
         };
         context.SysDictionaries.Add(item);
         if (context.SaveChanges() == 1)
         {
             MessageBox.Show("success");
         }
     }
 }
예제 #2
0
        private void btnAddDic_Click(object sender, EventArgs e)
        {
            string dicNO   = txtDicNO.Text;
            string dicName = txtDicName.Text;

            using (var context = new EverythingContext())
            {
                var exit = context.SysDictionaries.Any(x => x.DictionaryNO == dicNO);
                if (exit)
                {
                    MessageBox.Show("ExitDicNO");
                }
                else
                {
                    var dictionary = new SysDictionary
                    {
                        ID           = Guid.NewGuid().ToString(),
                        DictionaryNO = dicNO,
                        Name         = dicName,
                        Value        = -1,
                        Display      = dicName
                    };
                    context.SysDictionaries.Add(dictionary);
                    if (context.SaveChanges() == 1)
                    {
                        MessageBox.Show("success");
                    }
                }
            }
        }