private void CreateNodeChild(TreeNode Nparent, string quyen_ma, clsConnect cn) { string sql = "select * from menu where menu_parent_id = @menu_parent_id ORDER BY menu_order, menu.menu_id"; int Nparameter = 1; string[] name = new string[2]; object[] value = new object[2]; name[0] = "@menu_parent_id"; value[0] = Nparent.Value; foreach (DataRow row in cn.LoadData(sql, name, value, Nparameter).Rows) { TreeNode node_parent = new TreeNode(row["menu_title"].ToString(), row["menu_id"].ToString()); Nparent.ChildNodes.Add(node_parent); //checked menu sql = "select * from menu, chitietquyen where menu.menu_id = chitietquyen.menu_id and " + "menu.menu_id = @menu_id and quyen_ma = @quyen_ma ORDER BY menu_parent_id, menu_order, menu.menu_id"; Nparameter = 2; name[0] = "@menu_id"; value[0] = node_parent.Value; name[1] = "@quyen_ma"; value[1] = quyen_ma; if (cn.LoadData(sql, name, value, Nparameter).Rows.Count > 0) { node_parent.Checked = true; } CreateNodeChild(node_parent, quyen_ma, cn); } }
private void dislaytremenu(string quyen_ma) { clsConnect cn = new clsConnect(); string sql = "select * from menu where menu_parent_id = 0"; foreach (DataRow row_root in cn.LoadData(sql).Rows) { TreeNode root = new TreeNode(row_root["menu_title"].ToString(), row_root["menu_id"].ToString()); tremenu.Nodes.Add(root); sql = "select * from menu, chitietquyen where menu.menu_id = chitietquyen.menu_id and " + "menu.menu_id = @menu_id and quyen_ma = @quyen_ma ORDER BY menu_parent_id, menu_order, menu.menu_id"; int Nparameter = 2; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; name[0] = "@menu_id"; value[0] = root.Value; name[1] = "@quyen_ma"; value[1] = quyen_ma; if (cn.LoadData(sql, name, value, Nparameter).Rows.Count > 0) { root.Checked = true; } CreateNodeChild(root, quyen_ma, cn); } cn.close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { clsConnect cn = new clsConnect(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; Page.SetFocus(txtmenu_name); dislayTremenu(); if (Request.QueryString["Menu_ID"] != null) { string menu_id = Request.QueryString["Menu_ID"].ToString(); string valuepath = cn.LoadData("SELECT * FROM Menu where Menu_ID=" + menu_id + " ORDER BY menu_order").Rows[0]["menu_valuepath"].ToString(); tremenu.FindNode(valuepath).Selected = true; lblmenu.Text = tremenu.SelectedNode.Text; if (Request.QueryString["sub_menu"] == null) { rdbMenu.SelectedIndex = 1; } rdbMenu_SelectedIndexChanged(sender, e); } #region phan quyen trang try { string sqlText = "select * from ChiTietQuyen CT JOIN Menu M ON CT.Menu_id=M.Menu_id " + "WHERE Quyen_ma=@quyen_ma AND menu_url=@menu"; Nparameter = 2; name[0] = "@quyen_ma"; name[1] = "@menu"; value[0] = Session["Quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { } #endregion cn.close(); } }
protected void ddlServiceType_SelectedIndexChanged(object sender, EventArgs e) { try { clsConnect cn = new clsConnect(); int Nparameter = 1; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sql = ""; DataTable dt = new DataTable(); if (ddlServiceType.Text != "0") { sql = "SELECT * FROM service WHERE service_type_id=?service_type_id"; Nparameter = 1; name[0] = "?service_type_id"; value[0] = ddlServiceType.Text; dt = cn.LoadData(sql, name, value, Nparameter); if (dt.Rows.Count > 0) { ddlService.DataSource = dt; ddlService.DataBind(); } } } catch (Exception) { } }
private bool Check_Error(int _IDSave) { lblMsg.BackColor = System.Drawing.Color.Yellow; if (txtquyen_ten.Text == "") { lblMsg.Text = "Vui lòng điền vào tên quyền."; return(false); } else { clsConnect cn = new clsConnect(); string sql = "select * from quyen where quyen = @quyen_ten and quyen_ma != @quyen_ma"; int Nparameter = 2; string[] name = new string[Nparameter]; name[0] = "@quyen_ten"; name[1] = "@quyen_ma"; object[] value = new object[Nparameter]; value[0] = txtquyen_ten.Text; value[1] = _IDSave; if (cn.LoadData(sql, name, value, Nparameter).Rows.Count > 0) { lblMsg.Text = "Tên quyền đã có rồi.Vui lòng nhập lại."; return(false); } } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Convert.ToInt16(Session["Quyen_ma"]) == 0) { Response.Redirect("Default.aspx"); } //createMenu(1); createMenu(Convert.ToInt16((Session["Quyen_ma"]))); divUser.InnerHtml = "Xin chào, " + Session["username"].ToString(); String sqlText = "SELECT * FROM NhanVien WHERE NhanVien_ma = @nhanvien_ma;"; clsConnect cn = new clsConnect(); int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@nhanvien_ma"; object[] value = new object[Nparameter]; value[0] = Session["NhanVien_ma"]; DataTable dt = cn.LoadData(sqlText, name, value, Nparameter); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; divUser.InnerHtml = "Xin chào, " + row["NhanVien_ten"].ToString(); } cn.close(); } }
private bool SearchPassword() { clsConnect cn = new clsConnect(); string sql = ""; int parameter = 5; string[] name = new string[parameter]; object[] value = new object[parameter]; if (txtPassWordReNew.Text.Trim().ToUpper() != txtPassWordNew.Text.Trim().ToUpper()) { lblMsg.Text = "Mật khẩu mới không hợp lệ."; lblMsg.ForeColor = System.Drawing.Color.Red; return(false); } else { sql = "SELECT * FROM taikhoan WHERE nhanvien_ma=@nhanvien_ma"; parameter = 1; name[0] = "@nhanvien_ma"; value[0] = Session["nhanvien_ma"].ToString(); DataTable dt = cn.LoadData(sql, name, value, parameter); if (dt.Rows.Count == 0) { cn.close(); return(false); } lblUserName.Text = dt.Rows[0]["username"].ToString(); sql = "SELECT * FROM taikhoan WHERE username=@username AND password=@password"; parameter = 2; name[0] = "@username"; name[1] = "@password"; value[0] = lblUserName.Text.Trim(); value[1] = txtPassWord.Text.Trim(); dt = cn.LoadData(sql, name, value, parameter); if (dt.Rows.Count > 0) { cn.close(); return(true); } lblMsg.Text = "Mật khẩu không đúng."; lblMsg.ForeColor = System.Drawing.Color.Red; cn.close(); return(false); } }
private void dislayGrid_quyen() { clsConnect cn = new clsConnect(); string sql = "select * from quyen"; gridauthority.DataSource = cn.LoadData(sql); gridauthority.DataBind(); cn.close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dtlWeb.DataSource = cls.LoadData("select top 2 (tieude), * from dichvu where loaidv_id=1 order by tintuc_id desc"); dtlWeb.DataBind(); //dtlTinTuc.DataSource = cls.LoadData("SELECT TOP 5 (tieude),* FROM TinTuc where loaitin_ma=1 ORDER BY TinTuc_ID DESC "); //dtlTinTuc.DataBind(); lbl.Text = DateTime.Now.ToString("dd/MM/yyyy"); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (CheckError()) { clsConnect cn = new clsConnect(); string sql = "INSERT INTO menu(menu_title,menu_description,menu_url,menu_valuepath,menu_parent_id, menu_order) " + "VALUES(@menu_title,@menu_description,@menu_url,@menu_valuepath,@menu_parent_id, @menu_order)"; int Nparameter = 6; string[] name = new string[Nparameter]; name[0] = "@menu_valuepath"; name[1] = "@menu_description"; name[2] = "@menu_url"; name[3] = "@menu_title"; name[4] = "@menu_parent_id"; name[5] = "@menu_order"; object[] value = new object[Nparameter]; value[0] = ""; if (tremenu.SelectedNode != null) { value[0] = tremenu.SelectedNode.ValuePath; } value[1] = txtmenu_description.Text; value[2] = txtmenu_url.Text; value[3] = txtmenu_name.Text; if (Request.QueryString["menu_id"] == null) { value[4] = 0; } else { value[4] = tremenu.SelectedValue; } value[5] = txtMenuOrder.Text; cn.UpdateData(sql, name, value, Nparameter); string menu_id = cn.LoadData("SELECT * FROM menu WHERE menu_id IN(SELECT TOP 1(menu_id) FROM menu ORDER BY menu_id desc)").Rows[0][0].ToString(); value[0] = value[0].ToString() + "/" + menu_id; if (Request.QueryString["menu_id"] == null) { value[0] = menu_id; } cn.UpdateData("UPDATE menu SET menu_valuepath=@menu_valuepath WHERE menu_id=" + menu_id, name, value, 1); cn.close(); String strURL = "menu.aspx?menu_id=" + menu_id + "&sub_menu=1"; if (Request.QueryString["menu_id"] != null) { strURL = "menu.aspx?menu_id=" + Request.QueryString["menu_id"].ToString() + "&sub_menu=1"; } Response.Redirect(strURL); } }
private void dislayGrid_quyen_detail(string quyen_ma) { clsConnect cn = new clsConnect(); string sql = "select * from chitietquyen,menu where chitietquyen.menu_id=menu.menu_id and quyen_ma=@quyen_ma "; int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@quyen_ma"; object[] value = new object[Nparameter]; value[0] = quyen_ma; rptquyenDetail.DataSource = cn.LoadData(sql, name, value, Nparameter); rptquyenDetail.DataBind(); cn.close(); }
private void createMenu(int quyen_ma) { clsConnect cn = new clsConnect(); DataTable dt = cn.LoadData("select * from Menu, ChiTietQuyen where Menu.Menu_ID=ChiTietQuyen.Menu_ID and Quyen_ma=" + quyen_ma + " ORDER BY menu_parent_id, menu_order, Menu.Menu_ID"); if (dt.Rows.Count == 0) { mnuTools.Visible = false; } else { createMenuItem(dt); } cn.close(); }
private void LoadData(string menu_id) { clsConnect cn = new clsConnect(); int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@menu_id"; object[] value = new object[Nparameter]; value[0] = menu_id; DataRow row = cn.LoadData("SELECT * FROM menu where menu_id=@menu_id", name, value, Nparameter).Rows[0]; cn.close(); txtmenu_name.Text = row["menu_title"].ToString(); txtmenu_description.Text = row["menu_description"].ToString(); txtmenu_url.Text = row["menu_url"].ToString(); txtMenuOrder.Text = row["menu_order"].ToString(); }
protected void btnAdd_Click(object sender, EventArgs e) { if (Check_Error(0)) { clsConnect cn = new clsConnect(); string sql = "insert into quyen(quyen) values(@quyen)"; int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@quyen"; object[] value = new object[Nparameter]; value[0] = txtquyen_ten.Text; cn.UpdateData(sql, name, value, Nparameter); string quyen_ma = cn.LoadData("select * from quyen WHERE quyen_ma IN(SELECT TOP 1(quyen_ma) FROM quyen ORDER BY quyen_ma DESC)").Rows[0][0].ToString(); cn.close(); Response.Redirect("sys_authority.aspx");//?quyen_ma=" + quyen_ma); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { return; } { clsConnect cn = new clsConnect(); string quyen_ma = Convert.ToString(Request.QueryString["quyen_ma"]); if (quyen_ma == null) { setButton(true); } else { setButton(false); LoadData(quyen_ma); } dislayGrid_quyen(); #region phan quyen trang try { string sqlText = "select * from chitietquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + "WHERE quyen_ma=@quyen_ma AND menu_url=@menu"; int Nparameter = 2; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; name[0] = "@quyen_ma"; name[1] = "@menu"; value[0] = Session["quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { } #endregion } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dtlWeb.DataSource = cls.LoadData("Select * from dichvu where loaidv_id=2"); dtlWeb.DataBind(); if (Session["trang"] == null) { Session["trang"] = 1; } lblpreview.Visible = false; lblnext.Visible = false; lblpage.Visible = false; if (Session["sotrang"] == null) { Session["sotrang"] = 1; } } }
private void LoadData(string quyen_ma) { clsConnect cn = new clsConnect(); int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@quyen_ma"; object[] value = new object[Nparameter]; value[0] = quyen_ma; DataTable dt = cn.LoadData("select * from quyen where quyen_ma = @quyen_ma ", name, value, Nparameter); DataRow row = dt.Rows[0]; txtquyen_ten.Text = row["quyen"].ToString(); cn.close(); divmenu.Visible = true; lblquyen.Text = row["quyen"].ToString(); dislaytremenu(row["quyen_ma"].ToString()); dislayGrid_quyen_detail(row["quyen_ma"].ToString()); }
private void createMenuItem(DataTable table) { clsConnect cn = new clsConnect(); foreach (DataRow row in table.Rows) { string[] strValuepath = row["menu_valuepath"].ToString().Split('/'); string valuepathParent = ""; for (int i = 0; i < strValuepath.Length; i++) { DataRow temp = cn.LoadData("select * from Menu where Menu_ID=" + strValuepath[i]).Rows[0]; MenuItem item = new MenuItem(); if (i == 0 || i == 1) { valuepathParent = strValuepath[0]; } else { valuepathParent += "/" + strValuepath[i - 1]; } item = mnuTools.FindItem(temp["menu_valuepath"].ToString()); if (item == null) { MenuItem itemtemp = new MenuItem(); itemtemp.Text = temp["Menu_title"].ToString(); itemtemp.Value = temp["Menu_ID"].ToString(); itemtemp.NavigateUrl = temp["menu_url"].ToString(); itemtemp.ToolTip = temp["menu_description"].ToString(); if (i == 0) { mnuTools.Items.Add(itemtemp); } else { //itemtemp.Text = "<img src='../images/menu/icon-16-menu.png'/>" + temp["menu_title"].ToString(); mnuTools.FindItem(valuepathParent).ChildItems.Add(itemtemp); } } } } cn.close(); }
private bool Validate(int id) { clsConnect cn = new clsConnect(); string sqlText = ""; int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; if (txtTen.Text == "") { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message error\"><ul><li>Nhập tên tài khoản</li></ul></dd></dl>"; lblMessageStatus.Visible = true; return(false); } else { Nparameter = 2; name[0] = "@username"; name[1] = "@id"; value[0] = txtTen.Text.Trim(); value[1] = id; if (id == 0) { Nparameter = 1; sqlText = "select * from TaiKhoan where username = @username "; } else { sqlText = "select * from TaiKhoan where username = @username and id != @id"; } if (cn.LoadData(sqlText, name, value, Nparameter).Rows.Count > 0) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message error\"><ul><li>Tên tài khoản này đã có.</li></ul></dd></dl>"; lblMessageStatus.Visible = true; return(false); } } return(true); }
private bool Validate(int hanghoa_ma) { if (txtTen.Text == "") { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message error\"><ul><li>Nhập tên loại dịch vụ</li></ul></dd></dl>"; lblMessageStatus.Visible = true; return(false); } else { clsConnect cn = new clsConnect(); string sqlText = ""; int Nparameter = 2; string[] name = new string[2]; object[] value = new object[2]; name[0] = "@service_type_name"; name[1] = "@service_type_id"; value[0] = txtTen.Text.ToUpper(); value[1] = hanghoa_ma; if (hanghoa_ma == 0) { Nparameter = 1; sqlText = "select * from service_type where service_type_name = @service_type_name "; } else { sqlText = "select * from service_type where service_type_name = @service_type_name and service_type_id != @service_type_id"; } if (cn.LoadData(sqlText, name, value, Nparameter).Rows.Count > 0) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message error\"><ul><li>Tên loại dịch vụ này đã có.</li></ul></dd></dl>"; lblMessageStatus.Visible = true; return(false); } } return(true); }
private void dislayTremenu() { clsConnect cn = new clsConnect(); try { string sql = "SELECT * FROM Menu where menu_parent_id = 0 ORDER BY menu_parent_id, menu_order, menu_id"; foreach (DataRow row in cn.LoadData(sql).Rows) { TreeNode root = new TreeNode(row["Menu_title"].ToString() + " (" + row["menu_order"].ToString() + ")", row["Menu_ID"].ToString()); root.NavigateUrl = "menu.aspx?menu_id=" + row["Menu_ID"].ToString(); root.ToolTip = row["menu_description"].ToString(); tremenu.Nodes.Add(root); CreateNodeChild(root, cn); } } catch (Exception) { } cn.close(); }
private void deletemenu(string menu_id) { clsConnect cn = new clsConnect(); string sql = "DELETE FROM menu WHERE menu_id = @menu_id"; int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@menu_id"; object[] value = new object[Nparameter]; value[0] = menu_id; cn.UpdateData(sql, name, value, Nparameter); sql = "SELECT menu_id FROM menu where menu_parent_id = @menu_id"; DataTable dt = cn.LoadData(sql, name, value, Nparameter); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { deletemenu(row[0].ToString()); } } cn.close(); }
private void CreateNodeChild(TreeNode Nparent, clsConnect cn) { string sql = "SELECT * FROM Menu where menu_parent_id = @menu_parent_id ORDER BY menu_parent_id, menu_order, Menu_ID"; int Nparameter = 1; string[] name = new string[Nparameter]; name[0] = "@menu_parent_id"; object[] value = new object[Nparameter]; value[0] = Nparent.Value; try { foreach (DataRow row in cn.LoadData(sql, name, value, Nparameter).Rows) { TreeNode node_parent = new TreeNode(row["Menu_title"].ToString() + " (" + row["menu_order"].ToString() + ")", row["Menu_ID"].ToString()); node_parent.NavigateUrl = "menu.aspx?Menu_ID=" + row["Menu_ID"].ToString(); node_parent.ToolTip = row["menu_description"].ToString(); Nparent.ChildNodes.Add(node_parent); CreateNodeChild(node_parent, cn); } } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["add"] != null && !Request.QueryString["add"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1 chuyên mục [" + Request.QueryString["add"].ToString() + "] đã được thêm thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["save"] != null && !Request.QueryString["save"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>Thông tin chuyên mục [" + Request.QueryString["save"].ToString() + "] đã được cập nhật thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["delete"] != null && !Request.QueryString["delete"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1(nhiều) chuyên mục đã được xóa thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } clsConnect cn = new clsConnect(); DataTable dt = new DataTable(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; if (Request.QueryString["content_id"] != null && !Request.QueryString["content_id"].Equals("")) { string sqlText = "SELECT * FROM information A, service B, service_type C WHERE " + "A.service_id=B.service_id AND B.service_type_id=C.service_type_id AND information_id=?information_id"; Nparameter = 1; name[0] = "?information_id"; value[0] = Request.QueryString["content_id"].ToString(); dt = cn.LoadData(sqlText, name, value, Nparameter); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; //ddlService.SelectedValue = row["service_id"].ToString(); ddlServiceType.Text = row["service_type_id"].ToString(); //ddlServiceType_SelectedIndexChanged(sender, e); txtTitle.Text = row["tieude"].ToString(); txtSource.Text = row["nguontrichdan"].ToString(); txtContent.Value = row["noidung"].ToString(); lblHeadingText.Text = row["diengiai"].ToString(); //FileUpLoad1.FileName =row["file"].ToString(); btnSave.Visible = false; btnUpdate.Visible = true; btnDeleteAll.Visible = false; btnCancel.Visible = true; } } else { btnSave.Visible = true; btnCancel.Visible = true; } //loai chuyen muc ddlServiceType.DataSource = cn.LoadData("SELECT * FROM service_type"); ddlServiceType.DataBind(); ddlServiceType.Items.Insert(0, new ListItem("Chọn loại chuyên mục", "0")); /* #region phan quyen trang * try * { * sqlText = "select * from ctquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + * "WHERE quyen_ma=?quyen_ma AND menu_url=?menu"; * Nparameter = 2; * name[0] = "?quyen_ma"; * name[1] = "?menu"; * value[0] = Session["quyen_ma"]; * value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); * DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); * //kiem tra xem url nhap vao co chinh xac khong * if (dt3.Rows.Count == 0) * { * Response.Redirect("access_denied.aspx"); * } * } * catch (Exception) * { * } * #endregion*/ cn.close(); Page.SetFocus(ddlServiceType); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["add"] != null && !Request.QueryString["add"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1 thông tin [" + Request.QueryString["add"].ToString() + "] đã được thêm thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["save"] != null && !Request.QueryString["update"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>Thông tin thông tin [" + Request.QueryString["save"].ToString() + "] đã được cập nhật thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["delete"] != null && !Request.QueryString["delete"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1(nhiều) thông tin đã được xóa thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } clsConnect cn = new clsConnect(); DataTable dt = new DataTable(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sqlText = ""; if (Request.QueryString["info_id"] != null && !Request.QueryString["info_id"].Equals("")) { } else { btnCancel.Visible = true; } HienThiDS_Tieude(); //loai chuyen muc ddlDichvu.DataSource = cn.LoadData("SELECT * FROM loaidv"); ddlDichvu.DataBind(); ddlDichvu.Items.Insert(0, new ListItem("Chọn loại dich vụ", "0")); #region phan quyen trang try { sqlText = "select * from chitietquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + "WHERE quyen_ma=?quyen_ma AND menu_url=?menu"; Nparameter = 2; name[0] = "?quyen_ma"; name[1] = "?menu"; value[0] = Session["quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { } #endregion cn.close(); Page.SetFocus(ddlDichvu); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["add"] != null && !Request.QueryString["add"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1 tài khoản [" + Request.QueryString["add"].ToString() + "] đã được thêm thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["save"] != null && !Request.QueryString["save"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>Thông tin tài khoản [" + Request.QueryString["save"].ToString() + "] đã được cập nhật thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["delete"] != null && !Request.QueryString["delete"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1(nhiều) tài khoản đã được xóa thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } clsConnect cn = new clsConnect(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sqlText = "SELECT * FROM TaiKhoan DN " + "LEFT JOIN Quyen Q ON DN.quyen_ma=Q.quyen_ma " + "LEFT JOIN nhanvien NV ON DN.nhanvien_ma=NV.nhanvien_ma WHERE id!=0"; Nparameter = 0; if (Request.QueryString["id"] != null && !Request.QueryString["id"].Equals("")) { string sqlText1 = "SELECT * FROM TaiKhoan DN " + "LEFT JOIN quyen Q ON DN.quyen_ma=Q.quyen_ma " + "LEFT JOIN nhanvien NV ON DN.nhanvien_ma=NV.nhanvien_ma WHERE id!=0 AND id = @id;"; Nparameter = 1; name[0] = "@id"; value[0] = Request.QueryString["id"]; DataTable dt = cn.LoadData(sqlText1, name, value, Nparameter); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; txtTen.Text = row["username"].ToString(); txtMatKhau.Text = row["password"].ToString(); txtFrom.Text = row["tu_donvi"].ToString(); txtTo.Text = row["den_donvi"].ToString(); if (row["nhanvien_ma"].ToString() != "") { ddlNhanVien.Text = row["nhanvien_ma"].ToString(); } if (row["quyen_ma"].ToString() != "") { ddlQuyen.Text = row["quyen_ma"].ToString(); } btnInsert.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = false; btnCancel.Visible = true; } } else { btnInsert.Visible = true; } rptQuyen.DataSource = cn.LoadData(sqlText, name, value, Nparameter); rptQuyen.DataBind(); //Nhan vien sqlText = "SELECT * FROM nhanvien"; ddlNhanVien.DataSource = cn.LoadData(sqlText); ddlNhanVien.DataBind(); //quyen sqlText = "SELECT * FROM quyen"; ddlQuyen.DataSource = cn.LoadData(sqlText); ddlQuyen.DataBind(); #region phan quyen trang try { sqlText = "select * from chitietquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + "WHERE quyen_ma=@quyen_ma AND menu_url=@menu"; Nparameter = 2; name[0] = "@quyen_ma"; name[1] = "@menu"; value[0] = Session["quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { Response.Redirect("login.aspx"); } #endregion cn.close(); Page.SetFocus(txtTen); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["add"] != null && !Request.QueryString["add"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1 loại dịch vụ [" + Request.QueryString["add"].ToString() + "] đã được thêm thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["save"] != null && !Request.QueryString["save"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>Thông tin loại dịch vụ [" + Request.QueryString["save"].ToString() + "] đã được cập nhật thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["delete"] != null && !Request.QueryString["delete"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1(nhiều) loại dịch vụ đã được xóa thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } clsConnect cn = new clsConnect(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sqlText = "SELECT * FROM service_type "; rptProduct.DataSource = cn.LoadData(sqlText); rptProduct.DataBind(); if (Request.QueryString["service_type_id"] != null && !Request.QueryString["service_type_id"].Equals("")) { sqlText = "SELECT * FROM service_type WHERE service_type_id = @service_type_id;"; Nparameter = 1; name[0] = "@service_type_id"; value[0] = Request.QueryString["service_type_id"]; DataTable dt = cn.LoadData(sqlText, name, value, Nparameter); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; txtTen.Text = row["service_type_name"].ToString(); btnInsert.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = false; btnCancel.Visible = true; } } else { btnInsert.Visible = true; } // lay thong tin dang nhap sqlText = "SELECT * FROM taikhoan WHERE username=@username"; Nparameter = 1; name[0] = "@username"; value[0] = Session["username"].ToString(); DataTable dt_login = cn.LoadData(sqlText, name, value, Nparameter); if (dt_login.Rows.Count > 0) { DataRow row = dt_login.Rows[0]; quyen = row["quyen_ma"].ToString(); } #region phan quyen trang try { sqlText = "select * from chitietquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + "WHERE quyen_ma=@quyen_ma AND menu_url=@menu"; Nparameter = 2; name[0] = "@quyen_ma"; name[1] = "@menu"; value[0] = Session["quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { } #endregion cn.close(); Page.SetFocus(txtTen); }
void UploadTinGioithieu() { clsConnect cn = new clsConnect(); int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sql = ""; //upload file vao thu muc thuvien/taptin //try //{ if (FileUpLoad1.FileName != "") { string path = Server.MapPath("~/thuvien/taptin/") + FileUpLoad1.FileName; FileUpLoad1.SaveAs(path); Nparameter = 10; sql = "INSERT INTO information(service_id,title,date_post,human_post,source_link,content,heading_text,file,status_id,id)VALUES( " + "?service_id,?title,?date_post,?human_post,?source_link,?content,?heading_text,?file,?status_id,?id)"; name[0] = "?service_id"; name[1] = "?title"; name[2] = "?date_post"; name[3] = "?human_post"; name[4] = "?source_link"; name[5] = "?content"; name[6] = "?heading_text"; name[7] = "?file"; name[8] = "?status_id"; name[9] = "?id"; value[0] = ddlService.Text; value[1] = txtTitle.Text.Trim(); value[2] = DateTime.Now; value[3] = cn.LoadData("select nhanvien_ten FROM nhanvien WHERE nhanvien_ma=" + Session["nhanvien_ma"].ToString()).Rows[0][0].ToString(); value[4] = txtSource.Text.Trim(); value[5] = txtContent.Value; value[6] = lblHeadingText.Text.Trim(); value[7] = FileUpLoad1.FileName; //lay id chuyen muc, gan cho trang thai if (rbtChoise.SelectedValue == "0") { value[8] = "0"; } if (rbtChoise.SelectedValue == "1") { value[8] = "1"; } if (rbtChoise.SelectedValue == "2") { value[8] = "2"; } value[9] = ddlMon.SelectedIndex.ToString(); cn.UpdateData(sql, name, value, Nparameter); } else { Nparameter = 9; sql = "INSERT INTO information(service_id,title,date_post,human_post,source_link,content,heading_text,status_id,id)VALUES( " + "?service_id,?title,?date_post,?human_post,?source_link,?content,?heading_text,?status_id,?id)"; name[0] = "?service_id"; name[1] = "?title"; name[2] = "?date_post"; name[3] = "?human_post"; name[4] = "?source_link"; name[5] = "?content"; name[6] = "?heading_text"; name[7] = "?status_id"; name[8] = "?id"; value[0] = ddlService.Text; value[1] = txtTitle.Text.Trim(); value[2] = DateTime.Now; value[3] = cn.LoadData("select nhanvien_ten FROM nhanvien WHERE nhanvien_ma=" + Session["nhanvien_ma"].ToString()).Rows[0][0].ToString(); value[4] = txtSource.Text.Trim(); value[5] = txtContent.Value; value[6] = lblHeadingText.Text.Trim(); if (rbtChoise.SelectedValue == "0") { value[7] = "0"; } if (rbtChoise.SelectedValue == "1") { value[7] = "1"; } if (rbtChoise.SelectedValue == "2") { value[7] = "2"; } value[8] = ddlMon.SelectedIndex.ToString(); cn.UpdateData(sql, name, value, Nparameter); } cn.close(); }
protected void btnUpdate_Click1(object sender, EventArgs e) { if (ddlServiceType.Text != "") { clsConnect cn = new clsConnect(); int Nparameter = 11; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; string sql = ""; //upload file vao thu muc thuvien/taptin //try //{ if (FileUpLoad1.FileName != "") { string path = Server.MapPath("~/thuvien/taptin/") + FileUpLoad1.FileName; FileUpLoad1.SaveAs(path); Nparameter = 11; sql = "UPDATE information SET service_id=?service_id,title=?title,date_post=?date_post,human_post=?human_post,source_link=?source_link, " + "content=?content,heading_text=?heading_text,file=?file,status_id=?status_id , id=?id " + "WHERE information_id=?information_id"; name[0] = "?service_id"; name[1] = "?title"; name[2] = "?date_post"; name[3] = "?human_post"; name[4] = "?source_link"; name[5] = "?content"; name[6] = "?heading_text"; name[7] = "?file"; name[8] = "?status_id"; name[9] = "?information_id"; name[10] = "?id"; value[0] = ddlService.Text; value[1] = txtTitle.Text.Trim(); value[2] = DateTime.Now; value[3] = cn.LoadData("select nhanvien_ten FROM nhanvien WHERE nhanvien_ma=" + Session["nhanvien_ma"].ToString()).Rows[0][0].ToString(); value[4] = txtSource.Text.Trim(); value[5] = txtContent.Value; value[6] = lblHeadingText.Text.Trim(); value[7] = FileUpLoad1.FileName; //lay id chuyen muc, gan cho trang thai if (rbtChoise.SelectedValue == "0") { value[8] = "0"; } if (rbtChoise.SelectedValue == "1") { value[8] = "1"; } if (rbtChoise.SelectedValue == "2") { value[8] = "2"; } value[9] = Request.QueryString["content_id"]; value[10] = ddlMon.SelectedIndex.ToString(); cn.UpdateData(sql, name, value, Nparameter); } else { Nparameter = 9; sql = "UPDATE information SET service_id=?service_id,title=?title,date_post=?date_post,human_post=?human_post,source_link=?source_link, " + "content=?content,heading_text=?heading_text,status_id=?status_id " + "WHERE information_id=?information_id"; name[0] = "?service_id"; name[1] = "?title"; name[2] = "?date_post"; name[3] = "?human_post"; name[4] = "?source_link"; name[5] = "?content"; name[6] = "?heading_text"; name[7] = "?status_id"; name[8] = "?information_id"; value[0] = ddlService.Text; value[1] = txtTitle.Text.Trim(); value[2] = DateTime.Now; value[3] = cn.LoadData("select nhanvien_ten FROM nhanvien WHERE nhanvien_ma=" + Session["nhanvien_ma"].ToString()).Rows[0][0].ToString(); value[4] = txtSource.Text.Trim(); value[5] = txtContent.Value; value[6] = lblHeadingText.Text.Trim(); //lay id chuyen muc, gan cho trang thai if (rbtChoise.SelectedValue == "0") { value[7] = "0"; } if (rbtChoise.SelectedValue == "1") { value[7] = "1"; } if (rbtChoise.SelectedValue == "2") { value[7] = "2"; } value[8] = Request.QueryString["content_id"]; cn.UpdateData(sql, name, value, Nparameter); } cn.close(); Response.Redirect("web_send.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } cls_TinTuc tintuc = new cls_TinTuc(); if (Request.QueryString["add"] != null && !Request.QueryString["add"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1 chuyên mục [" + Request.QueryString["add"].ToString() + "] đã được thêm thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["save"] != null && !Request.QueryString["save"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>Thông tin chuyên mục [" + Request.QueryString["save"].ToString() + "] đã được cập nhật thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } if (Request.QueryString["delete"] != null && !Request.QueryString["delete"].Equals("")) { lblMessageStatus.Text = "<dl id=\"system-message\"><dd class=\"message message fade\"><ul><li>1(nhiều) chuyên mục đã được xóa thành công</li></ul></dd></dl>"; lblMessageStatus.Visible = true; } DataTable dt = new DataTable(); if (Request.QueryString["tieude"] != null && !Request.QueryString["tieude"].Equals("")) { tintuc.MaTinTuc = Convert.ToInt32(Request.QueryString["tieude"]); dt = tintuc.TinTucListGetID(); } else { //sqlText += "ORDER BY intuc_id desc"; dt = tintuc.TinTucList(); } string keyword = Request.QueryString["tieude"]; string sqlText = ""; int Nparameter = 10; string[] name = new string[Nparameter]; object[] value = new object[Nparameter]; PagedDataSource objPage = displayResult(dt, keyword); rptQuyen.DataSource = dt; rptQuyen.DataBind(); TitleList(); clsConnect cn = new clsConnect(); #region phan quyen trang try { sqlText = "select * from chitietquyen CT JOIN menu M ON CT.menu_id=M.menu_id " + "WHERE quyen_ma=?quyen_ma AND menu_url=?menu"; Nparameter = 2; name[0] = "?quyen_ma"; name[1] = "?menu"; value[0] = Session["quyen_ma"]; value[1] = Request.Url.Segments[Request.Url.Segments.Length - 1].ToString(); DataTable dt3 = cn.LoadData(sqlText, name, value, Nparameter); //kiem tra xem url nhap vao co chinh xac khong if (dt3.Rows.Count == 0) { Response.Redirect("access_denied.aspx"); } } catch (Exception) { } #endregion Page.SetFocus(ddlTitle); }