예제 #1
0
        public void Update(string ID, string Ten, string GioiTinh, string Email, string SDT, string DiaChi, string ChucVu, long Luong)
        {
            sqlQuery = "update NHANVIEN set ID = N'" + ID + "', HoTen = N'" + Ten + "', GioiTinh = N'" +
                       GioiTinh + "', Email= N'" + Email + "', SoDT =" + SDT + ", DiaChi = N'" + DiaChi + "', ChucVu=N'" + ChucVu + "', " +
                       "Luong = CAST(" + Luong + "AS Money)" + "where ID ='" + ID + "'";
            string str = "update NHANVIEN set ID = N'" + ID + "', HoTen = N'" + Ten + "', GioiTinh = N'" +
                         GioiTinh + "', Email= N'" + Email + "', SoDT =" + SDT + ", DiaChi = N'" + DiaChi + "', ChucVu=N'" + ChucVu + "', " +
                         "Luong = CAST(" + Luong + "AS Money)" + "where ID ='" + ID + "'";


            conString.ConString constring = new conString.ConString();
            try
            {
                using (var con = new SqlConnection(constring.initString()))
                {
                    using (var cmd = new SqlCommand(sqlQuery, con))
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
            }
            catch (SqlException ex)
            {
            }
        }
예제 #2
0
 public void Delete(string ID)
 {
     sqlQuery = "delete from Member where ma ='" + ID + "'";
     conString.ConString constring = new conString.ConString();    //this will hide the database info ... sort of
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
 }
예제 #3
0
 public void Delete(Class.LichTrucPT lichTrucPT)
 {
     sqlQuery = "delete from PTSchedule where ID = N'" + lichTrucPT.ID + "' and HoTen = N'" + lichTrucPT.HoTen + "' and Thu = " + lichTrucPT.Thu + " and Buoi =" + lichTrucPT.Buoi;
     conString.ConString constring = new conString.ConString();    //this will hide the database info ... sort of
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
 }
예제 #4
0
 public void Insert(Class.LichTrucPT lichTrucPT)
 {
     sqlQuery = "insert into PTSchedule (ID,HoTen,Thu,Buoi) values (N'" + lichTrucPT.ID + "',N'" + lichTrucPT.HoTen + "'," + lichTrucPT.Thu + "," + lichTrucPT.Buoi + ")";
     conString.ConString constring = new conString.ConString();
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
 }
예제 #5
0
 public void Update(Class.hoiVien hoiVien)
 {
     sqlQuery = "update Member set ma = N'" + hoiVien.ma.Trim() + "', ten = N'" + hoiVien.ten + "', tuoi = '" +
                hoiVien.tuoi + "', gioiTinh= N'" + hoiVien.gioiTinh + "', soDT =" + hoiVien.sdt + ", ngayThamGia = '" + hoiVien.ngayThamGia.ToString("MM/dd/yyyy") + "' where ma=N'" + hoiVien.ma.Trim() + "'";
     conString.ConString constring = new conString.ConString();
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
 }
예제 #6
0
 public void FullInsert(Class.hoiVien hoiVien)
 {
     sqlQuery = "insert into Member (ma, ten,tuoi, gioiTinh,soDT, ngayThamGia, ngayKetThuc) values ('" + hoiVien.ma + "',N'" +
                hoiVien.ten + "','" + hoiVien.tuoi.ToString() + "',N'" + hoiVien.gioiTinh + "','" + hoiVien.sdt + "','" + hoiVien.ngayThamGia.ToString("MM/dd/yyyy") + "','" + hoiVien.ngayTKetThuc.ToString("MM/dd/yyyy") + "')";
     conString.ConString constring = new conString.ConString();
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
 }
예제 #7
0
 public DataTable GetData(string str)
 {
     conString.ConString constring = new conString.ConString();    //this will hide the database info ... sort of
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(str, con))
             {
                 con.Open();
                 SqlDataAdapter da = new SqlDataAdapter(cmd);
                 // this will query your database and return the result to your datatable
                 da.Fill(result);
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
     return(result);
 }
예제 #8
0
 public void Insert(string ID, string Ten, string GioiTinh, string Email, string SDT, string DiaChi, string ChucVu, long Luong)
 {
     sqlQuery = "insert into NHANVIEN (ID,HoTen, GioiTinh, Email, SoDT, DiaChi,ChucVu,Luong) values (N'" + ID + "',N'" +
                Ten + "',N'" + GioiTinh + "',N'" + Email + "'," + SDT + ",N'" + DiaChi + "',N'" + ChucVu + "',CAST(" + Luong + "AS Money))";
     conString.ConString constring = new conString.ConString();
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #9
0
 public DataTable getStaffDetailInfo(string ma)
 {
     sqlQuery = "select ID,HoTen from NHANVIEN " +
                " where ID = '" + ma + "' ";
     conString.ConString constring = new conString.ConString();    //this will hide the database info ... sort of
     try
     {
         using (var con = new SqlConnection(constring.initString()))
         {
             using (var cmd = new SqlCommand(sqlQuery, con))
             {
                 con.Open();
                 SqlDataAdapter da = new SqlDataAdapter(cmd);
                 // this will query your database and return the result to your datatable
                 da.Fill(result);
                 con.Close();
             }
         }
     }
     catch (SqlException ex)
     {
     }
     return(result);
 }