Esempio n. 1
0
        // Hien thi ten Nha Cung Cap
        public List <ThongKe> HienThiTenNhaCungCap()
        {
            try
            {
                OpenConnection();
                List <ThongKe> tklist     = new List <ThongKe>();
                SqlCommand     sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = "SELECT DISTINCT TENCC FROM dbo.NHACC";
                sqlCommand.Connection  = conn;

                SqlDataReader sqlReader = sqlCommand.ExecuteReader();

                DataTable dt = new DataTable();
                dt.Load(sqlReader);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ThongKe tk = new ThongKe();
                    tk.TenCc = dt.Rows[i][0].ToString();

                    tklist.Add(tk);
                }
                sqlReader.Close();
                return(tklist);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Esempio n. 2
0
        public bool UpdateTongSldTonKho(ThongKe tk)
        {
            try
            {
                bool isCheck = false;
                OpenConnection();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_UPDATE_TONKHO";
                sqlCommand.Connection  = conn;

                sqlCommand.Parameters.Add("@MASP", SqlDbType.Int).Value    = tk.MaSp;
                sqlCommand.Parameters.Add("@TONGSLD", SqlDbType.Int).Value = tk.Sld;

                int result = sqlCommand.ExecuteNonQuery();

                if (result > 0)
                {
                    isCheck = true;
                }

                return(isCheck);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Esempio n. 3
0
        // Tinh Tong So Don Dat Hang Theo Ma San Pham
        public DataTable TonSldhTheoMaSp(ThongKe tk)
        {
            try
            {
                OpenConnection();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_ThongKeTongSoDoDhTheoMaSp";
                sqlCommand.Connection  = conn;

                sqlCommand.Parameters.Add("@Masp", SqlDbType.Int).Value = tk.MaSp;

                SqlDataAdapter sqlData = new SqlDataAdapter(sqlCommand);
                DataTable      dt      = new DataTable();
                sqlData.Fill(dt);

                return(dt);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Esempio n. 4
0
        // Thong Ke Phieu Xuat Theo Ngay Thang
        public List <ThongKe> ThongKePhieuXuatTheoNgayThang(ThongKe tk)
        {
            try
            {
                OpenConnection();
                List <ThongKe> tklist = new List <ThongKe>();

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_ThongKePhieuXuatTtheoNgayThang";
                sqlCommand.Connection  = conn;

                sqlCommand.Parameters.Add("@DateTimesOne", SqlDbType.DateTime).Value = tk.DateOne;
                sqlCommand.Parameters.Add("@DateTimesTwo", SqlDbType.DateTime).Value = tk.DateTwo;

                SqlDataReader sqlReader = sqlCommand.ExecuteReader();
                DataTable     dt        = new DataTable();

                dt.Load(sqlReader);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ThongKe tks = new ThongKe();
                    tks.MaSp      = int.Parse(dt.Rows[i][0].ToString());
                    tks.TenSp     = dt.Rows[i][1].ToString();
                    tks.TenLoai   = dt.Rows[i][2].ToString();
                    tks.TenSx     = dt.Rows[i][3].ToString();
                    tks.TenKh     = dt.Rows[i][4].ToString();
                    tks.Slx       = int.Parse(dt.Rows[i][5].ToString());
                    tks.TongTien  = double.Parse(dt.Rows[i][6].ToString());
                    tks.PhanTram  = float.Parse(dt.Rows[i][7].ToString());
                    tks.ThanhTien = double.Parse(dt.Rows[i][8].ToString());

                    tklist.Add(tks);
                }

                sqlReader.Close();
                return(tklist);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Esempio n. 5
0
        // THong KE phieu Nhap Theo Loai San Pham
        public List <ThongKe> ThongKePhieuNhapLoaiSp(ThongKe tk)
        {
            try
            {
                OpenConnection();
                List <ThongKe> tklist = new List <ThongKe>();

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_ThongKePhieuNhapTheoLoaiSp";
                sqlCommand.Connection  = conn;

                sqlCommand.Parameters.Add("@LoaiSp", SqlDbType.NVarChar).Value = tk.TenLoai;

                SqlDataReader sqlReader = sqlCommand.ExecuteReader();
                DataTable     dt        = new DataTable();

                dt.Load(sqlReader);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ThongKe tks = new ThongKe();
                    tks.MaSp      = int.Parse(dt.Rows[i][0].ToString());
                    tks.TenSp     = dt.Rows[i][1].ToString();
                    tks.TenLoai   = dt.Rows[i][2].ToString();
                    tks.TenSx     = dt.Rows[i][3].ToString();
                    tks.Sld       = int.Parse(dt.Rows[i][4].ToString());
                    tks.Sln       = int.Parse(dt.Rows[i][5].ToString());
                    tks.Slcl      = int.Parse(dt.Rows[i][6].ToString());
                    tks.DonGia    = double.Parse(dt.Rows[i][7].ToString());
                    tks.ThanhTien = double.Parse(dt.Rows[i][8].ToString());

                    tklist.Add(tks);
                }

                sqlReader.Close();
                return(tklist);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Esempio n. 6
0
        public List <ThongKe> ThongKeDonDatHang()
        {
            try
            {
                OpenConnection();
                List <ThongKe> tklist = new List <ThongKe>();

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "sp_ThongKeDonDatHang";
                sqlCommand.Connection  = conn;

                SqlDataReader sqlReader = sqlCommand.ExecuteReader();
                DataTable     dt        = new DataTable();

                dt.Load(sqlReader);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ThongKe tk = new ThongKe();
                    tk.MaSp    = int.Parse(dt.Rows[i][0].ToString());
                    tk.TenSp   = dt.Rows[i][1].ToString();
                    tk.TenLoai = dt.Rows[i][2].ToString();
                    tk.TenSx   = dt.Rows[i][3].ToString();
                    tk.Sld     = int.Parse(dt.Rows[i][4].ToString());


                    tklist.Add(tk);
                }

                sqlReader.Close();
                return(tklist);
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }