Ejemplo n.º 1
0
        public int ThemDocGia(TheDocGia_DTO dto)
        {
            ThemDocGiaDAO nvd = new ThemDocGiaDAO();
            int           k   = nvd.ThemDocGia(dto);

            return(k);
        }
Ejemplo n.º 2
0
        private void btn_them_Click(object sender, EventArgs e)
        {
            ThemDocGiaBUS nvbus = new ThemDocGiaBUS();
            TheDocGia_DTO dtonv = new TheDocGia_DTO();

            dtonv.Hoten      = txt_hoTen.Text;
            dtonv.Tennv      = txt_nguoiLap.Text;
            dtonv.Ngaysinh   = dtngaysinh.Text;
            dtonv.Diachi     = txt_diaChi.Text;
            dtonv.Email      = txt_email.Text;
            dtonv.Ngaylapthe = dtngaylap.Text;
            dtonv.Maloai     = Int32.Parse(cbbloaidocgia.SelectedItem.ToString());

            int k = nvbus.ThemDocGia(dtonv);

            if (k > 0)
            {
                MessageBox.Show("Bạn đã thêm thành công");
            }
            else
            {
                MessageBox.Show("Không thể thêm nhân viên");
            }
            fr_TheDocGia_Load(sender, e);
        }
Ejemplo n.º 3
0
        public bool UpDate(TheDocGia_DTO thedocgia)
        {
            // thuoc tinh ma thu thu khong duoc cap nhap lai
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                SqlCommand cmd;
                string     sqlQuyery1 = " select count(*) from  THEDOCGIA  where MaThe = N'" + thedocgia.MaThe + "'";
                cmd = new SqlCommand(sqlQuyery1, con);
                var i = cmd.ExecuteScalar();
                if (int.Parse(i.ToString()) == 0)
                {
                    return(false);
                }
                else
                {
                    string sqlQuery = @"Update THEDOCGIA  set MaDocGia = N'" + thedocgia.MaDocGia + "', NgayLamThe  =N'" + thedocgia.NgayLamThe
                                      + "', HanThe = N'" + thedocgia.HanThe + "', LoaiThe = N'" + thedocgia.LoaiThe
                                      + "' where MaThe = N'" + thedocgia.MaThe + "'";

                    cmd = new SqlCommand(sqlQuery, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
 public bool KiemTra(TheDocGia_DTO thedocgia)
 {
     if (thedocgia.MaThe == "" || thedocgia.MaDocGia == "" || thedocgia.NgayLamThe == "" || thedocgia.HanThe == "" || thedocgia.LoaiThe == "")
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
        public frm_PhieuDocGia()
        {
            InitializeComponent();
            thedocgiaBUS = new TheDocGia_BUS();
            thedocgiaDTO = new TheDocGia_DTO();
            qd           = new QuyDinh1_BUS();
            DataTable table = qd.Select();
            var       i     = table.Rows[0].ItemArray;

            dtNgayLamThe.Text = DateTime.Now.ToShortDateString();
            dthanThe.Text     = DateTime.Now.AddMonths(int.Parse(i[2].ToString())).ToShortDateString();
            KhoiTaoCmbTiemKiem();
            KhoiTaoCmbLoaiThe();
        }
Ejemplo n.º 6
0
 public bool Delete(TheDocGia_DTO thedocgia)
 {
     try
     {
         if (con.State == ConnectionState.Closed)
         {
             con.Open();
         }
         string     sqlQuery = "delete from THEDOCGIA where MaThe= '" + thedocgia.MaThe + "'";
         SqlCommand cmd      = new SqlCommand(sqlQuery, con);
         cmd.ExecuteNonQuery();
         con.Close();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
        public bool Insert(TheDocGia_DTO thedocgia)
        {
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                string sqlQuery = @"INSERT INTO THEDOCGIA(MaThe, MaDocGia, LoaiThe, NgayLamThe, HanThe ) 
                VALUES (N'" + thedocgia.MaThe + "', N'" + thedocgia.MaDocGia + "', N'" + thedocgia.LoaiThe + "'" +
                                  ",N'" + thedocgia.NgayLamThe + "',N'" + thedocgia.HanThe + "')";

                // thuc hien insert
                SqlCommand cmd = new SqlCommand(sqlQuery, con);
                cmd.ExecuteNonQuery();
                con.Close();
                return(true); // them thanh cong
            }
            catch
            {
                return(false); // them that bai;
            }
        }
Ejemplo n.º 8
0
        public int ThemDocGia(TheDocGia_DTO dtonv)
        {
            int                 k         = -1;
            SqlConnection       connect   = new SqlConnection();
            SqlConnectionString constring = new SqlConnectionString();

            connect = SqlConnectionString.HamKetNoi();
            connect.Open();
            SqlCommand cmd = new SqlCommand("sp_themdocgia", connect);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@hoten", SqlDbType.NVarChar);
            cmd.Parameters.Add("@tennv", SqlDbType.NVarChar);
            cmd.Parameters.Add("@ngaysinh", SqlDbType.DateTime);
            cmd.Parameters.Add("@diachi", SqlDbType.NVarChar);
            cmd.Parameters.Add("@email", SqlDbType.NChar);
            cmd.Parameters.Add("@ngaylapthe", SqlDbType.DateTime);
            cmd.Parameters.Add("@maloai", SqlDbType.Int);

            cmd.Parameters["@hoten"].Value      = dtonv.Hoten;
            cmd.Parameters["@tennv"].Value      = dtonv.Tennv;
            cmd.Parameters["@ngaysinh"].Value   = dtonv.Ngaysinh;
            cmd.Parameters["@diachi"].Value     = dtonv.Diachi;
            cmd.Parameters["@email"].Value      = dtonv.Email;
            cmd.Parameters["@ngaylapthe"].Value = dtonv.Ngaylapthe;
            cmd.Parameters["@maloai"].Value     = dtonv.Maloai;

            k = cmd.ExecuteNonQuery();
            connect.Close();
            if (k > 0)
            {
                return(k);
            }

            return(0);
        }
Ejemplo n.º 9
0
 public bool Delete(TheDocGia_DTO thedocgia)
 {
     return(TDG.Delete(thedocgia));
 }
Ejemplo n.º 10
0
 public bool UpDate(TheDocGia_DTO thedocgia)
 {
     return(TDG.UpDate(thedocgia));
 }
Ejemplo n.º 11
0
 public bool Insert(TheDocGia_DTO thedocgia)
 {
     return(TDG.Insert(thedocgia));
 }