Ejemplo n.º 1
0
        private void Btnaddb_Click(object sender, EventArgs e)
        {
            string   bkname   = txtbn.Text;
            string   count    = txtcn.Text;
            string   authornm = cmbaut.Text;
            DateTime publish  = dtpd.Value;

            if (bkname != string.Empty && count != string.Empty && authornm != string.Empty && publish <= DateTime.Now)
            {
                int  autId    = db.Authors.First(ath => ath.AutName == authornm).ID;
                int  countNum = Convert.ToInt32(count);
                Book bk       = new Book();
                bk.BookName   = bkname;
                bk.Counts     = countNum;
                bk.AuthorId   = autId;
                bk.CreateDate = publish;
                db.Books.Add(bk);
                db.SaveChanges();
                MessageBox.Show("Kitab Elave Edildi");
                BookLoad();
            }
            else
            {
                lblerror.Text    = "Butun Xanalari Doldur";
                lblerror.Visible = true;
            }
        }
Ejemplo n.º 2
0
        private void Add_Click(object sender, EventArgs e)
        {
            string frstnm  = first.Text;
            string lstnm   = last.Text;
            string phone   = phon.Text;
            string faculte = fklt.Text;
            string tbno    = tno.Text;
            long   newphon;

            if (frstnm != "" && lstnm != "" && phone != "" && faculte != "")
            {
                if (long.TryParse(phone, out newphon))
                {
                    Reader rd = new Reader();
                    rd.Rnm   = frstnm;
                    rd.RSnm  = lstnm;
                    rd.Rphon = phone;
                    db.Readers.Add(rd);
                    db.SaveChanges();
                }

                else
                {
                    MessageBox.Show("Duz yaz ee Telefonu", "EROOR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Doldur", "EROOR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }