public List <QuangCaoThichHop> GetDates(int nam, int thang, string goi)
        {
            List <QuangCaoThichHop> lst   = new List <QuangCaoThichHop>();
            GoiQuangCao             goiqc = new GoiQuangCao();

            goiqc = context.GoiQuangCao.Where(gh => gh.Id == Guid.Parse(goi)).SingleOrDefault();
            SqlConnection con = new SqlConnection("Server=.;Database=QLBanGiay;Integrated Security=True;");
            var           cmd = new SqlCommand("select day from [dbo].[ngaythichhop](@thang,@nam,@goi)", con);

            con.Open();
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("thang", thang);
            cmd.Parameters.AddWithValue("nam", nam);
            cmd.Parameters.AddWithValue("goi", goiqc.Id);
            var       da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            da.Fill(dt);
            foreach (DataRow row in dt.Rows)
            {
                QuangCaoThichHop qcth = new QuangCaoThichHop();
                qcth.day = Convert.ToInt32(row["day"]);
                lst.Add(qcth);
            }
            con.Close();

            // Info.
            return(lst);
        }
        public string GetTenViTri(string goi)
        {
            GoiQuangCao goiqc = new GoiQuangCao();

            goiqc = context.GoiQuangCao.Where(gh => gh.Id == Guid.Parse(goi)).Include(gh => gh.IdViTriNavigation).SingleOrDefault();
            return(goiqc.IdViTriNavigation.TenViTri);
        }
Exemple #3
0
        public string CreateGoiQuangCao(string ma, string vitriquangcao, double tongtien, int thoiluong)
        {
            GoiQuangCao   goi;
            ViTriQuangcao vitri;

            //Kiểm tra
            //Tên đăng nhập
            goi = context.GoiQuangCao.Where(gh => gh.MaGoiQuangCao == ma).SingleOrDefault();
            if (goi != null)
            {
                return("Gói đã tồn tại");
            }
            //Thêm
            goi               = new GoiQuangCao();
            goi.Id            = Guid.Parse(Guid.NewGuid().ToString().ToUpper());
            goi.MaGoiQuangCao = ma;

            goi.IdViTri = Guid.Parse(vitriquangcao);

            goi.TongTien  = tongtien;
            goi.ThoiLuong = thoiluong;
            goi.TinhTrang = "Không khoá";

            context.GoiQuangCao.Add(goi);
            context.SaveChanges();
            return("Thêm thành công");
        }
        public int GetThoiLuong(string goi)
        {
            GoiQuangCao goiqc = new GoiQuangCao();

            goiqc = context.GoiQuangCao.Where(gh => gh.Id == Guid.Parse(goi)).SingleOrDefault();

            return(Convert.ToInt32(goiqc.ThoiLuong));
        }
Exemple #5
0
        public string LockGoiQuangCao(string ma)
        {
            GoiQuangCao goi = context.GoiQuangCao.Where(gh => gh.MaGoiQuangCao == ma).SingleOrDefault();

            goi.TinhTrang = "Khoá";
            context.SaveChanges();
            return("Khoá thành công");
        }
Exemple #6
0
        public string CheckMa(string ma)
        {
            GoiQuangCao goi = new GoiQuangCao();

            goi = context.GoiQuangCao.Where(gh => gh.MaGoiQuangCao == ma).SingleOrDefault();
            if (goi == null)
            {
                return(null);
            }
            return(goi.MaGoiQuangCao);
        }
Exemple #7
0
        public string EditGoiQuangCao(string ma, string vitriquangcao, double tongtien, int thoiluong)
        {
            GoiQuangCao goi = new GoiQuangCao();

            //Sửa
            goi = context.GoiQuangCao.Where(gh => gh.MaGoiQuangCao == ma).SingleOrDefault();

            goi.IdViTri   = Guid.Parse(vitriquangcao);
            goi.TongTien  = tongtien;
            goi.ThoiLuong = thoiluong;
            context.SaveChanges();
            return("Sửa thành công");
        }