Ejemplo n.º 1
0
        public List<TAPTINBAIVIET> getLichLamViec()
        {
            List<TAPTINBAIVIET> list = new List<TAPTINBAIVIET>();
            using (LinQDataContext db = new LinQDataContext(global::DAOAuction.Properties.Settings.Default.webdoantruongConnectionString))
            {

                ISingleResult<TAPTINBAIVIET_getLichLamViecResult> lp = db.TAPTINBAIVIET_getLichLamViec();
                foreach (TAPTINBAIVIET_getLichLamViecResult TAPTINBAIVIET in lp)
                {
                    TAPTINBAIVIET var1 = new TAPTINBAIVIET();
                    var1.MaTapTin = TAPTINBAIVIET.MaTapTin;
                    var1.TenTapTin = TAPTINBAIVIET.TenTapTin;
                    var1.DuongDan = TAPTINBAIVIET.DuongDan;
                    var1.MaBaiViet = TAPTINBAIVIET.MaBaiViet;

                    list.Add(var1);
                }
                try
                {
                    // Save the changes.
                    db.SubmitChanges();
                }
                // Detect concurrency conflicts.
                catch (ChangeConflictException)
                {
                    // Resolve conflicts.
                    db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
                }
            }

            return list;
        }
        protected void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                //lay thong tin tu textbox
                TAPTINBAIVIET lpDTO = new TAPTINBAIVIET();
                lpDTO.MaTapTin = int.Parse(this.txtmataptin.Text);
                lpDTO.TenTapTin = this.txttentaptin.Text;
                lpDTO.MaBaiViet = int.Parse(this.txtmabaiviet.Text);
                lpDTO.DuongDan = this.txtduongdan.Text;
                //Goi ham cap nhat
                BUSTapTinBaiViet BUSTapTinBaiViet = new BUSTapTinBaiViet();
                if (BUSTapTinBaiViet.Them(lpDTO) == 0)
                {
                    //Thong bao
                    lbThongBao.Text = "Thêm Thành Công";
                    lbThongBao.Visible = true;
                    //Response.Redirect("LoaiMatHang.aspx");
                }
                else
                {
                    lbThongBao.Text = "Thêm Không Thành Công";
                    lbThongBao.Visible = true;
                }
            }

            catch
            {
                lbThongBao.Text = "Thêm Không Thành Công";
                lbThongBao.Visible = true;
            }
        }
Ejemplo n.º 3
0
 public int CapNhat(TAPTINBAIVIET lpDTO)
 {
     try
     {
         LinQDataContext db = new LinQDataContext(global::DAOAuction.Properties.Settings.Default.webdoantruongConnectionString);
         return db.TAPTINBAIVIET_update(
             lpDTO.MaTapTin ,
             lpDTO.TenTapTin ,
             lpDTO.DuongDan ,
             lpDTO.MaBaiViet
             );
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
        void SaveFile(HttpPostedFile file)
        {
            //Duong dan den thu muc Uploads tren server
            string savePath = Server.MapPath("~/Uploads\\TapTin");

            // Ten file upload
            string fileName = FileUploadTapTin.FileName;

            // Tao duong dan de kiem tra xem file da ton tai chua
            string pathToCheck = savePath + Path.DirectorySeparatorChar+ fileName;
            string tempfileName = fileName;
            //bool overwrite = false;

            // Kiem tra xem da ton tai file co ten giong voi file nguoi dung muon up chua
            if (System.IO.File.Exists(pathToCheck))
            {

                LabelUploadStatus.Text = "Tập tin trùng với tập tin đã có trên csdl";
            }
            else
            {
                file.SaveAs(savePath+ Path.DirectorySeparatorChar +fileName);
                // Thong bao la da upload thanh cong
                TAPTINBAIVIET ttbvDTO = new TAPTINBAIVIET();
                ttbvDTO.TenTapTin = fileName;
                string linkDir = "~/Uploads/TapTin/" + fileName;
                ttbvDTO.DuongDan = linkDir;
                ttbvDTO.MaBaiViet = int.Parse(Request.QueryString["id"]);
                BUSTapTinBaiViet bus = new BUSTapTinBaiViet();
                bus.Them(ttbvDTO);
                List<TAPTINBAIVIET> gvTapTinDS = bus.TimKiemMaBaiViet(int.Parse(Request.QueryString["id"]));
               //     gvTapTinDS.Add(ttbvDTO);
                this.GridViewTapTin.DataSource = gvTapTinDS;
                this.GridViewTapTin.DataBind();
                FilterSTT(gvTapTinDS.Count, 0, 30);
                ((List<TAPTINBAIVIET>)Session["FileUploadTemp"]).Add(ttbvDTO);
                ((List<HttpPostedFile>)Session["FileClientTemp"]).Add(file);
            }
        }
Ejemplo n.º 5
0
        void SaveFile(HttpPostedFile file)
        {
            //Duong dan den thu muc Uploads tren server
            string savePath = Server.MapPath("Uploads\\");

            // Ten file upload
            string fileName = FileUploadHinhAnh.FileName;

            // Tao duong dan de kiem tra xem file da ton tai chua
            string pathToCheck = savePath + fileName;
            string tempfileName = fileName;
            bool overwrite = false;

            // Kiem tra xem da ton tai file co ten giong voi file nguoi dung muon up chua
            if (System.IO.File.Exists(pathToCheck))
            {
                int counter = 2;
                while (System.IO.File.Exists(pathToCheck))
                {
                    DialogResult result;
                    string message = "Tên file " + tempfileName + " đã tồn tại. Bạn có muốn ghi đè lên không?";
                    result = MessageBox.Show(message, "Caution", MessageBoxButtons.YesNo);
                    if (result == DialogResult.No)
                    {
                        // them (so) vao sau ten file
                        int point = fileName.LastIndexOf('.');
                        string nameNumber = "(" + counter.ToString() + ")";
                        tempfileName = fileName.Insert(point, nameNumber);
                        pathToCheck = savePath + tempfileName;
                        counter++;
                    }
                    else
                    {
                        overwrite = true;
                        LabelUploadStatus.Text = "File của bạn đã được ghi đè thành công.";
                        break;
                    }
                }

                fileName = tempfileName;
                if (counter > 2)
                    LabelUploadStatus.Text = "File của bạn đã được ghi dưới tên: " + fileName;
            }
            else
            {
                // Thong bao la da upload thanh cong
                LabelUploadStatus.Text = "File của bạn đã được ghi thành công.";
            }

            savePath += fileName;

            //Luu file
            FileUploadHinhAnh.SaveAs(savePath);

            //Duong dan de tai file
            string linkDir = "~/Uploads/" + fileName;

            //Them vao bang TapTin
            //id la tham so truyen vao url, la id cua bai viet lien quan den tap tin

            if (Request.QueryString["id"] != null)
            {
                if (overwrite == false)
                {
                    int maBaiViet = int.Parse(Request.QueryString["id"]);

                    BUSTapTinBaiViet busTapTin = new BUSTapTinBaiViet();
                    int numberTapTin = busTapTin.TimSoLuongTapTin();
                    TAPTINBAIVIET lpDTO = new TAPTINBAIVIET();
                    lpDTO.TenTapTin = fileName;
                    lpDTO.DuongDan = linkDir;
                    lpDTO.MaBaiViet = maBaiViet;
                    lpDTO.MaTapTin = numberTapTin + 1;
                    busTapTin.Them(lpDTO);
                }
                else
                {
                    int maBaiViet = int.Parse(Request.QueryString["id"]);

                    BUSTapTinBaiViet busTapTin = new BUSTapTinBaiViet();
                    TAPTINBAIVIET lpDTO = busTapTin.TimKiemTenTapTin(fileName);

                    lpDTO.MaBaiViet = maBaiViet;
                    busTapTin.CapNhat(lpDTO);
                }
            }
        }
Ejemplo n.º 6
0
 public int Them(TAPTINBAIVIET lpDTO)
 {
     try
     {
         LinQDataContext db = new LinQDataContext(global::DAOAuction.Properties.Settings.Default.webdoantruongConnectionString);
          db.TAPTINBAIVIET_add (
             lpDTO.TenTapTin ,
             lpDTO.DuongDan ,
             lpDTO.MaBaiViet
             );
          return 1;
     }
     catch
     {
         return 0;
     }
 }
Ejemplo n.º 7
0
 public int Them(TAPTINBAIVIET lpDTO)
 {
     DAOTapTinBaiViet TAPTINBAIVIET = new DAOTapTinBaiViet();
     return TAPTINBAIVIET.Them(lpDTO);
 }
Ejemplo n.º 8
0
 public int CapNhat(TAPTINBAIVIET lpDTO)
 {
     DAOTapTinBaiViet TAPTINBAIVIET = new DAOTapTinBaiViet();
     return TAPTINBAIVIET.CapNhat(lpDTO);
 }