예제 #1
0
        public eTheLoai GetTheLoaiByID(int id)
        {
            eTheLoai tam  = new eTheLoai();
            TheLoai  item = tldal.Find(id);

            if (item != null)
            {
                tam.id_TheLoai   = item.id_TheLoai;
                tam.tenTheLoai   = item.tenTheLoai;
                tam.thoiGianThue = item.thoiGianThue;
                tam.giaThue      = item.giaThue;
                return(tam);
            }
            return(null);
        }
예제 #2
0
        public TheLoai find(ArrayList arrayList)
        {
            Console.WriteLine("Nhập mã hoặc tên: ");
            string  keyword = Console.ReadLine();
            TheLoai result  = null;

            foreach (TheLoai TheLoai in arrayList)
            {
                if (keyword.Equals(TheLoai.Matheloai) || keyword.Equals(TheLoai.Ten))
                {
                    result = TheLoai;
                }
            }
            return(result);
        }        //string matruyen,string tentruyen,string theloai,int giachothue,int soluongcu,int soluongmoi
예제 #3
0
        public bool Update(TheLoai obj)
        {
            var sp = context.TheLoais.SingleOrDefault(x => x.IdTheLoai == obj.IdTheLoai);

            if (sp != null)
            {
                sp.TenTheLoai = obj.TenTheLoai;
                sp.AnhTheLoai = obj.AnhTheLoai;


                context.SaveChanges();
                return(true);
            }
            return(false);
        }
예제 #4
0
 public bool InsertNTheLoai(DTO_TheLoai a)
 {
     try
     {
         TheLoai insert = new TheLoai();
         insert.Tenloai = a.TenLoai;
         db.TheLoais.InsertOnSubmit(insert);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #5
0
 public bool update(TheLoai tl)
 {
     try
     {
         var entity = db.TheLoais.Find(tl.id);
         entity.categoryName = tl.categoryName;
         entity.description  = tl.description;
         entity.minifyDate   = DateTime.Now;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #6
0
        public List <TheLoai> GetListTheLoai()
        {
            List <TheLoai> list = new List <TheLoai>();

            string query = "select * from THELOAI_View";

            DataTable data = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                TheLoai theLoai = new TheLoai(item);
                list.Add(theLoai);
            }

            return(list);
        }
예제 #7
0
        public List <TheLoai> SearchTheLoaiByName(string name)
        {
            List <TheLoai> list = new List <TheLoai>();

            string query = string.Format($"SELECT * FROM TimKiemTheLoai(N'{name}')");

            DataTable data = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                TheLoai theloai = new TheLoai(item);
                list.Add(theloai);
            }

            return(list);
        }
예제 #8
0
        //[HttpGet]
        public ActionResult Edit(int?id)
        {
            if (Session["Ad"] == null)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            else
            {
                var     kq      = db.TheLoai_SD(id).First();
                TheLoai theloai = new TheLoai();
                theloai.MaTheLoai  = kq.MaTheLoai;
                theloai.TenTheLoai = kq.TenTheLoai;

                return(View(theloai));
            }
        }
예제 #9
0
        public eTheLoai FindTheLoaiById(int id)
        {
            TheLoai t = tddal.FindTheLoaiById(id);

            if (t != null)
            {
                eTheLoai e = new eTheLoai();

                e.id_TheLoai   = t.id_TheLoai;
                e.tenTheLoai   = t.tenTheLoai;
                e.giaThue      = t.giaThue;
                e.thoiGianThue = t.thoiGianThue;
                return(e);
            }
            return(null);
        }
예제 #10
0
        public bool EditTheLoai(TheLoai item)
        {
            try
            {
                TheLoai temp = db.TheLoais.Find(item.ID);
                temp.TenTheLoai = item.TenTheLoai;
                temp.GhiChu     = item.GhiChu;

                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #11
0
 public List <TheLoai> TimKiemTheLoai(TheLoai theLoai)
 {
     using (QLThuVienEntities ThuVienDS = new QLThuVienEntities())
     {
         var listTheLoai = from r in ThuVienDS.TheLoais select r;
         if (theLoai.MaTheLoai != "none")
         {
             listTheLoai = listTheLoai.Where <TheLoai>(c => c.MaTheLoai.Contains(theLoai.MaTheLoai));
         }
         if (theLoai.TenTheLoai != "none")
         {
             listTheLoai = listTheLoai.Where <TheLoai>(c => c.TenTheLoai.Contains(theLoai.TenTheLoai));
         }
         return(listTheLoai.ToList());
     }
 }
예제 #12
0
        public bool remove(int id)
        {
            foreach (var g in db.SanPhams.Where(item => item.categoryId == id))
            {
                db.SanPhams.Attach(g);
                db.SanPhams.Remove(g);
            }
            TheLoai tl = new TheLoai()
            {
                id = id
            };

            db.TheLoais.Attach(tl);
            db.TheLoais.Remove(tl);
            db.SaveChanges();
            return(true);
        }
예제 #13
0
 public void GhiFile(ArrayList arrayList)
 {
     try
     {
         using (StreamWriter streamWriter = new StreamWriter(filepath))
         {
             foreach (TheLoai TheLoai in arrayList)
             {
                 streamWriter.WriteLine(TheLoai.ToString());
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
예제 #14
0
 public ActionResult Edit([Bind(Include = "matheloai,tentheloai")] TheLoai theLoai)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Database.SqlQuery <TheLoai>("exec sp_editTheLoai {0}, {1}", theLoai.matheloai, theLoai.tentheloai).ToList();
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (EntityCommandExecutionException ex)
     {
         return(RedirectToAction("Index"));
     }
     return(View(theLoai));
 }
예제 #15
0
        public void Sua(ArrayList arrayList)
        {
            TheLoai kq = find(arrayList);

            if (kq == null)
            {
                Console.WriteLine("Không tìm thấy");
            }
            else
            {
                Console.WriteLine("Nhập tên truyện");
                kq.Ten = Console.ReadLine();


                Console.WriteLine("Sửa thành công");
            }
        }
예제 #16
0
        public bool ThemTheLoai(TheLoai_DTO theLoai_DTO)
        {
            try
            {
                TheLoai theLoai = new TheLoai();

                theLoai.MaTheLoai  = theLoai_DTO.MaTheLoai;
                theLoai.TenTheLoai = theLoai_DTO.TenTheLoai;
                theLoai.TrangThai  = true;

                data.TheLoais.Add(theLoai);
                data.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #17
0
        public static void ThemTheLoai(TheLoai theloai)
        {
            IsSuccess = false;
            // kiểm tra dữ liệu

            // Thêm vào
            try
            {
                db.THELOAIs.Add(Convert(theloai));
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Message = "Thêm thể loại không thành công!\n" + e.Message;
                return;
            }
            Message   = "Thêm thể loại thành công!";
            IsSuccess = true;
        }
        public ActionResult Update(TheLoai obj, HttpPostedFileBase file)
        {
            try
            {
                TheLoaiDAO dao = new TheLoaiDAO();
                if (file != null && file.ContentLength > 0)
                {
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    fileName += "_" + obj.IdTheLoai;
                    fileName += Path.GetExtension(file.FileName);

                    string folderPath = Server.MapPath("~") + @"\Assets\images\genrs";

                    if (!Directory.Exists(folderPath))
                    {
                        Directory.CreateDirectory(folderPath);
                    }

                    string path = Path.Combine(folderPath, fileName);

                    file.SaveAs(path);
                    obj.AnhTheLoai = fileName;
                    if (dao.Update(obj))
                    {
                        return(RedirectToAction("Index", "TheLoai"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Error");
                        return(View(obj.IdTheLoai));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Bạn phải nhập vào trường này");
                }
            }
            catch
            {
            }
            return(View());
        }
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         TheLoaiBLL theLoaiBLL = new TheLoaiBLL();
         TheLoai    category   = new TheLoai();
         category.MaTLoai  = txtMa.Text;
         category.TenTLoai = txtTen.Text;
         category.GhiChu   = txtGhiChu.Text;
         theLoaiBLL.create(category);
         messenger.Text = theLoaiBLL.create(category);
         loadData();
         clear();
         messenger.Text = "Category Inserted !";
     }
     catch (Exception ex)
     {
         messenger.Text = ex.Message;
     }
 }
예제 #20
0
        // code lay ra TheLoai trong bang va dua vao List
        public List <TheLoai> dsTheLoai()
        {
            List <TheLoai> ds  = new List <TheLoai>();
            string         sql = "select * from TheLoai";

            con.Open();
            SqlCommand    cmd = new SqlCommand(sql, con);
            SqlDataReader rd  = cmd.ExecuteReader();

            while (rd.Read())
            {
                TheLoai tl = new TheLoai();
                tl.matheloai  = (int)rd["matheloai"];
                tl.tentheloai = (string)rd["tentheloai"];
                tl.hinhanh    = (string)rd["hinhanh"];
                ds.Add(tl);
            }
            con.Close();
            return(ds);
        }
예제 #21
0
        protected void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                TheLoai tl = new TheLoai();
                tl.tentheloai = txtten.Text;

                string path = Server.MapPath("~/images/theloai/");
                anh.PostedFile.SaveAs(path + anh.FileName);
                img.ImageUrl = "~/images/theloai/" + anh.FileName;
                tl.hinhanh   = anh.FileName;

                data.ThemTheLoai(tl);
                msg.Text = "Thêm thành công";
            }
            catch (Exception e1)
            {
                msg.Text = "Có lỗi khi thêm mới" + e1.Message;
            }
        }
예제 #22
0
        private void btSua_Click(object sender, EventArgs e)
        {
            string maTL, tenTL;

            maTL  = txtMaTL.Text;
            tenTL = txtTheLoai.Text;


            TheLoai theLoai = new TheLoai(maTL, tenTL);

            try
            {
                bool b = new TheLoaiBUS().UpdateTL(theLoai);
                Init();
                dgvTL.DataSource = new TheLoaiBUS().getTL();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Loi sua the loai sach\n" + ex.Message);
            }
        }
예제 #23
0
        public List <TheLoai> GetList()
        {
            List <TheLoai> list = new List <TheLoai>();

            string sqlQuery = "select * from TheLoai";

            reader = ExecuteReader(sqlQuery);

            while (reader.Read())
            {
                TheLoai tacGia = new TheLoai();

                tacGia.MaTheLoai  = reader["MaTheLoai"].ToString();
                tacGia.TenTheLoai = reader["TenTheLoai"].ToString();
                tacGia.GhiChu     = reader["GhiChu"].ToString();

                list.Add(tacGia);
            }

            return(list);
        }
예제 #24
0
        // lấy ra 1 thể loại
        public TheLoai layra1TL(int matl)
        {
            string sql = "select *from theloai where matheloai=@matl";

            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("matl", matl);
            SqlDataReader rd = cmd.ExecuteReader();
            TheLoai       tl = null;

            if (rd.Read())
            {
                tl            = new TheLoai();
                tl.matheloai  = (int)rd["matheloai"];
                tl.tentheloai = (string)rd["tentheloai"];
                tl.hinhanh    = (string)rd["hinhanh"];
            }
            con.Close();
            return(tl);
        }
예제 #25
0
        public bool insertTheLoai(string tenTG)
        {
            Boolean temp = true;
            TheLoai TG   = new TheLoai();

            TG.tenloaisach = tenTG;
            db.TheLoais.Add(TG);

            try
            {
                db.SaveChanges();
                db.SaveChangesAsync();
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                temp = false;
            }

            return(temp);
        }
        public List <TheLoai> AllTheLoai()
        {
            string sql = "select * from TheLoai";

            db = new DBACCESS();
            db.open();
            DataTable dt = db.getTable(sql);

            db.close();
            List <TheLoai> ds = new List <TheLoai>();

            foreach (DataRow dr in dt.Rows)
            {
                TheLoai tl = new TheLoai();
                tl.MaTheLoai  = dr[0].ToString();
                tl.TenTheLoai = dr[1].ToString();
                ds.Add(tl);
            }
            this.DanhSachTheLoai = ds;
            return(ds);
        }
예제 #27
0
        public List <TheLoai> GetTable_TL()
        {
            List <TheLoai> listTL = new List <TheLoai>();

            XuLy.conn = new SqlConnection(XuLy.strConnection);
            XuLy.conn.Open();
            string sql = "Select * from THE_LOAI";

            XuLy.cmd = new SqlCommand(sql, XuLy.conn);
            SqlDataReader dr = XuLy.cmd.ExecuteReader();

            while (dr.Read())
            {
                TheLoai tl = new TheLoai(
                    dr["MaTL"].ToString(),
                    dr["TenTL"].ToString());
                listTL.Add(tl);
            }
            dr.Close();
            XuLy.conn.Close();
            return(listTL);
        }
예제 #28
0
        private void btThem_Click(object sender, EventArgs e)
        {
            string maTL, tenTL;

            maTL  = txtMaTL.Text;
            tenTL = txtTheLoai.Text;


            TheLoai theLoai = new TheLoai(maTL, tenTL);

            try
            {
                int numerOfRows = new TheLoaiBUS().Add(theLoai);
                dgvTL.DataSource = new TheLoaiBUS().getTL();
                MessageBox.Show("Thêm thành công");
                Init();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Loi them the loai sach\n" + ex.Message);
            }
        }
예제 #29
0
 protected void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         TheLoai tl = new TheLoai();
         tl.matheloai  = int.Parse(txtma.Text);
         tl.tentheloai = txtten.Text;
         if (anh.FileName != oldAvt)
         {
             string path = Server.MapPath("~/images/theloai/");
             anh.PostedFile.SaveAs(path + anh.FileName);
             img.ImageUrl = "~/images/theloai/" + anh.FileName;
         }
         tl.hinhanh = anh.FileName;
         data.capNhatTL(tl);
         msg.Text = "Cập nhật thành công";
     }
     catch (Exception e2)
     {
         msg.Text = "Cập nhật thất bại " + e2.Message;
     }
 }
예제 #30
0
 private void btnXoaTL_Click(object sender, EventArgs e)
 {
     if (txtmaTL.Text != "")
     {
         TheLoai theloai;
         theloai = new TheLoai(txtmaTL.Text, txtTenTL.Text);
         if (tl.xoaType(theloai))
         {
             dGVTheLoai.DataSource = tl.LoadType();
             MessageBox.Show("Xóa thành công!");
         }
         else
         {
             MessageBox.Show("Xóa không thành công! Vui lòng Kiểm tra lại");
         }
         DeleteText2();
     }
     else
     {
         MessageBox.Show("Cần nhập thông tin trước khi xóa!");
     }
 }
예제 #31
0
 public bool suaTheLoai(TheLoai theLoai)
 {
     return theLoaiDAL.updateTheLoai(theLoai);
 }
예제 #32
0
 public bool themTheLoai(TheLoai theLoai)
 {
     return theLoaiDAL.insertTheLoai(theLoai);
 }
예제 #33
0
 public bool xoaTheLoai(TheLoai theLoai)
 {
     return theLoaiDAL.deleteTheLoai(theLoai);
 }