コード例 #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>");
     }
 }
コード例 #2
0
ファイル: SuaDT.aspx.cs プロジェクト: khanh71/Phone-Trading
 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;
     }
 }
コード例 #3
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");
    }
コード例 #4
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>");
        }
    }
コード例 #5
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>");
            }
        }
    }