private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         Student student = new Student();
         student.Course = Convert.ToInt32(Course_TXB.Text);
         student.Group  = Convert.ToInt32(Group_TXB.Text);
         student.Name   = Student_TXB.Text;
         db.dbSet.Add(student);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
 protected void Save() => _context.SaveChanges();
Esempio n. 3
0
    public CallbackResult CallBack_FormTag_65200_9()
    {
        /*id=request.id&allowempty=author,view&action=edit*/
        string formname = this.CallValue("formname");

        if (formname != "FormTag_65200_9")
        {
            return(null);
        }
        dynamic error = new ExpandoObject();

        error.formname = formname;
        CallbackResult call = new CallbackResult(error);

        call.type = "formcall";
        Article _article = null;
        long    long_id  = long.MinValue;

        long.TryParse("" + Request.QueryString["id"], out long_id);

        _article = Db_Context.Article.Where(x => x.IsLock != true).FirstOrDefault(b =>
                                                                                  b.ID == long_id
                                                                                  );
        if (_article == null)
        {
            /*编辑模式(action = edit),未找到记录则返回*/;
            error.code = 3;
            error.msg  = "操作失败:not found!";
            error.dom  = "";
            return(call);
        }
        string _Title = this.CallValue("Title");

        if (string.IsNullOrEmpty(_Title))
        {
            error.code = 1;
            error.msg  = "不能为空!";
            error.dom  = "Title";
            return(call);
        }
        _article.Title = _Title;
        string _Author = this.CallValue("Author");

        _article.Author = _Author;
        string   _Time  = this.CallValue("Time");
        DateTime __Time = DateTime.Now;

        if (DateTime.TryParse(_Time, out __Time))
        {
            _article.Time = __Time;
        }
        else
        {
            if (string.IsNullOrEmpty(_Time))
            {
                error.code = 1;
                error.msg  = "不能为空!";
                error.dom  = "Time";
                return(call);
            }
            else
            {
                error.code = 2;
                error.msg  = "请输入正确的时间";
                error.dom  = "Time";
                return(call);
            }
        }
        string _View  = this.CallValue("View");
        int    __View = 0;

        if (int.TryParse(_View, out __View))
        {
            _article.View = __View;
        }
        string _Content = this.CallValue("Content");

        if (string.IsNullOrEmpty(_Content))
        {
            error.code = 1;
            error.msg  = "不能为空!";
            error.dom  = "Content";
            return(call);
        }
        _article.Content = _Content;
        //
        Db_Context.SaveChanges();
        error.code = 0;
        error.msg  = "操作成功!";
        error.dom  = "";
        return(call);
    }
Esempio n. 4
0
 public bool SaveChanges()
 {
     return(_context.SaveChanges() >= 0);
 }