コード例 #1
0
ファイル: EditDream.cs プロジェクト: lutuandat0411/Dreambook
        private void EditDream_Load(object sender, EventArgs e)
        {
            DreamDBEntities1 db = new DreamDBEntities1();

            txtName.Text     = DreamList.Name;
            txtTarget.Text   = DreamList.Target;
            txtSplit.Text    = Convert.ToString(DreamList.Splitphase);
            dTPDateCrt.Value = DreamList.DateCreated.Value;
            dTPDateEx.Value  = DreamList.DateExpired;
        }
コード例 #2
0
ファイル: EditDream.cs プロジェクト: lutuandat0411/Dreambook
        private void btnbtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int       spt       = int.Parse(txtSplit.Text);
                var       db        = new DreamDBEntities1();
                DreamList editDream = db.DreamLists.Find(DreamList.idDream);
                editDream.Name        = txtName.Text;
                editDream.Target      = txtTarget.Text;
                editDream.Splitphase  = spt;
                editDream.DateCreated = dTPDateCrt.Value.Date;
                editDream.DateExpired = dTPDateEx.Value.Date;

                db.Entry(editDream).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                this.Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private void btnbtnAdd_Click(object sender, EventArgs e)
        {
            int       sptphase = int.Parse(txtSplit.Text);
            DreamList addnew   = new DreamList();

            addnew.Name        = txtName.Text;
            addnew.Target      = txtTarget.Text;
            addnew.Splitphase  = sptphase;
            addnew.DateCreated = dateTPBegin.Value;
            addnew.DateExpired = dateTPExpired.Value;
            try
            {
                var db = new DreamDBEntities1();
                db.DreamLists.Add(addnew);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.Close();
        }