Exemplo n.º 1
0
 public bool ThemQuanHe(QuanHeInfo qh)
 {
     try
     {
         SqlCommand s = new SqlCommand("INSERT INTO QUANHE(MAQUANHE,TENQUANHE) values(" + qh.MaQuanHe.ToString() + ",N'" + qh.TenQuanHe + "')");
         ser.Load(s);
         return(true);
     }
     catch (Exception e)
     {
         e.ToString();
         return(false);;
     }
 }
Exemplo n.º 2
0
 public bool CapNhatQuanHe(QuanHeInfo qh)
 {
     try
     {
         SqlCommand s = new SqlCommand("UPDATE QUANHE SET TENQUANHE = N'" + qh.TenQuanHe + "' WHERE MAQUANHE=" + qh.MaQuanHe);
         ser.Load(s);
         return(true);
     }
     catch (Exception e)
     {
         e.ToString();
         return(false);;
     }
 }
Exemplo n.º 3
0
 public bool XoaQuanHe(QuanHeInfo qh)
 {
     try
     {
         SqlCommand s = new SqlCommand("DELETE QUANHE where MAQUANHE=" + qh.MaQuanHe.ToString());
         ser.Load(s);
         return(true);
     }
     catch (Exception e)
     {
         e.ToString();
         return(false);;
     }
 }
Exemplo n.º 4
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!boolThem)//Chua chon
            {
                btnThem.Text = "Lưu";
                QLKTX.Controller.QuanHeCtrl qh = new QuanHeCtrl();
                txtMa.Text     = qh.LayMaMax().ToString();
                txtTen.Enabled = true;

                btnSua.Enabled = false;
                btnXoa.Enabled = false;

                btnKetThuc.Text = "Bỏ qua";
                txtTen.Text     = "";
                txtTen.Focus();
                boolThem = true;
            }
            else
            {
                if (txtTen.Text == "")
                {
                    MessageBox.Show("Nhập Tên! Nhâp lại", "Luu", MessageBoxButtons.OK);
                    txtTen.Focus();
                }
                else
                {
                    //Goi ham cap nhat
                    QuanHeInfo qh = new QuanHeInfo();
                    qh.MaQuanHe  = Convert.ToInt32(txtMa.Text);
                    qh.TenQuanHe = txtTen.Text;

                    //Lưu
                    ctrl.ThemQuanHe(qh);
                    boolThem = false;
                    ctrl.DataTableToListView(listQuanHe);


                    btnThem.Text    = "Thêm";
                    btnSua.Enabled  = true;
                    btnXoa.Enabled  = true;
                    btnKetThuc.Text = "Kết thúc";
                    boolThem        = false;
                }
            }
        }
        /// <summary>
        /// Thêm một thân nhân
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnThemThanNhan_Click(object sender, EventArgs e)
        {
            if (txtHoTenThanNhan.Text != "" && txtHoTenThanNhan != null)
            {
                ListViewItem row = new ListViewItem();
                row.Text = Convert.ToString(listDSThanNhan.Items.Count + 1);
                row.SubItems.Add(txtHoTenThanNhan.Text.ToString());
                row.SubItems.Add(cmbQuanHeThanNhan.Text);
                row.SubItems.Add(cmbNgheNghiepThanNhan.Text);


                ThanNhanInfo thannhan = new ThanNhanInfo();


                thannhan.MaThanNhan = listDSThanNhan.Items.Count + 1;
                SinhVienInfo sv = new SinhVienInfo();
                sv.MaKTX = txtMaKTX.Text;
                sv.HoTen = txtHoTen.Text;

                thannhan.SinhVien      = sv;
                thannhan.HoTenThanNhan = row.SubItems[1].Text;
                QuanHeInfo qh = new QuanHeInfo();
                qh.MaQuanHe     = (int)cmbQuanHeThanNhan.SelectedValue;
                qh.TenQuanHe    = row.SubItems[2].Text;
                thannhan.QuanHe = qh;

                NgheNghiepInfo nn = new NgheNghiepInfo();
                nn.MaNgheNghiep     = Convert.ToInt32(cmbNgheNghiepThanNhan.SelectedValue);
                nn.TenNgheNghep     = cmbNgheNghiepThanNhan.Text;
                thannhan.NgheNghiep = nn;

                row.Tag = thannhan;

                listDSThanNhan.Items.Add(row);
                //
                txtHoTenThanNhan.Text               = "";
                cmbQuanHeThanNhan.SelectedIndex     = 0;
                cmbNgheNghiepThanNhan.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("Chưa nhập đủ thông tin của Thân nhân", "Thân nhân", MessageBoxButtons.OK);
            }
        }
Exemplo n.º 6
0
        public void DataTableToListView(ListViewEx list)
        {
            list.Items.Clear();
            DataTable table = data.DSQuanHe();

            foreach (DataRow r in table.Rows)
            {
                ListViewItem item = new ListViewItem();
                item.Text = r["MAQUANHE"].ToString();
                item.SubItems.Add(r["TENQUANHE"].ToString());

                QuanHeInfo qh = new QuanHeInfo();
                qh.MaQuanHe  = Convert.ToInt32(r["MAQUANHE"]);
                qh.TenQuanHe = r["TENQUANHE"].ToString();
                item.Tag     = qh;

                list.Items.Add(item);
            }
        }
Exemplo n.º 7
0
        public bool SuaQuanHe(QuanHeInfo qh)
        {
            QuanHeData qhdt = new QuanHeData();

            return(qhdt.CapNhatQuanHe(qh));
        }
Exemplo n.º 8
0
        public bool XoaQuanHe(QuanHeInfo qh)
        {
            QuanHeData qhdt = new QuanHeData();

            return(qhdt.XoaQuanHe(qh));
        }
Exemplo n.º 9
0
        public bool ThemQuanHe(QuanHeInfo qh)
        {
            QuanHeData qhdt = new QuanHeData();

            return(qhdt.ThemQuanHe(qh));
        }