Example #1
0
        /// <summary>
        /// Thêm hóa đơn return IDHoaDon
        /// </summary>
        /// <param name="IDBan"></param>
        /// <param name="GioVao"></param>
        /// <returns></returns>
        public static object ThemHoaDon(int IDBan, int NhanVien)
        {
            object         ID       = null;
            string         sTruyVan = string.Format(@"INSERT INTO CF_HoaDon(IDBan,GioVao,IDNhanVien) OUTPUT INSERTED.ID VALUES ('{0}',getdate(),{1})", IDBan, NhanVien);
            SqlConnection  conn     = new SqlConnection();
            DAO_ConnectSQL connect  = new DAO_ConnectSQL();

            conn = connect.Connect();
            SqlCommand cm = new SqlCommand(sTruyVan, conn);

            ID = cm.ExecuteScalar();
            return(ID);
        }
Example #2
0
        public static object ThemMoiHoaDon(int IDBan, int NhanVien, DateTime GioVao, string IDChiNhanh)
        {
            object         ID       = null;
            string         sTruyVan = string.Format(@"INSERT INTO CF_HoaDon(IDBan,GioVao,IDNhanVien,GioRa,NgayBan,IDChiNhanh) OUTPUT INSERTED.ID VALUES ('{0}','{1}',{2},getdate(),getdate(),'{3}')", IDBan, GioVao.ToString("yyyy-MM-dd hh:mm:ss tt"), NhanVien, IDChiNhanh);
            SqlConnection  conn     = new SqlConnection();
            DAO_ConnectSQL connect  = new DAO_ConnectSQL();

            conn = connect.Connect();
            SqlCommand cm = new SqlCommand(sTruyVan, conn);

            ID = cm.ExecuteScalar();
            return(ID);
        }
 // Thực hiện truy vấn không trả về dữ liệu
 /// <summary>
 /// insert,update,delete
 /// </summary>
 /// <param name="sTruyVan"></param>
 /// <returns></returns>
 public static bool TruyVanKhongLayDuLieu(string sTruyVan)
 {
     try
     {
         SqlConnection  conn    = new SqlConnection();
         DAO_ConnectSQL connect = new DAO_ConnectSQL();
         conn = connect.Connect();
         SqlCommand cm = new SqlCommand(sTruyVan, conn);
         cm.ExecuteNonQuery();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        // Thực hiện truy vấn trả về bảng dữ liệu
        /// <summary>
        /// Datatable
        /// </summary>
        /// <param name="sTruyVan"></param>
        /// <returns></returns>
        public static DataTable TruyVanLayDuLieu(string sTruyVan)
        {
            SqlConnection  conn    = new SqlConnection();
            DAO_ConnectSQL connect = new DAO_ConnectSQL();

            conn = connect.Connect();
            if (conn == null)
            {
                return(null);
            }
            SqlDataAdapter da = new SqlDataAdapter(sTruyVan, conn);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            return(dt);
        }