Exemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            int gioitinh;

            if (rdbNam.Checked == true)
            {
                gioitinh = 1;
            }
            else
            {
                gioitinh = 0;
            }
            int ret = nvc.Insert(
                new NhanVien()
            {
                Ten         = txtTen.Text,
                Ngaysinh    = dtpNgaySinh.Value,
                Gioitinh    = gioitinh,
                Anh         = anh,
                Diachi      = txtDiaChi.Text,
                Dantoc      = txtDanToc.Text,
                Tongiao     = txtTonGiao.Text,
                Sodienthoai = txtSDT.Text,
                Socmt       = txtCMND.Text,
                Tinhtrang   = "Tốt",
                MaPB        = checkData(cmbPhongBan.Text, lstNamePB),
                MaCV        = checkData(cmbChucVu.Text, lstNameCV),
                MaTDHV      = 1,
                Ngoaingu    = txtNgoaiNgu.Text,
                MaHD        = 1,
                MaSBH       = 1,
                MaKT        = 1,
                MaKL        = 1,
                MaL         = 1,
                Ghichu      = "ABC"
            });

            if (ret == 1)
            {
                MessageBox.Show("Thêm nhân viên thành công!", "Success!");
                this.Close();
            }
            else
            {
                MessageBox.Show("Thêm không thành công.Xin kiểm tra lại!", "Failed!");
            }
        }
Exemplo n.º 2
0
        //public static bool SaveBooks(BookInfo row)
        //{
        //    var dataBook = Controller.GetByPublisherPublishYear(row["Publisher"].ToString(), (short)row["PublishYear"]);
        //    DataRow rowBook;
        //    if (dataBook.Rows.Count == 0)
        //    {
        //        if (!Controller.Insert(new BookInfo
        //        {
        //            BookTitleId = (int)row["BookTitleId"],
        //            Publisher = row["Publisher"].ToString(),
        //            PublishYear = short.Parse(row["PublishYear"].ToString()),
        //            Count = (int)row["Count"],
        //            Price = (decimal)row["Price"]
        //        })) return null;

        //        rowBook = Controller.GetByLast();
        //    }
        //    else
        //    {
        //        rowBook = dataBook.Rows[0];
        //    }

        //    var n = (int)row["Count"];
        //    for (int i = 0; i < n; i++)
        //    {
        //        if (!TomeService.Insert(new TomeInfo()
        //        {
        //            BookId = (int)rowBook["Id"],
        //            Status = 1
        //        })) return null;
        //    }

        //    return rowBook;
        //}
        public static bool Insert(NhanVien nhanVien)
        {
            return(Controller.Insert(nhanVien));
        }