public bool CapNhatHangHoa(HangHoa_DTO hh)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "UPDATE HANGHOA SET Ten = @Ten, Dongia = @Dongia, Soluong = @Soluong WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters.Add("@Ten", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Soluong", SqlDbType.Int);

            cmd.Parameters["@Id"].Value      = hh.Id;
            cmd.Parameters["@Ten"].Value     = hh.Ten;
            cmd.Parameters["@Dongia"].Value  = hh.Dongia;
            cmd.Parameters["@Soluong"].Value = hh.Soluong;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
Exemple #2
0
        public static bool CapNhatMon(Mon_DTO mon)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "UPDATE MON SET Tenmon = @Tenmon, Dongia = @Dongia, Loai = @Loai WHERE Mamon = @Mamon";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Mamon", SqlDbType.VarChar, 10);
            cmd.Parameters.Add("@Tenmon", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Loai", SqlDbType.VarChar, 10);

            cmd.Parameters["@Mamon"].Value  = mon.Mamon;
            cmd.Parameters["@Tenmon"].Value = mon.Tenmon;
            cmd.Parameters["@Dongia"].Value = mon.Dongia;
            cmd.Parameters["@Loai"].Value   = mon.Loai;

            cnn.Open();
            int count = cmd.ExecuteNonQuery();

            if (count < 1)
            {
                return(false);
            }
            cnn.Close();
            return(true);
        }
Exemple #3
0
        public bool CapNhatTiec(Tiec_DTO tiec)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "UPDATE TIEC SET Ngaytochuc = @Ngaytochuc, Gia = @Gia WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters.Add("@Ngaytochuc", SqlDbType.DateTime);
            cmd.Parameters.Add("@Gia", SqlDbType.Float);

            cmd.Parameters["@Id"].Value         = tiec.Id;
            cmd.Parameters["@Ngaytochuc"].Value = tiec.Ngaytochuc;
            cmd.Parameters["@Gia"].Value        = tiec.Gia;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
Exemple #4
0
        public static DataTable LoadDSMon()
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Mamon, Tenmon, Dongia, Loai FROM MON";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #5
0
        public static DataTable LoadDSNhanVien()
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Manhanvien, Tennhanvien, Ngaysinh, Gioitinh, CMND, Diachi, Sdt, Email, Luong, Tenloainhanvien FROM NHANVIEN, LOAINHANVIEN WHERE IdLoainhanvien = Loainhanvien";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #6
0
        public DataTable LoadDSLuong()
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Tennhanvien, Tenloainhanvien, Chisoluong FROM NHANVIEN, LOAINHANVIEN WHERE IdLoainhanvien = Loainhanvien";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #7
0
        public static DataTable DSMaLoaiMon()
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Maloaimon FROM LOAIMON";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
        public DataTable LoadDSLoaiNV()
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT Tenloainhanvien FROM LOAINHANVIEN";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #9
0
        public DataTable LoadTiec()
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT * FROM TIEC";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new System.Data.DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #10
0
        public static DataTable LoadDSMonTheoLoai(string tenloai)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Tenmon, Dongia FROM MON WHERE Loai = @Loai";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Loai", SqlDbType.NVarChar, 50);
            cmd.Parameters["@Loai"].Value = tenloai;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #11
0
        public static DataTable TimKiemTheoGioiTinh(string gioitinh)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Manhanvien, Tennhanvien, Ngaysinh, Gioitinh, CMND, Diachi, Sdt, Email, Luong FROM NHANVIEN WHERE Gioitinh = @Gioitinh";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar, 4);
            cmd.Parameters["@Gioitinh"].Value = gioitinh;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #12
0
        public static DataTable TimKiemTheoChucVu(string chucvu)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "SELECT Manhanvien, Tennhanvien, Ngaysinh, Gioitinh, CMND, Diachi, Sdt, Email, Luong FROM NHANVIEN, LOAINHANVIEN WHERE IdLoainhanvien = Loainhanvien AND Tenloainhanvien = @Chucvu";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Chucvu", SqlDbType.NChar, 10);
            cmd.Parameters["@Chucvu"].Value = chucvu;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
        public DataTable LoadDS(DateTime ngay)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT * FROM BAOCAOTHU WHERE Ngay = @Ngay";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Ngay", SqlDbType.DateTime);
            cmd.Parameters["@Ngay"].Value = ngay;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
Exemple #14
0
        public static bool ThemMon(Mon_DTO mon)
        {
            SqlConnection kt   = ConnectToSQL.HamKetNoi();
            string        sql  = "SELECT Mamon FROM MON WHERE Mamon = @Mamon";
            SqlCommand    cmd1 = new SqlCommand(sql, kt);

            cmd1.CommandType = CommandType.Text;
            cmd1.Parameters.Add("@Mamon", SqlDbType.VarChar, 10);
            cmd1.Parameters["@Mamon"].Value = mon.Mamon;

            kt.Open();
            SqlDataReader reader = cmd1.ExecuteReader();
            int           count  = 0;

            if (reader.Read())
            {
                count++;
                string s = reader.GetString(0);
            }
            reader.Close();
            if (count == 1)
            {
                //MessageBox.Show("Sinh vien da ton tai!");
                return(false);
            }


            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "INSERT INTO MON(Mamon, Tenmon, Dongia, Loai) VALUES (@Mamon, @Tenmon, @Dongia, @Loai)";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Mamon", SqlDbType.VarChar, 10);
            cmd.Parameters.Add("@Tenmon", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Loai", SqlDbType.VarChar, 10);

            cmd.Parameters["@Mamon"].Value  = mon.Mamon;
            cmd.Parameters["@Tenmon"].Value = mon.Tenmon;
            cmd.Parameters["@Dongia"].Value = mon.Dongia;
            cmd.Parameters["@Loai"].Value   = mon.Loai;

            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();

            return(true);
        }
Exemple #15
0
        public static DataTable LoadCTHDTheoMHD(int mahoadon)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            //string str = "SELECT tenmon, soluong FROM CT_HD";
            string     str = @"SELECT Tenmon, Dongia, Soluong FROM CTHD WHERE mahoadon = @Mahoadon";
            SqlCommand cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Mahoadon", SqlDbType.Int);
            cmd.Parameters["@Mahoadon"].Value = mahoadon;
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataTable      dtb = new DataTable();

            da.Fill(dtb);
            return(dtb);
        }
        public bool ThemHangHoa(HangHoa_DTO hh)
        {
            //kiem tra
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT Id FROM HANGHOA WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters["@Id"].Value = hh.Id;

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            int           count  = 0;

            if (reader.Read())
            {
                count++;
                string s = reader.GetString(0);
            }
            reader.Close();
            if (count == 1)
            {
                return(false);
            }

            SqlConnection conn1 = ConnectToSQL.HamKetNoi();
            string        str1  = "INSERT INTO HANGHOA(Id, Ten, Dongia, Soluong) VALUES (@Id, @Ten, @Dongia, @Soluong)";
            SqlCommand    cmd1  = new SqlCommand(str1, conn);

            cmd1.CommandType = CommandType.Text;

            cmd1.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd1.Parameters.Add("@Ten", SqlDbType.NVarChar, 50);
            cmd1.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd1.Parameters.Add("@Soluong", SqlDbType.Int);

            cmd1.Parameters["@Id"].Value      = hh.Id;
            cmd1.Parameters["@Ten"].Value     = hh.Ten;
            cmd1.Parameters["@Dongia"].Value  = hh.Dongia;
            cmd1.Parameters["@Soluong"].Value = hh.Soluong;

            conn1.Open();
            cmd1.ExecuteNonQuery();
            conn1.Close();
            return(true);
        }
Exemple #17
0
        public bool ThemTiec(Tiec_DTO tiec)
        {
            //kiem tra
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT Id FROM TIEC WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters["@Id"].Value = tiec.Id;

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            int           count  = 0;

            if (reader.Read())
            {
                count++;
                string s = reader.GetString(0);
            }
            reader.Close();
            if (count == 1)
            {
                return(false);
            }

            SqlConnection conn1 = ConnectToSQL.HamKetNoi();
            string        str1  = "INSERT INTO TIEC(Id, Ngaytochuc, Gia) VALUES (@Id, @Ngaytochuc, @Gia)";
            SqlCommand    cmd1  = new SqlCommand(str1, conn);

            cmd1.CommandType = CommandType.Text;

            cmd1.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd1.Parameters.Add("@Ngaytochuc", SqlDbType.DateTime);
            cmd1.Parameters.Add("@Gia", SqlDbType.Float);

            cmd1.Parameters["@Id"].Value         = tiec.Id;
            cmd1.Parameters["@Ngaytochuc"].Value = tiec.Ngaytochuc;
            cmd1.Parameters["@Gia"].Value        = tiec.Gia;

            conn1.Open();
            cmd1.ExecuteNonQuery();
            conn1.Close();
            return(true);
        }
Exemple #18
0
 public DataTable LoadCTHDTheoIDTiec(string Id)
 {
     try
     {
         SqlConnection cnn = ConnectToSQL.HamKetNoi();
         //string str = "SELECT tenmon, soluong FROM CT_HD";
         string     str = @"SELECT Mon, Dongia, Soluong FROM CTTIEC WHERE IDTiec = @IDTiec";
         SqlCommand cmd = new SqlCommand(str, cnn);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add("@IDTiec", SqlDbType.NChar, 10);
         cmd.Parameters["@IDTiec"].Value = Id;
         SqlDataAdapter da  = new SqlDataAdapter(cmd);
         DataTable      dtb = new DataTable();
         da.Fill(dtb);
         return(dtb);
     }
     catch { return(null); }
 }
Exemple #19
0
        public static void ThemHoaDon(HoaDon_DTO hd)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = @"INSERT INTO HOADON(Ban, Tongtien) VALUES (@Ban, @Tongtien)";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Ban", SqlDbType.Int);
            cmd.Parameters.Add("@Tongtien", SqlDbType.Float);

            cmd.Parameters["@Ban"].Value      = hd.Ban;
            cmd.Parameters["@Tongtien"].Value = hd.Tongtien;

            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Exemple #20
0
        public static string CoutDS()
        {
            int           t   = 0;
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = @"SELECT COUNT(*) FROM HOADON";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;

            cnn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                t = reader.GetInt32(0);
            }
            reader.Close();
            return(t.ToString());
        }
Exemple #21
0
        public string LayTenTheoMa(string manhanvien)
        {
            string        t   = "";
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = @"SELECT Tennhanvien FROM NHANVIEN WHERE Manhanvien = @Manhanvien";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Manhanvien", SqlDbType.NChar, 10);
            cmd.Parameters["@Manhanvien"].Value = manhanvien;
            cnn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                t = reader.GetString(0);
            }
            reader.Close();
            return(t);
        }
        public string TimIdTheoTen(string ten)
        {
            string        t    = "";
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT IdLoainhanvien FROM LOAINHANVIEN WHERE Tenloainhanvien = @Tenloainhanvien";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Tenloainhanvien", SqlDbType.NVarChar, 50);
            cmd.Parameters["@Tenloainhanvien"].Value = ten;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                t = reader.GetString(0);
            }
            reader.Close();
            return(t);
        }
Exemple #23
0
        public bool XoaTiec(Tiec_DTO tiec)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "DELETE FROM TIEC WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Id", System.Data.SqlDbType.NChar, 10);
            cmd.Parameters["@Id"].Value = tiec.Id;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
        public bool ThemBaoCao(Baocaothu_DTO bc)
        {
            SqlConnection conn1 = ConnectToSQL.HamKetNoi();
            string        str1  = "INSERT INTO BAOCAOTHU(Ngay, Loai, Tien) VALUES (@Ngay, @Loai, @Tien)";
            SqlCommand    cmd1  = new SqlCommand(str1, conn1);

            cmd1.CommandType = CommandType.Text;

            cmd1.Parameters.Add("@Ngay", SqlDbType.DateTime);
            cmd1.Parameters.Add("@Loai", SqlDbType.NVarChar, 50);
            cmd1.Parameters.Add("@Tien", SqlDbType.Float);

            cmd1.Parameters["@Ngay"].Value = bc.Ngay;
            cmd1.Parameters["@Loai"].Value = bc.Loai;
            cmd1.Parameters["@Tien"].Value = bc.Tien;

            conn1.Open();
            cmd1.ExecuteNonQuery();
            conn1.Close();
            return(true);
        }
Exemple #25
0
        public static bool XoaLoaiMon(LoaiMon_DTO loai)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "DELETE FROM LOAIMON WHERE Maloaimon = @Maloaimon";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Maloaimon", SqlDbType.VarChar, 10);

            cmd.Parameters["@Maloaimon"].Value = loai.Maloai;

            cnn.Open();
            int count = cmd.ExecuteNonQuery();

            if (count < 1)
            {
                return(false);
            }
            cnn.Close();
            return(true);
        }
Exemple #26
0
        public static bool XoaNhanVien(NhanVien_DTO nv)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "DELETE FROM NHANVIEN WHERE Manhanvien = @Manhanvien";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Manhanvien", SqlDbType.VarChar, 10);

            cmd.Parameters["@Manhanvien"].Value = nv.Manhanvien;

            cnn.Open();
            int count = cmd.ExecuteNonQuery();

            if (count < 1)
            {
                return(false);
            }
            cnn.Close();
            return(true);
        }
Exemple #27
0
        public static bool CapNhatNhanVien(NhanVien_DTO nv)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = "UPDATE NHANVIEN SET Manhanvien = @Manhanvien, Tennhanvien = @Tennhanvien, Ngaysinh = @Ngaysinh, Gioitinh = @Gioitinh, CMND = @CMND, Diachi = @Diachi, Sdt = @Sdt, Email = @Email, Luong = @Luong WHERE Manhanvien = @Manhanvien";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Manhanvien", SqlDbType.VarChar, 10);
            cmd.Parameters.Add("@Tennhanvien", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Ngaysinh", SqlDbType.Date);
            cmd.Parameters.Add("@Gioitinh", SqlDbType.NVarChar, 4);
            cmd.Parameters.Add("@CMND", SqlDbType.VarChar, 10);
            cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@Sdt", SqlDbType.VarChar, 10);
            cmd.Parameters.Add("@Email", SqlDbType.VarChar, 50);
            cmd.Parameters.Add("@Luong", SqlDbType.Float);

            cmd.Parameters["@Manhanvien"].Value  = nv.Manhanvien;
            cmd.Parameters["@Tennhanvien"].Value = nv.Tennhanvien;
            cmd.Parameters["@Ngaysinh"].Value    = nv.Ngaysinh;
            cmd.Parameters["@Gioitinh"].Value    = nv.Gioitinh;
            cmd.Parameters["@CMND"].Value        = nv.Cmnd;
            cmd.Parameters["@Diachi"].Value      = nv.Diachi;
            cmd.Parameters["@Sdt"].Value         = nv.Sdt;
            cmd.Parameters["@Email"].Value       = nv.Email;
            cmd.Parameters["@Luong"].Value       = nv.Luong;

            cnn.Open();
            int count = cmd.ExecuteNonQuery();

            if (count < 1)
            {
                return(false);
            }
            cnn.Close();
            return(true);
        }
Exemple #28
0
        public bool CapNhatTongTien(string id, float tongtien)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "UPDATE TIEC SET Gia = @Gia WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters.Add("@Gia", SqlDbType.Float);

            cmd.Parameters["@Id"].Value  = id;
            cmd.Parameters["@Gia"].Value = tongtien;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
Exemple #29
0
        public bool ThemCTTiec(CTTiec_DTO cttiec)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = @"INSERT INTO CTTIEC(IDTiec, Mon, Dongia, Soluong) VALUES (@IDTiec, @Mon, @Dongia, @Soluong)";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@IDTiec", SqlDbType.NChar, 10);
            cmd.Parameters.Add("@Mon", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Soluong", SqlDbType.Int);


            cmd.Parameters["@IDTiec"].Value  = cttiec.Id;
            cmd.Parameters["@Mon"].Value     = cttiec.Mon;
            cmd.Parameters["@Dongia"].Value  = cttiec.Dongia;
            cmd.Parameters["@Soluong"].Value = cttiec.Soluong;

            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();

            return(true);
        }
Exemple #30
0
        public static bool ThemCTHD(CTHD_DTO cthd)
        {
            SqlConnection cnn = ConnectToSQL.HamKetNoi();
            string        str = @"INSERT INTO CTHD(Mahoadon, Tenmon, Dongia, Soluong) VALUES (@Mahoadon, @Tenmon, @Dongia, @Soluong)";
            SqlCommand    cmd = new SqlCommand(str, cnn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Mahoadon", SqlDbType.Int);
            cmd.Parameters.Add("@Tenmon", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Soluong", SqlDbType.Int);


            cmd.Parameters["@Mahoadon"].Value = cthd.Mahoadon;
            cmd.Parameters["@Tenmon"].Value   = cthd.Tenmon;
            cmd.Parameters["@Dongia"].Value   = cthd.Dongia;
            cmd.Parameters["@Soluong"].Value  = cthd.Soluong;

            cnn.Open();
            cmd.ExecuteNonQuery();
            cnn.Close();

            return(true);
        }