protected void Button1_Click1(object sender, EventArgs e)
 {
     if (Session["TenDN"] == null)
     {
         Response.Redirect("~/dangnhap.aspx");
     }
     else
     {
         string        MaChim = Request.QueryString["MaChim"];
         SqlConnection con    = new SqlConnection(CSDLBANCHIM.strCon);
         con.Open();
         SqlCommand cmd = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.Connection  = con;
         //                    cmd.CommandText = @"INSERT INTO CHIM(TenSP,DonViTinh,DonGia,MoTa,HinhMinhHoa,MaMenu,NgayCapNhat)
         //                                        VALUES(@TenSP,@DonViTinh,@DonGia,@MoTa,@HinhMinhHoa,@MaMenu,@NgayCapNhat)";
         cmd.CommandText = @"INSERT INTO BINHLUAN(NgayDang,NoiDungbinhluan,MaChim,TenDN) 
                                     VALUES(@NgayDang,@NoiDungbinhluan,@MaChim,@TenDN)";
         cmd.Parameters.Add("@NgayDang", SqlDbType.SmallDateTime);
         cmd.Parameters["@NgayDang"].Value = DateTime.Now.ToShortTimeString();
         cmd.Parameters.Add("@NoiDungbinhluan", SqlDbType.NText);
         cmd.Parameters["@NoiDungbinhluan"].Value = txtnoidung.Text;
         cmd.Parameters.Add("@MaChim", SqlDbType.Int);
         cmd.Parameters["@MaChim"].Value = MaChim;
         cmd.Parameters.Add("@TenDN", SqlDbType.VarChar, 15);
         cmd.Parameters["@TenDN"].Value = Session["TenDN"].ToString();
         cmd.ExecuteNonQuery();
         con.Close();
         Repeater2.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM BINHLUAN where MaChim=" + MaChim);
         Repeater2.DataBind();
     }
 }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Session["TenDNAdmin"] == null)
                {
                    Response.Redirect("~/Admin/DangnhapAdmin.aspx");
                }

                if (Session["TenDNAdmin"] != null)
                {
                    GridView1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM TINTUC ");
                    GridView1.DataBind();
                    //laynhaxuatban();
                    //CapnhatNXB();
                    ViewState["SortDirection"] = SortDirection.Ascending;
                }
            }
            catch
            {
            }
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Maloai = Request.QueryString["Maloai"];

        DataList.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM CHIM where Maloai=" + Maloai);
        DataList.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack != true)
        {
            if (Request.QueryString["MaChim"] != null)
            {
                int       MaChim = int.Parse(Request.QueryString["MaChim"]);
                DataTable dt     = CSDLBANCHIM.GetData("SELECT Tengoi,DonGia From CHIM WHERE MaChim = " + MaChim);
                String    Tengoi = dt.Rows[0][0].ToString();

                float DonGia  = float.Parse(dt.Rows[0][1].ToString());
                int   SoLuong = 1;
                ThemVaoGioHang(MaChim, Tengoi, DonGia, SoLuong);
            }
            if (Session["GioHang"] != null)
            {
                DataTable dt = new DataTable();
                dt = (DataTable)Session["GioHang"];
                System.Decimal TongThanhTien = 0;
                foreach (DataRow r in dt.Rows)
                {
                    r["ThanhTien"]       = Convert.ToInt32(r["SoLuong"]) * Convert.ToDouble(r["DonGia"]);
                    TongThanhTien       += Convert.ToDecimal(r["ThanhTien"]);
                    lbTongThanhTien.Text = TongThanhTien.ToString();
                }
                gvGioHang.DataSource = dt;
                gvGioHang.DataBind();
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = CSDLBANCHIM.GetData(@"SELECT TOP 9 * FROM CHIM ORDER BY NgayCapNhat DESC");

        DataList.DataSource = dt;
        DataList.DataBind();
    }
    protected void trahinh()
    {
        string    sql = "select * from LOGO where trangthai=0";
        DataTable dt  = CSDLBANCHIM.GetData(sql);

        Repeater2.DataSource = dt;
        Repeater2.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataList1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM TINTUC ");
        DataList1.DataBind();

        string    cmd = "UPDATE TINTUC SET LUOTXEM=LUOTXEM+1";
        DataTable dt  = CSDLBANCHIM.GetData(cmd);
    }
Пример #8
0
    protected void submit_Click(object sender, EventArgs e)
    {
        DataTable cmd = CSDLBANCHIM.GetData(@"Select TenDNAdmin,MatKhauAdmin from ADMIN where TenDNAdmin='" + userad.Text + "' and  MatKhauAdmin='" + passwordad.Text + "'");

        if (cmd.Rows.Count > 0)
        {
            Session["TenDNAdmin"] = userad.Text;
            lblThongbao.Text      = "Bạn đã đăng nhập thành công";
            Response.Redirect("~/Admin/Default.aspx");
        }
        else
        {
            lblThongbao.Text = "Bạn đăng nhập sai tên hoặc mật khẩu! Xin vui lòng kiểm tra lại";
        }
    }
Пример #9
0
    protected void submit_Click(object sender, EventArgs e)
    {
        DataTable cmd = CSDLBANCHIM.GetData(@"Select TenDN,MatKhau from KHACHHANG where TenDN='" + user.Text + "' and  MatKhau='" + password.Text + "'");

        if (cmd.Rows.Count > 0)
        {
            Session["TenDN"] = user.Text;
            lblThongbao.Text = "Bạn đã đăng nhập thành công";
            Response.Redirect("~/Trangchu.aspx");
        }
        else
        {
            lblThongbao.Text = "Bạn đăng nhập sai tên hoặc mật khẩu! Xin vui lòng kiểm tra lại";
        }
    }
 protected void submit_Click(object sender, EventArgs e)
 {
     try
     {
         string str1 = @"select 1 from Khachhang where TenDN=N'" + txtTenDN.Text + "'";
         if (CSDLBANCHIM.GetData(str1).Rows.Count > 0)
         {
             lbThongbaoloi.Text = "Tên đăng nhập đã tồn tại";
             txtTenDN.Focus();
         }
         else
         {
             SqlConnection con = new SqlConnection(CSDLBANCHIM.strCon);
             con.Open();
             SqlCommand cmd = new SqlCommand();
             cmd.CommandType = CommandType.Text;
             cmd.Connection  = con;
             cmd.CommandText = "INSERT INTO KHACHHANG (HoTenKH,DiaChiKH,DienThoaiKH,Email,TenDN,MatKhau,NgaySinh,GioiTinh) VALUES (@Hoten,@Diachi,@Dienthoai,@Email,@TenDN,@Matkhau,@Ngaysinh,@Gioitinh)";
             cmd.Parameters.Add("@Hoten", SqlDbType.NVarChar, 50);
             cmd.Parameters["@Hoten"].Value = txbTen.Text;
             cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar, 50);
             cmd.Parameters["@Diachi"].Value = txbDiachi.Text;
             cmd.Parameters.Add("@Dienthoai", SqlDbType.VarChar, 10);
             cmd.Parameters["@Dienthoai"].Value = txbSdt.Text;
             cmd.Parameters.Add("@Email", SqlDbType.VarChar, 50);
             cmd.Parameters["@Email"].Value = txtEmail.Text;
             cmd.Parameters.Add("@TenDN", SqlDbType.VarChar, 15);
             cmd.Parameters["@TenDN"].Value = txtTenDN.Text;
             cmd.Parameters.Add("@Matkhau", SqlDbType.VarChar, 15);
             cmd.Parameters["@Matkhau"].Value = txbMatkhau.Text;
             cmd.Parameters.Add("@Ngaysinh", SqlDbType.SmallDateTime);
             cmd.Parameters["@Ngaysinh"].Value = DateTime.Parse(txbNam.Text + "-" + DropDownList2.Text + "-" + DropDownList1.Text);
             cmd.Parameters.Add("@Gioitinh", SqlDbType.Int);
             cmd.Parameters["@Gioitinh"].Value = Convert.ToInt16(rdGioiTinh.SelectedItem.Value);
             // cmd.Parameters["@Gioitinh"].Value = Convert.ToInt16(rdGioiTinh.SelectedItem.Value.Equals("Nam") ? 1 : 0);
             cmd.ExecuteNonQuery();
             con.Close();
             Response.Redirect("~/DangNhap.aspx");
         }
     }
     catch
     {
         lbThongbaoloi.Text = "Thất bại!";
     }
 }
Пример #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack != true)
     {
         if (Session["TenDN"] == null)
         {
             Response.Redirect("~/dangnhap.aspx");
         }
         if (Session["GioHang"] == null)
         {
             Response.Redirect("~/Giohang.aspx");
         }
         if (Session["TenDN"] != null)
         {
             // string s = @"select MaKH,HoTenKH,DiaChiKH,DienThoaiKH,Email from KHACHHANG where TenDN ='" + Session["TenDN"].ToString() + "'";
             DataTable dt = CSDLBANCHIM.GetData("select MaKH,HoTenKH,DiaChiKH,DienThoaiKH,Email from KHACHHANG where TenDN ='" + Session["TenDN"].ToString() + "'");
             if (dt.Rows.Count > 0)
             {
                 lbHoTen.Text      = dt.Rows[0][1].ToString();
                 lbDiaChi.Text     = dt.Rows[0][2].ToString();
                 lbDienThoai.Text  = dt.Rows[0][3].ToString();
                 lbEmail.Text      = dt.Rows[0][4].ToString();
                 txtNguoiNhan.Text = dt.Rows[0][1].ToString();
                 txtDiaChi.Text    = dt.Rows[0][2].ToString();
                 txtDienThoai.Text = dt.Rows[0][3].ToString();
             }
         }
         if (Session["GioHang"] != null)
         {
             DataTable dt = new DataTable();
             dt = (DataTable)Session["GioHang"];
             System.Decimal tongthanhtien = 0;
             foreach (DataRow r in dt.Rows)
             {
                 r["ThanhTien"]  = Convert.ToInt32(r["SoLuong"]) * Convert.ToDecimal(r["DonGia"]);
                 tongthanhtien  += Convert.ToDecimal(r["Thanhtien"]);
                 lbTongTien.Text = tongthanhtien.ToString();
             }
             gvGioHang.DataSource = dt;
             gvGioHang.DataBind();
         }
         calNgayGiao.SelectedDate = DateTime.Today;
     }
 }
Пример #12
0
 protected void gvDonDatHang_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Chitiet")
     {
         try
         {
             hien();
             gvCTDH.Visible = true;
             int chiso = int.Parse(e.CommandArgument.ToString());
             int ma    = int.Parse(gvDonDatHang.Rows[chiso].Cells[0].Text);
             gvCTDH.DataSource = CSDLBANCHIM.GetData("select * from CTDATHANG where SoDH = " + ma);
             gvCTDH.DataBind();
         }
         catch
         {
             lbThongBao.Text = "Thất bại!";
         }
     }
 }
Пример #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["TenDNAdmin"] == null)
        {
            Response.Redirect("~/Admin/DangnhapAdmin.aspx");
        }

        if (Session["TenDNAdmin"] != null)
        {
            gvDonDatHang.DataSource = CSDLBANCHIM.GetData("Select * from DONDATHANG");
            gvDonDatHang.DataBind();

            string    Tengoi = ("select SUM(TriGia) FROM DONDATHANG ").ToString();
            string    sql    = "select SUM(TriGia) AS TONGTIEN FROM DONDATHANG ";
            DataTable dt     = CSDLBANCHIM.GetData(sql);

            lbtong.Text = dt.Rows[0]["TONGTIEN"].ToString();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string tim = Request.QueryString["tim"];/*Nhận 1 tham số từ trang khác*/

        DataTable dt = new DataTable();

        dt = CSDLBANCHIM.GetData("select * from CHIM where Tengoi LIKE  N'%" + tim + "%' and SoLuongBan > 0");
        if (dt.Rows.Count > 0)
        {
            lbtim.Visible       = true;
            lbtim.Text          = "Kết quả tìm kiếm cho:'" + tim + "'";
            lbthongbao.Visible  = false;
            DataList.DataSource = dt;
            DataList.DataBind();
        }
        else
        {
            lbtim.Visible      = false;
            lbthongbao.Visible = true;
            lbthongbao.Text    = "không có kết quả cho:'" + tim + "'";
        }
    }
    private void laydulieu()
    {
        DataTable dt = new DataTable();

        dt            = CSDLBANCHIM.GetData("select * from KHACHHANG where TenDN='" + Session["TenDN"].ToString() + "'");
        txtHoTen.Text = dt.Rows[0][1].ToString();
        bool GioiTinh = Boolean.Parse(dt.Rows[0][7].ToString());

        if (GioiTinh == true)
        {
            rblGioiTinh.SelectedValue = "Nam";
        }
        else
        {
            rblGioiTinh.SelectedValue = "Nữ";
        }
        DateTime ngaysinh = Convert.ToDateTime(dt.Rows[0][6].ToString());

        txtNgaySinh.Text    = ngaysinh.ToString("dd/MM/yyyy");
        txtDiaChi.Text      = dt.Rows[0][2].ToString();
        txtSoDienThoai.Text = dt.Rows[0][3].ToString();
    }
    protected void btndangnhap_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable cmd = CSDLBANCHIM.GetData(@"Select TenDN From KHACHHANG where TenDN='" + txtusername.Text + "' and Matkhau='" + txtpasswork.Text + " '");
            if (cmd.Rows.Count > 0)
            {
                CSDLBANCHIM.ExcuteNonQueryTraVeGiaTri("UPDATE KhachHang Set Matkhau = '" + txtmatkhaumoi.Text + "' WHERE TenDN = '" + txtusername.Text + "'");


                lblThongbao.Text = "Đổi mật khẩu thành công";
                Response.Redirect("~/DangNhap.aspx");
            }
            else
            {
                lblThongbao.Text = " đăng nhập hoặc mật khẩu cũ không hợp lệ!";
            }
        }
        catch
        {
            lblThongbao.Text = "Thất bại!";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        trahinh();
        DataList10.DataSource = CSDLBANCHIM.GetData("select * from PHANLOAI");
        DataList10.DataBind();
        if (Session["TenDN"] == null)
        {
            HyperLink2.Text      = "";
            linkdangnhap.Visible = true;

            ImageButton3.Visible = false;
        }
        else
        {
            HyperLink2.Text      = Session["TenDN"].ToString();
            linkdangnhap.Visible = false;
            linkdangky.Visible   = false;
            //lbllayten.Visible = false;
            //linkdangxuat.Visible = false;
            //linkdangnhap.Visible = true;
            //linkdangky.Visible = true;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string danhgia = txtdanhgia.Text.Trim();

        string    kkk = "select * from DANHGIA where Masao= N'" + danhgia + "'";
        DataTable dt  = CSDLBANCHIM.GetData(kkk);

        Repeater3.DataSource = dt;
        Repeater3.DataBind();


        string MaChim = Request.QueryString["MaChim"];

        Repeater1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM CHIM where MaChim=" + MaChim);
        Repeater1.DataBind();



        DataList.DataSource = CSDLBANCHIM.GetData(@"SELECT TOP 3 * from CHIM ORDER BY NEWID()");
        DataList.DataBind();

        Repeater2.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM BINHLUAN where MaChim=" + MaChim);
        Repeater2.DataBind();
    }
Пример #19
0
    protected void btDongY_Click(object sender, EventArgs e)
    {
        //  string str = @"select MaKH from KHACHHANG where TenDN ='" + Session["TenDN"].ToString() + "'";
        DataTable dt1 = new DataTable();

        dt1  = CSDLBANCHIM.GetData("select MaKH from KHACHHANG where TenDN ='" + Session["TenDN"].ToString() + "'");
        MaKH = int.Parse(dt1.Rows[0][0].ToString());
        int    httt = 0, htgh = 0;
        string TenNguoiNhan, DiaChiNhan, DienThoaiNhan;

        TenNguoiNhan  = txtNguoiNhan.Text;
        DiaChiNhan    = txtNguoiNhan.Text;
        DienThoaiNhan = txtDienThoai.Text;
        decimal tongthanhtien = decimal.Parse(lbTongTien.Text);

        httt = Convert.ToInt32(rblHinhThucThanhToan.SelectedItem.Value);
        htgh = Convert.ToInt32(rblhinhThucGiaoHang.SelectedItem.Value);

        try
        {
            SqlConnection con = new SqlConnection(CSDLBANCHIM.strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            cmd.CommandText = @"insert into DONDATHANG(MaKH,NgayDH,TriGia,NgayGiaoHang,TenNguoiNhan,DiaChiNhan,DienThoaiNhan,ThanhToan,Phuongthuc)
                Values(" + MaKH + ",@ngaydathang," + tongthanhtien + ",@NgayGiaoHang,N'" + TenNguoiNhan + "',N'" + DiaChiNhan + "','" + DienThoaiNhan + "'," + httt + "," + htgh + ")";
            cmd.Parameters.Add("@ngaydathang", SqlDbType.SmallDateTime);
            cmd.Parameters["@ngaydathang"].Value = DateTime.Now;
            cmd.Parameters.Add("@NgayGiaoHang", SqlDbType.SmallDateTime);
            cmd.Parameters["@NgayGiaoHang"].Value = calNgayGiao.SelectedDate;
            cmd.ExecuteNonQuery();
            con.Close();

            //laymadonhang
            string    s         = @"Select max(SoDH) from  DONDATHANG Where MaKH =" + MaKH;
            int       SODONHANG = int.Parse(CSDLBANCHIM.GetData(s).Rows[0][0].ToString());
            DataTable dt        = new DataTable();
            dt = (DataTable)Session["GioHang"];
            int     MaChim, SoLuong;
            Decimal DonGia;
            /* Luu san pham vao table CTDATHANG */
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                MaChim  = int.Parse(dt.Rows[i]["MaChim"].ToString());
                SoLuong = int.Parse(dt.Rows[i]["SoLuong"].ToString());
                DonGia  = Decimal.Parse(dt.Rows[i]["DonGia"].ToString());
                s       = "INSERT INTO CTDATHANG(SoDH,MaChim,SoLuong,DonGia) VALUES(" + SODONHANG + "," + MaChim + "," + SoLuong + "," + DonGia + ")";
                CSDLBANCHIM.Execute(s);
            }
            /* xoa gio hang sau khi da thuc hien xong dat hang*/
            Session["GioHang"] = null;
            /*Sau khi dat hang se chuyen toi trang XAc nhan don hang */
            //Response.Redirect("~/Xacnhandonhang.aspx");
            lbThongBaoLoi.Text = "Thanh toán thành công!";
        }
        catch
        {
            lbThongBaoLoi.Text = "Lỗi trong quá trình cập nhật dữ liệu!";
        }
    }
Пример #20
0
 public void laytin()
 {
     GridView1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM TINTUC ");
     GridView1.DataBind();
 }
 public void layChim()
 {
     GridView1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM CHIM ");
     GridView1.DataBind();
 }
Пример #22
0
 public void CapnhatNXB()
 {
     gvDonDatHang.DataSource = CSDLBANCHIM.GetData("Select * from DONDATHANG");
     gvDonDatHang.DataBind();
 }
Пример #23
0
 public void CapnhatNXB()
 {
     GridView1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM KHACHHANG ");
     GridView1.DataBind();
 }
Пример #24
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["TenDNAdmin"] == null)
        {
            Response.Redirect("~/Admin/DangnhapAdmin.aspx");
        }

        if (Session["TenDNAdmin"] != null)
        {
            try
            {
                string str1 = @"Select * from CHim Where HinhMinhHoa = '" + FileUpload1.FileName.ToString() + "'";
                if (CSDLBANCHIM.GetData(str1).Rows.Count > 0)
                {
                    lbThongBaoLoi.Text      = "Sản phẩm đã tồn tại.";
                    lbThongBaoLoi.ForeColor = System.Drawing.Color.Red;
                    lbThongBaoLoi.Focus();
                }
                else
                {
                    SqlConnection con = new SqlConnection(CSDLBANCHIM.strCon);
                    con.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    //                    cmd.CommandText = @"INSERT INTO CHIM(TenSP,DonViTinh,DonGia,MoTa,HinhMinhHoa,MaMenu,NgayCapNhat)
                    //                                        VALUES(@TenSP,@DonViTinh,@DonGia,@MoTa,@HinhMinhHoa,@MaMenu,@NgayCapNhat)";
                    cmd.CommandText = @"INSERT INTO CHIM(Tengoi,DonGia,MoTa,Maloai,HinhMinhHoa,NgayCapNhat,SoLuongBan) 
                                        VALUES(@Tengoi,@DonGia,@MoTa,@Maloai,@HinhMinhHoa,@NgayCapNhat,@SoLuongBan)";
                    cmd.Parameters.Add("@Tengoi", SqlDbType.NVarChar, 100);
                    cmd.Parameters["@Tengoi"].Value = TextBox1.Text;

                    cmd.Parameters.Add("@DonGia", SqlDbType.Money);
                    cmd.Parameters["@DonGia"].Value = TextBox3.Text;
                    cmd.Parameters.Add("@MoTa", SqlDbType.NText);
                    cmd.Parameters["@MoTa"].Value = CKEditorControl1.Text;
                    cmd.Parameters.Add("@HinhMinhHoa", SqlDbType.VarChar, 50);
                    cmd.Parameters["@HinhMinhHoa"].Value = FileUpload1.FileName.ToString();
                    cmd.Parameters.Add("@Maloai", SqlDbType.Int);

                    cmd.Parameters["@Maloai"].Value = TextBox2.Text;
                    cmd.Parameters.Add("@SoLuongBan", SqlDbType.Int);

                    cmd.Parameters["@SoLuongBan"].Value = TextBox4.Text;
                    cmd.Parameters.Add("@NgayCapNhat", SqlDbType.SmallDateTime);
                    cmd.Parameters["@NgayCapNhat"].Value = DateTime.Now.ToShortTimeString();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    TextBox1.Text           = "";
                    TextBox2.Text           = "";
                    TextBox4.Text           = "";
                    CKEditorControl1.Text   = "";
                    TextBox3.Text           = "";
                    lbThongBaoLoi.Text      = "Thêm Sản Phẩm Mới Thành Công";
                    lbThongBaoLoi.ForeColor = System.Drawing.Color.Green;
                }
            }
            catch (Exception ex)
            {
                lbThongBaoLoi.Text      = "Thêm SP mới thất bại.";
                lbThongBaoLoi.ForeColor = System.Drawing.Color.Red;
                throw ex;
            }
        }
    }
 public void layLG()
 {
     GridView1.DataSource = CSDLBANCHIM.GetData(@"SELECT * FROM LOGO ");
     GridView1.DataBind();
 }