protected void Page_Load(object sender, EventArgs e) { string sql = "select id_nguoi, email_nguoi, mat_khau_nguoi, ten_nguoi, cast(FORMAT(ngay_sinh, 'yyyy-MM-dd') as varchar) as ngay_sinh, dia_chi_nguoi, sdt_nguoi, gioi_tinh_nguoi from nguoi where id_nguoi="; int id_nguoi = 0; WebApplication2.QuanTri.maHoa mH = new WebApplication2.QuanTri.maHoa(); connect connect; try { if (Request.QueryString["id_nguoi"] != null && Request.QueryString["id_nguoi"] != "") { id_nguoi = int.Parse(Request.QueryString["id_nguoi"]); } } catch (Exception qqe) { } if (id_nguoi == 0) { Response.Redirect("./DanhSach.aspx"); } connect = new connect(); System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); DataTable ds = new DataTable(); new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql + +id_nguoi, ketnoi)).Fill(ds); if (ds == null || ds.Rows.Count == 0) { Response.Redirect("./DanhSach.aspx"); } maHoa m = new maHoa(); if (!IsPostBack) { TextBox6.Text = ds.Rows[0][0].ToString(); TextBox0.Text = ds.Rows[0][1].ToString(); TextBox1.Text = m.Base64Decode(ds.Rows[0][2].ToString()); TextBox1.Attributes["type"] = "password"; TextBox2.Text = ds.Rows[0][3].ToString(); TextBox3.Text = ds.Rows[0][4].ToString(); TextBox4.Text = ds.Rows[0][5].ToString(); TextBox5.Text = ds.Rows[0][6].ToString(); if (bool.Parse(ds.Rows[0][7].ToString()) == true) { RadioButton1.Checked = true; RadioButton2.Checked = false; } else { RadioButton1.Checked = false; RadioButton2.Checked = true; } } }
protected void Page_Load(object sender, EventArgs e) { mH = new maHoa(); connect = new connect(); System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); //1. danh sách TH string sql = "select id_thuong_hieu, ten_thuong_hieu from thuong_hieu"; connect = new connect(); DataTable tmp = new DataTable(); new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(tmp); for (int i = 0; i < tmp.Rows.Count; i++) { tmp.Rows[i][1] = mH.Base64Decode(tmp.Rows[i][1].ToString()); } if (!IsPostBack) { DropDownList0.DataSource = tmp; DropDownList0.DataTextField = "ten_thuong_hieu"; DropDownList0.DataValueField = "id_thuong_hieu"; DropDownList0.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { mH = new maHoa(); connect connect; try { if (Request.QueryString["id_san_pham"] != null && Request.QueryString["id_san_pham"] != "") { id_san_pham = int.Parse(Request.QueryString["id_san_pham"]); } } catch (Exception qqe) { } if (id_san_pham == 0) { Response.Redirect("./danhSach.aspx"); } connect = new connect(); System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); string sql = "SELECT id_san_pham " + ",id_thuong_hieu " + " ,ten_san_pham " + ",anh_san_pham " + " ,cast(gia_cao as int)" + " ,cast(gia_ban_ra as int)" + ",cast(gia_nhap_san_pham as int)" + ",mo_ta_san_pham_html " + ",dac_tinh_san_pham " + ",khoi_luong_san_pham_gram " + ",da_co_vat " + " , cast(FORMAT(ngay_cap_nhat, 'yyyy-MM-dd') as varchar) as ngay_cap_nhat" + " FROM san_pham " + "where id_san_pham=" + id_san_pham; DataTable ds = new DataTable(); new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds); if (ds == null || ds.Rows.Count == 0) { Response.Redirect("./danhSach.aspx"); } anh = ds.Rows[0][3].ToString(); //1. danh sách tỉnh sql = "select id_thuong_hieu, ten_thuong_hieu from thuong_hieu"; connect = new connect(); DataTable tmp = new DataTable(); new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(tmp); for (int i = 0; i < tmp.Rows.Count; i++) { tmp.Rows[i][1] = mH.Base64Decode(tmp.Rows[i][1].ToString()); } if (!IsPostBack) { DropDownList0.DataSource = tmp; DropDownList0.DataTextField = "ten_thuong_hieu"; DropDownList0.DataValueField = "id_thuong_hieu"; DropDownList0.DataBind(); } if (!IsPostBack) { DropDownList0.SelectedValue = ds.Rows[0][1].ToString(); TextBox0.Text = ds.Rows[0][0].ToString(); TextBox1.Text = mH.Base64Decode(ds.Rows[0][2].ToString()); TextBox3.Text = ds.Rows[0][4].ToString(); TextBox4.Text = ds.Rows[0][5].ToString(); TextBox5.Text = ds.Rows[0][6].ToString(); TextBox6.Text = mH.Base64Decode(ds.Rows[0][7].ToString()); TextBox7.Text = mH.Base64Decode(ds.Rows[0][8].ToString()); TextBox8.Text = ds.Rows[0][9].ToString(); TextBox9.Text = ds.Rows[0][11].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { connect connect = new connect(); System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); string loi = "Dữ liệu đầu vào lỗi"; string ngaybaydau = ""; string ngayketthuc = ""; try { try { if (Request.QueryString["ngaybaydau"] != null && Request.QueryString["ngaybaydau"].Length != 0) { ngaybaydau = Request.QueryString["ngaybaydau"]; } if (Request.QueryString["ngayketthuc"] != null && Request.QueryString["ngayketthuc"].Length != 0) { ngayketthuc = Request.QueryString["ngayketthuc"]; } } catch (Exception a) { } if (ngaybaydau.Length == 0 || ngayketthuc.Length == 0) { int.Parse("a"); } loi = "Lỗi không xác định!"; maHoa m = new maHoa(); ngaybaydau = m.Base64Decode(ngaybaydau); ngayketthuc = m.Base64Decode(ngayketthuc); if (!IsPostBack) { WebApplication2.QuanTri.maHoa mH = new WebApplication2.QuanTri.maHoa(); string sql = "select dh.id_don_hang, cast(FORMAT(dh.ngay_tao_don_hang, 'dd-MM-yyyy') as varchar) as ngay_tao_don_hang, " + " sp.ten_san_pham, ctdh.so_luong, " + " cast (sp.gia_nhap_san_pham as int) donGiaNhap, " + " cast(ctdh.so_luong * sp.gia_nhap_san_pham as int)thanhTienNhap, " + " cast(ctdh.gia_da_giam as int)donGiaBan, " + " cast(ctdh.so_luong * ctdh.gia_da_giam as int)thanhTienBan, " + " cast((ctdh.so_luong * ctdh.gia_da_giam - ctdh.so_luong * sp.gia_nhap_san_pham) as int) tienLoi " + " from don_hang dh join chi_tiet_don_hang ctdh on dh.id_don_hang = ctdh.id_don_hang " + " join san_pham sp on sp.id_san_pham=ctdh.id_san_pham " + " where " + " DATEDIFF(DAY,'" + ngaybaydau + "', dh.ngay_tao_don_hang) >= 0 " + " and DATEDIFF(DAY,dh.ngay_tao_don_hang, '" + ngayketthuc + "') >= 0 " + " and dh.id_ttdh=3 " + " order by dh.id_don_hang asc"; DataTable tmp = new DataTable(); new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(tmp); //khungHoaDon KHD = new khungHoaDon(); //DataTable BangChiTietDoanhThu = KHD.Tables["ChiTietSanPhamDonHang"]; DataTable BangChiTietDoanhThu = new DataTable(); BangChiTietDoanhThu.Columns.Add("id_don_hang"); BangChiTietDoanhThu.Columns.Add("ngay_tao_don_hang"); BangChiTietDoanhThu.Columns.Add("ten_san_pham"); BangChiTietDoanhThu.Columns.Add("so_luong"); BangChiTietDoanhThu.Columns.Add("donGiaNhap"); BangChiTietDoanhThu.Columns.Add("thanhTienNhap"); BangChiTietDoanhThu.Columns.Add("donGiaBan"); BangChiTietDoanhThu.Columns.Add("thanhTienBan"); BangChiTietDoanhThu.Columns.Add("tienLoi"); long tongdoanhthu = 0, tongtienloi = 0; for (int i = 0; i < tmp.Rows.Count; i++) { tongdoanhthu += int.Parse(tmp.Rows[i][7].ToString()); tongtienloi += int.Parse(tmp.Rows[i][8].ToString()); DataRow x = BangChiTietDoanhThu.NewRow(); x[0] = tmp.Rows[i][0].ToString(); x[1] = tmp.Rows[i][1].ToString(); x[2] = mH.Base64Decode(tmp.Rows[i][2].ToString()); x[3] = tmp.Rows[i][3].ToString(); x[4] = String.Format("{0:n0}", int.Parse(tmp.Rows[i][4].ToString())).Replace(",", ".") + " vnđ"; x[5] = String.Format("{0:n0}", int.Parse(tmp.Rows[i][5].ToString())).Replace(",", ".") + " vnđ"; x[6] = String.Format("{0:n0}", int.Parse(tmp.Rows[i][6].ToString())).Replace(",", ".") + " vnđ"; x[7] = String.Format("{0:n0}", int.Parse(tmp.Rows[i][7].ToString())).Replace(",", ".") + " vnđ"; x[8] = String.Format("{0:n0}", int.Parse(tmp.Rows[i][8].ToString())).Replace(",", ".") + " vnđ"; BangChiTietDoanhThu.Rows.Add(x); } ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report1.rdlc"); // ReportParameter[] param = new ReportParameter[4]; param[0] = new ReportParameter("thoiGianDauCuoi", "TỪ NGÀY " + ngaybaydau + " ĐẾN NGÀY " + ngayketthuc); param[1] = new ReportParameter("ngaytaobaocao", DateTime.Now.ToString("dd/MM/yyyy")); param[2] = new ReportParameter("tongdoanhthu", String.Format("{0:n0}", tongdoanhthu).Replace(",", ".") + " vnđ"); param[3] = new ReportParameter("tongtienloi", String.Format("{0:n0}", tongtienloi).Replace(",", ".") + " vnđ"); ReportViewer1.LocalReport.SetParameters(param); // ReportDataSource datasource = new ReportDataSource("PhaiChinhXac", BangChiTietDoanhThu); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } } catch (Exception a) { Response.Write("<script language='javascript'> alert('" + loi + "'); history.go(-1); </script>"); } // }