Ejemplo n.º 1
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string thumuc = "~/images/news";
         if (!Directory.Exists(thumuc))
         {
             Directory.CreateDirectory(Server.MapPath(thumuc));
         }
         if (FileUpload1.HasFile)
         {
             if (XLDL.CheckFileType(FileUpload1.FileName))
             {
                 string tenhinh = "~/images/news/" + DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;
                 FileUpload1.SaveAs(Server.MapPath(tenhinh));
             }
         }
         string hinh = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;
         XLDL.Chaylenh("insert into tintuc(tieude,tomtat,hinh,url,ngaydang) values(N'" + txtTieuDe.Text.Trim() + "',N'" + txtTomTat.Text.Trim() + "','" + hinh + "','" + txtLink.Text.Trim() + "','" + DateTime.Today.ToShortDateString() + "')");
         Response.Redirect("~/viewtintuc.aspx");
     }
     catch
     {
         Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
     }
 }
Ejemplo n.º 2
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        int bit = 0;

        foreach (DataListItem item in dlHinh.Items)
        {
            int      id     = int.Parse(dlHinh.DataKeys[item.ItemIndex].ToString());
            CheckBox cbHinh = (CheckBox)item.FindControl("cbHinh");
            if (cbHinh.Checked == true)
            {
                bit = 1;
            }
            else
            {
                bit = 0;
            }
            XLDL.Chaylenh("update bannerhome set hien=" + bit + " where id=" + id);
        }
        string             tenhinh        = "~/images/home/banner/";
        HttpFileCollection fileCollection = Request.Files;

        for (int i = 0; i < fileCollection.Count; i++)
        {
            HttpPostedFile uploadfile = fileCollection[i];
            string         fileName   = Path.GetFileName(uploadfile.FileName);
            if (uploadfile.ContentLength > 0)
            {
                string hinh = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fileName;
                uploadfile.SaveAs(Server.MapPath(tenhinh) + hinh);
                XLDL.Chaylenh("insert into bannerhome(hinh) values('" + hinh + "')");
            }
        }
        slide();
    }
Ejemplo n.º 3
0
    protected void dtMota_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        TextBox   txtTen = (TextBox)e.Item.FindControl("txtTen");
        TextBox   txtQuocGia = (TextBox)e.Item.FindControl("txtQuocGia");
        TextBox   txtMota = (TextBox)e.Item.FindControl("txtMota");
        string    oldurl = "", newurl = "";
        DataTable dt = XLDL.LayDuLieu("select tencty from congty where macty=" + int.Parse(Request.QueryString["macty"].ToString()));

        if (dt.Rows.Count > 0)
        {
            oldurl = "~/images/" + dt.Rows[0][0];
        }
        try
        {
            XLDL.Chaylenh("update congty set tencty=N'" + txtTen.Text.Trim() + "',quocgia=N'" + txtQuocGia.Text.Trim() + "',mota=N'" + txtMota.Text.Trim() + "' where macty = " + Request.QueryString["macty"]);
            newurl = "~/images/" + txtTen.Text.Trim();
            if (Directory.Exists(Server.MapPath(oldurl)) && txtTen.Text.Trim() != dt.Rows[0][0].ToString())
            {
                Directory.Move(Server.MapPath(oldurl), Server.MapPath(newurl));
            }
            Response.Redirect("~/congty.aspx");
        }
        catch
        {
            Response.Write("<script>alert('Lỗi trong quá trình ghi dữ liệu, vui lòng thử lại sau')</script>");
        }
    }
Ejemplo n.º 4
0
    protected void dlBinhLuan_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Label      Label35 = (Label)e.Item.FindControl("Label35");
        LinkButton lThich  = (LinkButton)e.Item.FindControl("lThich");
        string     sl      = Label35.Text.Trim();

        if (e.CommandName == "Thich")
        {
            string chuoi;
            if (Session["TenDN"] != null)
            {
                DataTable dt = XLDL.LayDuLieu("select maKH from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'");
                string[]  a  = sl.Split(',');
                if (sl.Contains(dt.Rows[0][0].ToString()) == false)
                {
                    chuoi = dt.Rows[0][0].ToString();
                }
                else
                {
                    chuoi = "";
                }
                if (a.Length > 1)
                {
                    for (int i = 0; i < a.Length; i++)
                    {
                        if (a[i] == dt.Rows[0][0].ToString())
                        {
                            continue;
                        }
                        if (chuoi == "")
                        {
                            chuoi = a[i];
                            continue;
                        }
                        chuoi = chuoi + "," + a[i];
                    }
                }
                else
                {
                    if (a[0] != "")
                    {
                        if (chuoi != "")
                        {
                            chuoi = chuoi + "," + a[0];
                        }
                        else
                        {
                            chuoi = "";
                        }
                    }
                }
                XLDL.Chaylenh("update binhluan set thich='" + chuoi + "' where ID=" + (int)dlBinhLuan.DataKeys[e.Item.ItemIndex]);
            }
            binhluan();
            CreateBanner();
        }
    }
Ejemplo n.º 5
0
    protected void dlAdmin_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int id = int.Parse(dlAdmin.DataKeys[e.Item.ItemIndex].ToString());

        try
        {
            XLDL.Chaylenh("delete admin where id=" + id);
            admin();
        }
        catch { }
    }
Ejemplo n.º 6
0
    protected void dlThongSo_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        try
        {
            string  masp       = dlThongSo.DataKeys[e.Item.ItemIndex].ToString();
            TextBox txtManHinh = (TextBox)e.Item.FindControl("txtManHinh");
            TextBox txtCPU     = (TextBox)e.Item.FindControl("txtCPU");
            TextBox txtRam1    = (TextBox)e.Item.FindControl("txtRam1");
            TextBox txtRom     = (TextBox)e.Item.FindControl("txtRom");
            TextBox txtHdh1    = (TextBox)e.Item.FindControl("txtHdh1");
            TextBox txtCamera  = (TextBox)e.Item.FindControl("txtCamera");
            TextBox txtSelfie  = (TextBox)e.Item.FindControl("txtSelfie");
            TextBox txtPin1    = (TextBox)e.Item.FindControl("txtPin1");
            XLDL.Chaylenh("update thongso set manhinh=N'" + txtManHinh.Text.Trim() + "',cpu=N'" + txtCPU.Text.Trim() + "',ram1=N'" + txtRam1.Text.Trim() + "',rom=N'" + txtRom.Text.Trim() + "',hdh1=N'" + txtHdh1.Text.Trim() + "',camera=N'" + txtCamera.Text.Trim() + "',selfie=N'" + txtSelfie.Text.Trim() + "',pin1=N'" + txtPin1.Text.Trim() + "' where masp='" + masp + "'");

            TextBox txtCNMH            = (TextBox)e.Item.FindControl("txtCNMH");
            TextBox txtDoPhanGiai      = (TextBox)e.Item.FindControl("txtDoPhanGiai");
            TextBox txtMHRong          = (TextBox)e.Item.FindControl("txtMHRong");
            TextBox txtCamUng          = (TextBox)e.Item.FindControl("txtCamUng");
            TextBox txtDoPhanGiaiSau   = (TextBox)e.Item.FindControl("txtDoPhanGiaiSau");
            TextBox txtQuayPhimSau     = (TextBox)e.Item.FindControl("txtQuayPhimSau");
            TextBox txtFlash           = (TextBox)e.Item.FindControl("txtFlash");
            TextBox txtChupAnhNangCao  = (TextBox)e.Item.FindControl("txtChupAnhNangCao");
            TextBox txtDoPhanGiaiTruoc = (TextBox)e.Item.FindControl("txtDoPhanGiaiTruoc");
            TextBox txtVideoCall       = (TextBox)e.Item.FindControl("txtVideoCall");
            TextBox txtThongTinKhac    = (TextBox)e.Item.FindControl("txtThongTinKhac");
            TextBox txtHdh             = (TextBox)e.Item.FindControl("txtHdh");
            TextBox txtChipset         = (TextBox)e.Item.FindControl("txtChipset");
            TextBox txtTocDoCPU        = (TextBox)e.Item.FindControl("txtTocDoCPU");
            TextBox txtGpu             = (TextBox)e.Item.FindControl("txtGpu");
            TextBox txtRam             = (TextBox)e.Item.FindControl("txtRam");
            TextBox txtBoNhoTrong      = (TextBox)e.Item.FindControl("txtBoNhoTrong");
            TextBox txtTheNho          = (TextBox)e.Item.FindControl("txtTheNho");
            TextBox txtSim             = (TextBox)e.Item.FindControl("txtSim");
            TextBox txtSac             = (TextBox)e.Item.FindControl("txtSac");
            TextBox txtTainghe         = (TextBox)e.Item.FindControl("txtTainghe");
            TextBox txtThietKe         = (TextBox)e.Item.FindControl("txtThietKe");
            TextBox txtChatLieu        = (TextBox)e.Item.FindControl("txtChatLieu");
            TextBox txtKichThuoc       = (TextBox)e.Item.FindControl("txtKichThuoc");
            TextBox txtTrongLuong      = (TextBox)e.Item.FindControl("txtTrongLuong");
            TextBox txtPin             = (TextBox)e.Item.FindControl("txtPin");
            TextBox txtLoaiPin         = (TextBox)e.Item.FindControl("txtLoaiPin");
            TextBox txtCNPin           = (TextBox)e.Item.FindControl("txtCNPin");
            TextBox txtThoiDiem        = (TextBox)e.Item.FindControl("txtThoiDiem");
            XLDL.Chaylenh("update thongsochitiet set cnmanhinh=N'" + txtCNMH.Text.Trim() + "',dophangiaimh=N'" + txtDoPhanGiai.Text.Trim() + "',mhrong=N'" + txtMHRong.Text.Trim() + "',camung=N'" + txtCamUng.Text.Trim() + "',dophangiaicamsau=N'" + txtDoPhanGiaiSau.Text.Trim() + "',quayphimsau=N'" + txtQuayPhimSau.Text.Trim() + "',denflash=N'" + txtFlash.Text.Trim() + "',chupanhnangcao=N'" + txtChupAnhNangCao.Text.Trim() + "',dophangiaicamtruoc=N'" + txtDoPhanGiaiTruoc.Text.Trim() + "',videocall=N'" + txtVideoCall.Text.Trim() + "',thongtinkhac=N'" + txtThongTinKhac.Text.Trim() + "',hdh=N'" + txtHdh.Text.Trim() + "',chipset=N'" + txtChipset.Text.Trim() + "',tocdocpu=N'" + txtTocDoCPU.Text.Trim() + "',gpu=N'" + txtGpu.Text.Trim() + "',ram=N'" + txtRam.Text.Trim() + "',bonhotrong=N'" + txtBoNhoTrong.Text.Trim() + "',thenho=N'" + txtTheNho.Text.Trim() + "',sim=N'" + txtSim.Text.Trim() + "',sac=N'" + txtSac.Text.Trim() + "',tainghe=N'" + txtTainghe.Text.Trim() + "',chatlieu=N'" + txtChatLieu.Text.Trim() + "',kichthuoc=N'" + txtKichThuoc.Text.Trim() + "',trongluong=N'" + txtTrongLuong.Text.Trim() + "',pin=N'" + txtPin.Text.Trim() + "',loaipin=N'" + txtLoaiPin.Text.Trim() + "',congnghepin=N'" + txtCNPin.Text.Trim() + "',thoidiemramat=N'" + txtThoiDiem.Text.Trim() + "' where masp='" + masp + "'");

            thongso();
            alert.Visible = true;
        }
        catch
        {
            error.Visible = true;
        }
    }
Ejemplo n.º 7
0
 protected void dlKhuyenMai_DeleteCommand(object source, DataListCommandEventArgs e)
 {
     try
     {
         int ID = int.Parse(dlKhuyenMai.DataKeys[e.Item.ItemIndex].ToString());
         XLDL.Chaylenh("delete from khuyenmaisp where id=" + ID);
         Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         XLDL.Chaylenh("insert into admin(HoTen,DiaChi,sdt,email,TenDN,MatKhau) values(N'" + txtHoTen.Text.Trim() + "',N'" + txtDiaChi.Text.Trim() + "','" + txtSDT.Text.Trim() + "','" + txtEmail.Text.Trim() + "','" + XLDL.MaHoa(txtTenDN.Text.ToLower().Trim()) + "','" + XLDL.MaHoa(txtMatKhau.Text.Trim()) + "')");
         Response.Redirect("~/quantrivien.aspx");
     }
     catch
     {
         lbThongbaoloi.Text = "Tên đăng nhập đã tồn tại, vui lòng thử lại với tên khác !";
     }
 }
Ejemplo n.º 9
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         XLDL.Chaylenh("update danhgia set danhgia=N'" + CKEditor1.Text + "' where masp='" + Request.QueryString["MaSP"] + "'");
         danhgia();
         alert.Visible = true;
     }
     catch
     {
         error.Visible = true;
     }
 }
Ejemplo n.º 10
0
 protected void dlTongQuat_UpdateCommand(object source, DataListCommandEventArgs e)
 {
     try
     {
         string       masp       = dlTongQuat.DataKeys[e.Item.ItemIndex].ToString();
         TextBox      txtTenSP   = (TextBox)e.Item.FindControl("txtTenSP");
         DropDownList ddlHangSX  = (DropDownList)e.Item.FindControl("ddlHangSX");
         TextBox      txtGiaBan  = (TextBox)e.Item.FindControl("txtGiaBan");
         CheckBox     cbTraGop   = (CheckBox)e.Item.FindControl("cbTraGop");
         TextBox      txtGiamGia = (TextBox)e.Item.FindControl("txtGiamGia");
         TextBox      txtSLTon   = (TextBox)e.Item.FindControl("txtSLTon");
         FileUpload   fuHinh     = (FileUpload)e.Item.FindControl("fuHinh");
         int          tragop     = 0;
         double       giamgia    = 0;
         if (cbTraGop.Checked == true)
         {
             tragop = 1;
         }
         int       macty = 1;
         DataTable dt    = XLDL.LayDuLieu("select macty from congty where tencty='" + ddlHangSX.SelectedItem + "'");
         if (dt.Rows.Count > 0)
         {
             macty = int.Parse(dt.Rows[0][0].ToString());
         }
         if (txtGiamGia.Text.Trim() != "")
         {
             giamgia = double.Parse(txtGiamGia.Text.Trim());
         }
         if (fuHinh.HasFile)
         {
             if (XLDL.CheckFileType(fuHinh.FileName))
             {
                 string tenhinh = "~/images/home/" + DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fuHinh.FileName;
                 fuHinh.SaveAs(Server.MapPath(tenhinh));
                 XLDL.Chaylenh("update dienthoai set tensp=N'" + txtTenSP.Text.Trim() + "',giaban=" + double.Parse(txtGiaBan.Text.Trim()) + ",hinhanh='" + fuHinh.FileName + "',macty=" + macty + ",tragop=" + tragop + ",giamgia=" + giamgia + " where masp='" + masp + "'");
             }
         }
         else
         {
             XLDL.Chaylenh("update dienthoai set tensp=N'" + txtTenSP.Text.Trim() + "',giaban=" + double.Parse(txtGiaBan.Text.Trim()) + ",macty=" + macty + ",tragop=" + tragop + ",giamgia=" + giamgia + " where masp='" + masp + "'");
         }
         XLDL.Chaylenh("update kho set soluongton=" + int.Parse(txtSLTon.Text.Trim()) + " where masp='" + masp + "'");
         tongquat();
         alert.Visible = true;
     }
     catch
     {
         error.Visible = true;
     }
 }
Ejemplo n.º 11
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     foreach (DataListItem item in dlDonHang.Items)
     {
         int      sodh = int.Parse(dlDonHang.DataKeys[item.ItemIndex].ToString());
         CheckBox cb   = (CheckBox)item.FindControl("CheckBox1");
         int      bit  = 0;
         if (cb.Checked)
         {
             bit = 1;
         }
         XLDL.Chaylenh("update donhang set dagiao=" + bit + " where sodh=" + sodh);
     }
     donhang();
 }
Ejemplo n.º 12
0
    protected void dlTinTuc_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int id = int.Parse(dlTinTuc.DataKeys[e.Item.ItemIndex].ToString());

        try
        {
            XLDL.Chaylenh("delete from tintuc where id=" + id);
            Response.Write("<script>alert('Xóa tin tức thành công')</script>");
            tintuc();
        }
        catch
        {
            Response.Write("<script>alert('Lỗi ! Không thể xóa tin tức')</script>");
        }
    }
Ejemplo n.º 13
0
    protected void dlBinhLuan_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int id = int.Parse(dlBinhLuan.DataKeys[e.Item.ItemIndex].ToString());

        try
        {
            XLDL.Chaylenh("delete from binhluan where id=" + id);
            binhluan();
            slbl();
            CreateBanner();
        }
        catch
        {
            Response.Write("<script>alert('Không thể xóa bình luận')</script>");
        }
    }
Ejemplo n.º 14
0
 protected void dlHinh_DeleteCommand(object source, DataListCommandEventArgs e)
 {
     try
     {
         int       ID      = int.Parse(dlHinh.DataKeys[e.Item.ItemIndex].ToString());
         DataTable dt      = XLDL.LayDuLieu("select tencty,dienthoai.masp,hinh from bannersp,dienthoai,congty where bannersp.masp=dienthoai.masp and dienthoai.macty=congty.macty and id=" + ID);
         string    tenhinh = "~/images/" + dt.Rows[0][0].ToString() + "/" + dt.Rows[0][1].ToString() + "/" + dt.Rows[0][2].ToString();
         if (File.Exists(Server.MapPath(tenhinh)) == true)
         {
             File.Delete(Server.MapPath(tenhinh));
         }
         XLDL.Chaylenh("delete from bannersp where id=" + ID);
         Hinh();
     }
     catch { }
 }
Ejemplo n.º 15
0
 protected void LuuThanhToan()
 {
     try
     {
         int           makh = int.Parse(XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0].ToString());
         SqlConnection con  = new SqlConnection(XLDL.strcon);
         SqlCommand    cmd  = new SqlCommand("insert into donhang(makh,ngaydh,tennguoinhan,diachinhan,sdtnhan,thanhtoan) values(" + makh + ",@ngaydh,N'" + txtTen.Text.Trim() + "',N'" + txtDiaChi.Text.Trim() + "','" + txtSDT.Text.Trim() + "'," + thanhtoan + ")", con);
         con.Open();
         cmd.Parameters.Add("@ngaydh", SqlDbType.DateTime);
         cmd.Parameters["@ngaydh"].Value = DateTime.Now;
         cmd.ExecuteNonQuery();
         con.Close();
         int       sodh = int.Parse(XLDL.LayDuLieu("select max(sodh) from donhang where makh=" + XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0]).Rows[0][0].ToString());
         DataTable dt   = (DataTable)Session["Giohang"];
         string    Masp;
         int       soluong;
         double    dongia, giamgia;
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             Masp    = XLDL.LayDuLieu("select masp from dienthoai where tensp='" + dt.Rows[i]["TenSP"].ToString().Trim() + "'").Rows[0][0].ToString();
             soluong = int.Parse(dt.Rows[i]["SoLuong"].ToString());
             dongia  = double.Parse(dt.Rows[i]["GiaBan"].ToString());
             if (dt.Rows[i]["GiamGia"].ToString() != "")
             {
                 giamgia = double.Parse(dt.Rows[i]["GiamGia"].ToString());
             }
             else
             {
                 giamgia = 0;
             }
             if (i == dt.Rows.Count - 1)
             {
                 mota += soluong.ToString() + " x " + dt.Rows[i]["TenSP"].ToString().Trim();
             }
             else
             {
                 mota += soluong.ToString() + "x" + dt.Rows[i]["TenSP"].ToString().Trim() + ", ";
             }
             XLDL.Chaylenh("insert into ctdonhang(sodh,masp,soluong,dongia,giamgia) values(" + sodh + ",'" + Masp + "'," + soluong + "," + dongia + "," + giamgia + ")");
         }
     }
     catch
     {
         Response.Write("<script>alert('Không thể đặt đơn hàng này')</script>");
     }
 }
Ejemplo n.º 16
0
    protected void dlDienThoai_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        string    masp = dlDienThoai.DataKeys[e.Item.ItemIndex].ToString();
        string    url = "", urlfile = "";
        DataTable td = XLDL.LayDuLieu("select tencty,dienthoai.hinhanh from DIENTHOAI,CONGTY where DIENTHOAI.macty=CONGTY.macty and masp='" + masp + "'");

        if (td.Rows.Count > 0)
        {
            url     = "~/images/" + td.Rows[0][0] + "/" + masp;
            urlfile = "~/images/home/" + td.Rows[0][1];
        }
        DataTable dt = XLDL.LayDuLieu("select masp from CTDONHANG where masp='" + masp + "'");

        if (dt.Rows.Count > 0)
        {
            Response.Write("<script>alert('Lỗi ! Không thể xóa sản phẩm')</script>");
        }
        else
        {
            //try
            {
                if (Directory.Exists(Server.MapPath(url)))
                {
                    XLDL.DeleteFolder(Server.MapPath(url));
                }
                if (File.Exists(Server.MapPath(urlfile)))
                {
                    File.Delete(Server.MapPath(urlfile));
                }
                XLDL.Chaylenh("delete from bannersp where masp='" + masp + "'");
                XLDL.Chaylenh("delete from kho where masp='" + masp + "'");
                XLDL.Chaylenh("delete from thongso where masp='" + masp + "'");
                XLDL.Chaylenh("delete from thongsochitiet where masp='" + masp + "'");
                XLDL.Chaylenh("delete from danhgia where masp='" + masp + "'");
                XLDL.Chaylenh("delete from dienthoai where masp='" + masp + "'");
                Response.Write("<script>alert('Sản phẩm được gỡ bỏ thành công')</script>");
                dienthoai();
            }

            /*catch
             * {
             *  Response.Write("<script>alert('Lỗi ! Không thể xóa sản phẩm')</script>");
             * }*/
        }
    }
Ejemplo n.º 17
0
    protected void dlSuaAdmin_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        int     id        = int.Parse(dlSuaAdmin.DataKeys[e.Item.ItemIndex].ToString());
        TextBox txtHoTen  = (TextBox)e.Item.FindControl("txtHoTen");
        TextBox txtDiaChi = (TextBox)e.Item.FindControl("txtDiaChi");
        TextBox txtSDT    = (TextBox)e.Item.FindControl("txtSDT");
        TextBox txtEmail  = (TextBox)e.Item.FindControl("txtEmail");

        try
        {
            XLDL.Chaylenh("update admin set hoten=N'" + txtHoTen.Text.Trim() + "',diachi=N'" + txtDiaChi.Text.Trim() + "',sdt='" + txtSDT.Text.Trim() + "',email=N'" + txtEmail.Text.Trim() + "' where id=" + id);
            Response.Redirect("~/quantrivien.aspx");
        }
        catch
        {
            Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
        }
    }
Ejemplo n.º 18
0
 protected void dlHinh_DeleteCommand(object source, DataListCommandEventArgs e)
 {
     try
     {
         int       id = int.Parse(dlHinh.DataKeys[e.Item.ItemIndex].ToString());
         DataTable dt = XLDL.LayDuLieu("select hinh from bannerhome where id=" + id);
         if (dt.Rows.Count > 0)
         {
             string tenfile = "~/images/home/banner/" + dt.Rows[0][0].ToString();
             File.Delete(Server.MapPath(tenfile));
             XLDL.Chaylenh("delete from bannerhome where id=" + id);
             slide();
         }
     }
     catch
     {
         Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
     }
 }
Ejemplo n.º 19
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     try
     {
         int bit = 0;
         foreach (DataListItem item in dlHinh.Items)
         {
             int      id     = int.Parse(dlHinh.DataKeys[item.ItemIndex].ToString());
             CheckBox cbHinh = (CheckBox)item.FindControl("cbHinh");
             if (cbHinh.Checked == true)
             {
                 bit = 1;
             }
             else
             {
                 bit = 0;
             }
             XLDL.Chaylenh("update khuyenmaicty set hien=" + bit + " where madeal=" + id);
         }
         DataTable dt = XLDL.LayDuLieu("select tencty,macty from congty where tencty='" + ddlHangSX.SelectedItem + "'");
         if (dt.Rows.Count > 0)
         {
             string             tenhinh        = "~/images/" + dt.Rows[0][0].ToString() + "/";
             HttpFileCollection fileCollection = Request.Files;
             for (int i = 0; i < fileCollection.Count; i++)
             {
                 HttpPostedFile uploadfile = fileCollection[i];
                 string         fileName   = Path.GetFileName(uploadfile.FileName);
                 if (uploadfile.ContentLength > 0)
                 {
                     string hinh = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fileName;
                     uploadfile.SaveAs(Server.MapPath(tenhinh) + hinh);
                     XLDL.Chaylenh("insert into khuyenmaicty(hinhanh,macty) values('" + hinh + "'," + int.Parse(dt.Rows[0][1].ToString()) + ")");
                 }
             }
         }
         deal();
     }
     catch
     {
         Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
     }
 }
Ejemplo n.º 20
0
 protected void dlHinh_DeleteCommand(object source, DataListCommandEventArgs e)
 {
     try
     {
         int       id = int.Parse(dlHinh.DataKeys[e.Item.ItemIndex].ToString());
         DataTable dt = XLDL.LayDuLieu("select khuyenmaicty.hinhanh,tencty from congty,khuyenmaicty where congty.macty=khuyenmaicty.macty and madeal=" + id);
         if (dt.Rows.Count > 0)
         {
             string tenfile = "~/images/" + dt.Rows[0][1].ToString() + "/" + dt.Rows[0][0].ToString();
             File.Delete(Server.MapPath(tenfile));
             XLDL.Chaylenh("delete from khuyenmaicty where madeal=" + id);
             deal();
         }
     }
     catch
     {
         Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
     }
 }
Ejemplo n.º 21
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     try
     {
         int bit = 0;
         foreach (DataListItem item in dlHinh.Items)
         {
             int      id     = int.Parse(dlHinh.DataKeys[item.ItemIndex].ToString());
             CheckBox cbHinh = (CheckBox)item.FindControl("cbHinh");
             if (cbHinh.Checked == true)
             {
                 bit = 1;
             }
             else
             {
                 bit = 0;
             }
             XLDL.Chaylenh("update bannersp set hien=" + bit + " where id=" + id);
         }
         DataTable          dt             = XLDL.LayDuLieu("select tencty,masp from congty,dienthoai where congty.macty=dienthoai.macty and masp='" + Request.QueryString["masp"] + "'");
         string             tenhinh        = "~/images/" + dt.Rows[0][0].ToString() + "/" + dt.Rows[0][1].ToString() + "/";
         HttpFileCollection fileCollection = Request.Files;
         for (int i = 0; i < fileCollection.Count; i++)
         {
             HttpPostedFile uploadfile = fileCollection[i];
             string         fileName   = Path.GetFileName(uploadfile.FileName);
             string         urlname    = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fileName;
             if (uploadfile.ContentLength > 0)
             {
                 uploadfile.SaveAs(Server.MapPath(tenhinh) + urlname);
                 XLDL.Chaylenh("insert into bannersp(masp,hinh) values('" + dt.Rows[0][1] + "','" + urlname + "')");
             }
         }
         Hinh();
         alert.Visible = true;
     }
     catch
     {
         error.Visible = true;
     }
 }
Ejemplo n.º 22
0
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        string thumuc = "~/images/" + txtTen.Text.Trim();

        if (!Directory.Exists(Server.MapPath(thumuc)))
        {
            Directory.CreateDirectory(Server.MapPath(thumuc));
        }
        if (FileUpload1.HasFile)
        {
            if (XLDL.CheckFileType(FileUpload1.FileName))
            {
                string tenhinh = "~/images/" + txtTen.Text.Trim() + "/" + DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;
                FileUpload1.SaveAs(Server.MapPath(tenhinh));
            }
        }
        string hinh = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;

        XLDL.Chaylenh("insert into congty(tencty,quocgia,mota,hinhanh) values(N'" + txtTen.Text.Trim() + "',N'" + txtQuocGia.Text.Trim() + "',N'" + txtMota.Text.Trim() + "','" + hinh + "')");
        Response.Redirect("~/congty.aspx");
    }
Ejemplo n.º 23
0
    protected void dlTinTuc_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        TextBox    txtTieuDe   = (TextBox)e.Item.FindControl("txtTieuDe");
        TextBox    txtTomTat   = (TextBox)e.Item.FindControl("txtTomTat");
        TextBox    txtLink     = (TextBox)e.Item.FindControl("txtLink");
        FileUpload FileUpload1 = (FileUpload)e.Item.FindControl("FileUpload1");
        int        id          = int.Parse(dlTinTuc.DataKeys[e.Item.ItemIndex].ToString());

        try
        {
            if (FileUpload1.HasFile)
            {
                if (XLDL.CheckFileType(FileUpload1.FileName))
                {
                    DataTable dt = XLDL.LayDuLieu("select hinh from tintuc where id=" + id);
                    if (dt.Rows.Count > 0)
                    {
                        string urlhinh = "~/images/news/" + dt.Rows[0][0];
                        if (File.Exists(Server.MapPath(urlhinh)))
                        {
                            File.Delete(Server.MapPath(urlhinh));
                        }
                    }
                    string tenhinh = "~/images/news/" + DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;
                    FileUpload1.SaveAs(Server.MapPath(tenhinh));
                    string hinh = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + FileUpload1.FileName;
                    XLDL.Chaylenh("update tintuc set tieude=N'" + txtTieuDe.Text.Trim() + "',tomtat=N'" + txtTomTat.Text.Trim() + "',hinh='" + hinh + "',url='" + txtLink.Text.Trim() + "',ngaydang='" + DateTime.Today.ToShortDateString() + "' where id=" + Request.QueryString["id"]);
                }
            }
            else
            {
                XLDL.Chaylenh("update tintuc set tieude=N'" + txtTieuDe.Text.Trim() + "',tomtat=N'" + txtTomTat.Text.Trim() + "',url='" + txtLink.Text.Trim() + "',ngaydang='" + DateTime.Today.ToShortDateString() + "' where id=" + Request.QueryString["id"]);
            }
            Response.Redirect("~/viewtintuc.aspx");
        }
        catch
        {
            Response.Write("<script>alert('Lỗi ! Vui lòng thử lại sau')</script>");
        }
    }
Ejemplo n.º 24
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNDKhuyenMai.Text.Trim() != "")
         {
             XLDL.Chaylenh("insert into khuyenmaisp(masp,noidung) values('" + Request.QueryString["masp"] + "',N'" + txtNDKhuyenMai.Text.Trim() + "')");
         }
         foreach (DataListItem item in dlKhuyenMai.Items)
         {
             int     id    = int.Parse(dlKhuyenMai.DataKeys[item.ItemIndex].ToString());
             TextBox txtKm = (TextBox)item.FindControl("txtKm");
             XLDL.Chaylenh("update khuyenmaisp set noidung=N'" + txtKm.Text.Trim() + "' where id=" + id);
         }
         khuyenmai();
         alert.Visible = true;
     }
     catch
     {
         error.Visible = true;
     }
 }
Ejemplo n.º 25
0
    protected void dtMota_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        int macty = int.Parse(dtMota.DataKeys[e.Item.ItemIndex].ToString());

        try
        {
            string    url = "";
            DataTable dt  = XLDL.LayDuLieu("select tencty from congty where macty = " + macty);
            if (dt.Rows.Count > 0)
            {
                url = "~/images/" + dt.Rows[0][0];
            }
            if (Directory.Exists(Server.MapPath(url)))
            {
                Directory.Delete(Server.MapPath(url));
            }
            XLDL.Chaylenh("delete from congty where macty=" + macty);
            motaCty();
        }
        catch
        {
            Response.Write("<script>alert('Xóa không thành công')</script>");
        }
    }
Ejemplo n.º 26
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataTable td = XLDL.LayDuLieu("select masp from DIENTHOAI where exists (select masp from DIENTHOAI) and masp='" + txtMaSP.Text.Trim() + "'");

        if (td.Rows.Count > 0)
        {
            Response.Write("<script>alert('Mã sản phẩm đã tồn tại. Vui lòng thử lại với tên khác')</script>");
            txtMaSP.Focus();
        }
        else
        {
            try
            {
                int    tragop  = 0;
                double giaban  = 0;
                int    macty   = 1;
                double giamgia = 0;
                if (cbTraGop.Checked == true)
                {
                    tragop = 1;
                }
                DataTable dt = XLDL.LayDuLieu("select macty from congty where tencty='" + ddlHangSX.SelectedItem + "'");
                if (dt.Rows.Count > 0)
                {
                    macty = int.Parse(dt.Rows[0][0].ToString());
                }
                else
                {
                    Response.Redirect("~/dienthoai.aspx");
                }
                if (txtGiamGia.Text.Trim() != "")
                {
                    giamgia = double.Parse(txtGiamGia.Text.Trim());
                }
                if (txtGiaBan.Text.Trim() != "")
                {
                    giaban = double.Parse(txtGiaBan.Text.Trim());
                }
                string thumuc  = "~/images/" + ddlHangSX.SelectedItem + "/" + txtMaSP.Text.Trim();
                string namepic = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fuHinh.FileName;
                XLDL.Chaylenh("insert into dienthoai values('" + txtMaSP.Text.Trim() + "',N'" + txtTenSP.Text.Trim() + "'," + giaban + ",'" + namepic + "'," + macty + "," + tragop + "," + giamgia + ")");
                if (!Directory.Exists(thumuc))
                {
                    Directory.CreateDirectory(Server.MapPath(thumuc));
                }
                if (fuHinh.HasFile)
                {
                    if (XLDL.CheckFileType(fuHinh.FileName))
                    {
                        string tenhinh = "~/images/home/" + DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + fuHinh.FileName;
                        fuHinh.SaveAs(Server.MapPath(tenhinh));
                    }
                }
                HttpFileCollection fileCollection = Request.Files;
                for (int i = 0; i < fileCollection.Count; i++)
                {
                    HttpPostedFile uploadfile = fileCollection[i];
                    string         fileName   = DateTime.Now.ToString("ddMMyyyy_hhmmss_tt_") + Path.GetFileName(uploadfile.FileName);
                    if (uploadfile.ContentLength > 0)
                    {
                        uploadfile.SaveAs(Server.MapPath(thumuc) + "/" + fileName);
                        XLDL.Chaylenh("insert into bannersp(masp,hinh) values('" + txtMaSP.Text.Trim() + "','" + fileName + "')");
                    }
                }
                XLDL.Chaylenh("insert into danhgia values('" + txtMaSP.Text.Trim() + "',N'" + CKEditor1.Text + "')");
                XLDL.Chaylenh("insert into thongso values('" + txtMaSP.Text.Trim() + "',N'" + txtManHinh.Text.Trim() + "',N'" + txtCPU.Text.Trim() + "',N'" + txtRam1.Text.Trim() + "',N'" + txtRom.Text.Trim() + "',N'" + txtHdh1.Text.Trim() + "',N'" + txtCamera.Text.Trim() + "',N'" + txtSelfie + "',N'" + txtPin1.Text.Trim() + "')");
                XLDL.Chaylenh("insert into thongsochitiet values('" + txtMaSP.Text.Trim() + "',N'" + txtCNMH.Text.Trim() + "',N'" + txtDoPhanGiai.Text.Trim() + "',N'" + txtMHRong.Text.Trim() + "',N'" + txtCamUng.Text.Trim() + "',N'" + txtDoPhanGiaiSau.Text.Trim() + "',N'" + txtQuayPhimSau.Text.Trim() + "',N'" + txtFlash.Text.Trim() + "',N'" + txtChupAnhNangCao.Text.Trim() + "',N'" + txtDoPhanGiaiTruoc.Text.Trim() + "',N'" + txtVideoCall.Text.Trim() + "',N'" + txtThongTinKhac.Text.Trim() + "',N'" + txtHdh.Text.Trim() + "',N'" + txtChipset.Text.Trim() + "',N'" + txtTocDoCPU.Text.Trim() + "',N'" + txtGpu.Text.Trim() + "',N'" + txtRam.Text.Trim() + "',N'" + txtBoNhoTrong.Text.Trim() + "',N'" + txtTheNho.Text.Trim() + "',N'" + txtSim.Text.Trim() + "',N'" + txtSac.Text.Trim() + "',N'" + txtTainghe.Text.Trim() + "',N'" + txtThietKe.Text.Trim() + "',N'" + txtChatLieu.Text.Trim() + "',N'" + txtKichThuoc.Text.Trim() + "',N'" + txtTrongLuong.Text.Trim() + "',N'" + txtPin.Text.Trim() + "',N'" + txtLoaiPin.Text.Trim() + "',N'" + txtCNPin.Text.Trim() + "',N'" + txtThoiDiem.Text.Trim() + "')");
                Response.Redirect("~/dienthoai.aspx");
            }
            catch
            {
                Response.Write("<script>alert('Lỗi trong quá trình ghi dữ liệu, vui lòng kiểm tra lại thông tin và đảm bảo rằng mọi thông tin đều chính xác')</script>");
            }
        }
    }