예제 #1
0
        public static int GenerateReport()
        {
            int            amount            = 0;
            List <SachDTO> listOfCurrentBook = SachDAO.GetAllData();

            foreach (SachDTO item in listOfCurrentBook)
            {
                int number = int.Parse(item.LuongTon);
                amount += number;
            }
            string querry = @"INSERT INTO BaoCaoSachTon(NgayLap, SoLuong) VALUES ('" + DateTime.Now.Date + "'," + amount.ToString() + ")";
            int    result = DataProvider.ExecuteNonQuerry(querry);

            querry = @"SELECT IDENT_CURRENT('BaoCaoSachTon') AS Id";
            string id = DataProvider.ExecuteQuerry(querry).Rows[0]["Id"].ToString();

            if (result == 0)
            {
                return(0);
            }
            else
            {
                foreach (SachDTO item in listOfCurrentBook)
                {
                    querry = @"INSERT INTO Sach_BaoCao(Sach, BaoCao) VALUES (" + item.Id + "," + id + ")";
                    result = DataProvider.ExecuteNonQuerry(querry);
                }
            }
            return(result);
        }
        public static int updateDeb(CongNoDTO deb)
        {
            string querry = @"UPDATE CongNo SET NoDau=" + deb.NoDau + ", NoCuoi=" + deb.NoCuoi + ", PhatSinh=" + deb.PhatSinh + "WHERE Id=" + deb.Id;
            int    result = DataProvider.ExecuteNonQuerry(querry);

            return(result);
        }
        public static int AddBill(HoaDonDTO bill)
        {
            string querry1 = @"INSERT INTO HoaDon (Ngay, ThanhTien, SoTienThanhToan) VALUES
('" + bill.Ngay + "', '" + bill.ThanhTien + "', '" + bill.SoTienThanhToan + "')";
            int    result  = DataProvider.ExecuteNonQuerry(querry1);

            if (result <= 0)
            {
                return(0);
            }
            string querry2 = @"SELECT IDENT_CURRENT('HoaDon') AS Id";
            string id      = DataProvider.ExecuteQuerry(querry2).Rows[0]["Id"].ToString();

            foreach (SachDTO item in bill.Sach)
            {
                string querry = @"INSERT INTO Sach_HoaDon (SoLuong, HoaDon, Sach) VALUES (" + item.LuongTon + "," + id +
                                "," + item.Id + ")";
                int res = DataProvider.ExecuteNonQuerry(querry);
                if (result <= 0)
                {
                    return(0);
                }
            }
            return(1);
        }
        public static string addDeb(CongNoDTO deb)
        {
            string querry = @"INSERT INTO CongNo (NoDau, NoCuoi, PhatSinh) VALUES (" + deb.NoDau + ", " + deb.NoCuoi +
                            ", " + deb.PhatSinh + ")";
            int result = DataProvider.ExecuteNonQuerry(querry);

            querry = @"SELECT IDENT_CURRENT('CongNo') AS Id";
            string id = DataProvider.ExecuteQuerry(querry).Rows[0]["Id"].ToString();

            return(id);
        }