Beispiel #1
0
        private CongDan GetFromReader(SqlDataReader reader)
        {
            CongDan cd = new CongDan();

            cd.Ma              = int.Parse(reader["Ma"].ToString());
            cd.SoCmnd          = reader["SoCmnd"].ToString();
            cd.SoCccd          = reader["SoCccd"].ToString();
            cd.MaHoKhau        = reader["MaHoKhau"].ToString();
            cd.HoTen           = reader["HoTen"].ToString();
            cd.GioiTinh        = reader["GioiTinh"].ToString();
            cd.QueQuan         = reader["QueQuan"].ToString();
            cd.QuocTich        = reader["QuocTich"].ToString();
            cd.DiaChiHoKhau    = reader["DiaChiHoKhau"].ToString();
            cd.DanToc          = reader["DanToc"].ToString();
            cd.TonGiao         = reader["TonGiao"].ToString();
            cd.DacDiemNhanDang = reader["DacDiemNhanDang"].ToString();

            string NgaySinh;

            NgaySinh = reader["NgaySinh"].ToString();

            if (!string.IsNullOrEmpty(NgaySinh.Trim()))
            {
                cd.NgaySinh = DateTime.Parse(NgaySinh);
            }

            return(cd);
        }
Beispiel #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaNV.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo");
                txtMaNV.Focus();
                return;
            }
            if (txtTenNV.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên nhân viên", "Thông báo");
                txtTenNV.Focus();
                return;
            }
            if (cboMaBao.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã báo", "Thông báo");
                cboMaBao.Focus();
                return;
            }
            if (cboMaPhong.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã phòng", "Thông báo");
                cboMaPhong.Focus();
                return;
            }
            if (cboMaCV.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã chức vụ", "Thông báo");
                cboMaCV.Focus();
                return;
            }
            if (cboTrinhDo.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã trình độ", "Thông báo");
                cboTrinhDo.Focus();
                return;
            }
            if (cboMaCM.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã chuyên môn", "Thông báo");
                cboMaCM.Focus();
                return;
            }

            if (txtDiaChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo");
                txtDiaChi.Focus();
                return;
            }
            if (cboNgay.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập ngày sinh", "Thông báo");
                cboNgay.Focus();
                return;
            }
            if (cboThang.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tháng sinh ", "Thông báo");
                cboThang.Focus();
                return;
            }
            if (cboNam.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập ngày sinh", "Thông báo");
                cboNam.Focus();
                return;
            }
            if (cboGioiTinh.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập giới tính", "Thông báo");
                cboGioiTinh.Focus();
                return;
            }

            if (txtDienThoai.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo");
                txtDienThoai.Focus();
                return;
            }
            if (txtMobile.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Mobile", "Thông báo");
                txtMobile.Focus();
                return;
            }
            if (txtEmail.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Email", "Thông báo");
                txtEmail.Focus();
                return;
            }
            sql = "SELECT MaNV FROM tblNhanVien WHERE MaNV=N' " + txtMaNV.Text.Trim() + "'";
            DataTable tblNhanVien = Class.Functions.GetDataToTable(sql);

            if (tblNhanVien.Rows.Count > 0)
            {
                MessageBox.Show("Mã nhân viên này đã có, bạn phải nhập mã khác", "Thông báo");
                txtMaNV.Focus();
                txtMaNV.Text = "";
                return;
            }
            string NgaySinh;

            NgaySinh = String.Format("{0}/{1}/{2}", cboThang.Text, cboNgay.Text, cboNam.Text);


            sql = "UPDATE  tblNhanVien  SET TenNV=N'" + txtTenNV.Text.Trim()
                  + "',MaBao=N'" + cboMaBao.SelectedValue.ToString() + "',MaPhong=N'" + cboMaPhong.SelectedValue.ToString()
                  + "',MaChucVu=N'" + cboMaCV.SelectedValue.ToString() + "', MaTĐ=N'" + cboTrinhDo.SelectedValue.ToString() + "', MaCM=N'" + cboMaCM.SelectedValue.ToString() + "', DiaChi=N'" + txtDiaChi.Text.Trim() + "', NgaySinh=N'" + NgaySinh.Trim() + "', GioiTinh=N'" + cboGioiTinh.Text.Trim() + "', DienThoai=N'" + txtDienThoai.Text.Trim() + "', Mobile=N'" + txtMobile.Text.Trim() + "', Email=N'" + txtEmail.Text.Trim() + "' WHERE MaNV = N'"
                  + txtMaNV.Text + "'";
            Class.Functions.RunSql(sql);
            this.Close();
        }