protected void rptThiNghiem_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DAO.clsPhanQuyenDAO PQDAO  = new DAO.clsPhanQuyenDAO();
            DataRow             tbl_ND = PQDAO.getQuyen(Convert.ToInt32(Session["ID"]));

            if (tbl_ND["VaiTro"] == null)
            {
                Response.Redirect("index.aspx");
                return;
            }
            if (tbl_ND["VaiTro"].ToString() != "1")
            {
                foreach (RepeaterItem item in ((Repeater)sender).Items)
                {
                    Button    btnXoa           = item.FindControl("btn_XoaContent") as Button;
                    Button    btnXoa1          = item.FindControl("btn_Xoa") as Button;
                    Button    btnSua           = item.FindControl("btn_Sua") as Button;
                    Button    btnKhoa          = item.FindControl("btn_Khoa") as Button;
                    Label     lblQuyenSua      = item.FindControl("mazic_lblQuyenSua") as Label;
                    HyperLink hyper_NhapLieu   = item.FindControl("hyperNhapLieu") as HyperLink;
                    HyperLink hyper_XuatBaoCao = item.FindControl("hyperXuatBaoCao") as HyperLink;
                    btnKhoa.Visible = false;
                    btnXoa.Visible  = false;
                    btnXoa1.Visible = false;
                    if (lblQuyenSua.Text == "0")
                    {
                        btnSua.Visible         = false;
                        hyper_NhapLieu.Visible = false;
                    }
                    if (tbl_ND["SuaThiNghiem"].ToString() == "0")
                    {
                        btnSua.Visible = false;
                    }
                    if (tbl_ND["XuatBaoCao"].ToString() == "0")
                    {
                        hyper_XuatBaoCao.Visible = false;
                    }
                }
            }
            if (tbl_ND["VaiTro"].ToString() == "1")
            {
                foreach (RepeaterItem item in ((Repeater)sender).Items)
                {
                    Button btnKhoa     = item.FindControl("btn_Khoa") as Button;
                    Label  lblQuyenSua = item.FindControl("mazic_lblQuyenSua") as Label;
                    if (lblQuyenSua.Text == "1")
                    {
                        btnKhoa.Text     = "";
                        btnKhoa.CssClass = "btn btn-outline-primary font-weight-bold fa";
                    }
                    if (lblQuyenSua.Text == "0")
                    {
                        btnKhoa.Text     = "";
                        btnKhoa.CssClass = "btn btn-outline-secondary font-weight-bold fa";
                    }
                }
            }
        }
Beispiel #2
0
        protected void btnTaoThiNghiem_Click(object sender, EventArgs e)
        {
            DAO.clsPhanQuyenDAO PQDAO  = new DAO.clsPhanQuyenDAO();
            DataRow             tbl_ND = PQDAO.getQuyen(Convert.ToInt32(Session["ID"]));

            if (tbl_ND["VaiTro"].ToString() == "1" || tbl_ND["TaoThiNghiem"].ToString() == "1")
            {
                DTO.clsThiNghiemDTO TN = new DTO.clsThiNghiemDTO();
                int flag = 0;
                TN.XuatXu       = txtXuatXu.Text;
                TN.SearchXuatXu = DAO.clsString.convertToUnSign3(txtXuatXu.Text);
                DateTime a, b, c;
                if (DateTime.TryParseExact(txtNgayLayMau.Text, "d/M/yyyy", null, DateTimeStyles.None, out a) &&
                    DateTime.TryParseExact(txtNgayNhanMau.Text, "d/M/yyyy", null, DateTimeStyles.None, out b) &&
                    DateTime.TryParseExact(txtNgayThuMau.Text, "d/M/yyyy", null, DateTimeStyles.None, out c))
                {
                    TN.NgayLayMau  = a;
                    TN.NgayNhanMau = b;
                    TN.NgayThuMau  = c;
                }
                else
                {
                    flag = 1;
                }
                TN.LyDoThiNghiem    = txtLyDoThiNghiem.Text;
                TN.PhuTrachLayMau   = txtPhuTrachLayMau.Text;
                TN.GhiChu           = txtGhiChu.Text;
                TN.ID_LoaiThiNghiem = Convert.ToInt32(ddlLoaiThiNghiem.SelectedValue);
                TN.Created_at       = DateTime.Now;
                TN.Created_by       = Session["TenHienThi"].ToString();
                if (flag == 0)
                {
                    DAO.clsThiNghiemDAO TNDAO = new DAO.clsThiNghiemDAO();
                    TN.ID = TNDAO.lastID() + 1;
                    if (DAO.clsThiNghiemDAO.addThiNghiem(TN))
                    {
                        // Thêm list NhapLieu
                        DAO.clsNhapLieuDAO NLDAO = new DAO.clsNhapLieuDAO();
                        NLDAO.insertNhapLieu(TN.ID, TN.ID_LoaiThiNghiem);
                        //
                        Response.Write("<script>alert(\"Thêm Thành Công\");</script>");
                        Global.numbMaxRow_ThiNghiem = TNDAO.getNumbMaxPage();
                        rptThiNghiemBind();
                    }
                }
                else
                {
                    Response.Write("<script>alert(\"Sai Định Dạng\");</script>");
                }
            }
            else
            {
                Response.Write("<script>alert(\"Bạn không có quyền\");</script>");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["ID"] == null)
     {
         Server.Transfer("Login.aspx", true);
         return;
     }
     if (!Page.IsPostBack)
     {
         DAO.clsPhanQuyenDAO PQDAO = new DAO.clsPhanQuyenDAO();
         DataRow             t     = PQDAO.getQuyen(Convert.ToInt32(Session["ID"]));
         txtTenHienThi.Text = Session["TenHienThi"].ToString();
         txtSDT.Text        = t["SDT"].ToString();
     }
 }
        private void rptDNCNBind(int id)
        {
            DAO.clsThiNghiemDAO TNDAO = new DAO.clsThiNghiemDAO();
            DataRow             TN    = TNDAO.getThiNghiemByID(id);

            if (TN["QuyenSua"].ToString() == "0" && Session["VaiTro"].ToString() != "1")
            {
                Server.Transfer("index.aspx");
                return;
            }
            else
            {
                lblID_ThiNghiem.Text = id.ToString();
                if (TN["ID_LoaiThiNghiem"].ToString() == "1")
                {
                    lblTenThiNghiem.Text = "Dầu cách điện";
                }
                else
                {
                    lblTenThiNghiem.Text = "Dầu nhớt công nghiệp";
                }
                lblXuatXu.Text = TN["XuatXu"].ToString();
                DAO.clsPhanQuyenDAO PQDAO   = new DAO.clsPhanQuyenDAO();
                DataRow             tblND   = PQDAO.getQuyen(Convert.ToInt32(Session["ID"]));
                DAO.clsNhapLieuDAO  NLDAO   = new DAO.clsNhapLieuDAO();
                DataTable           tblDNCN = new DataTable();
                tblDNCN = NLDAO.selectNhapLieu_DNCN(id);
                DataView view = new DataView(tblDNCN);
                if (tblND["VaiTro"].ToString() != "1")
                {
                    string   filter = "ID_DacTinh IN (0,";
                    string[] arr    = tblND["NhapLieu_DNCN"].ToString().Split(' ');
                    for (int i = 0; i < arr.Length - 1; i++)
                    {
                        filter = filter + arr[i] + ",";
                    }
                    filter        += ")";
                    view.RowFilter = filter;
                }
                rptDNCN.DataSource = view;
                rptDNCN.DataBind();
            }
        }
        private void Bind()
        {
            // rptPhanQuyenBind
            lblID_NguoiDung.Text = Request.QueryString["ID"].ToString();
            DAO.clsPhanQuyenDAO PQDAO = new DAO.clsPhanQuyenDAO();
            DataRow             tblND = PQDAO.getQuyen(Convert.ToInt32(lblID_NguoiDung.Text));

            lblTenNV1.InnerText     = "Phân quyền nhân viên " + tblND["TenHienThi"];
            lblTenNV2.InnerText     = "Tên tài khoản: " + tblND["TaiKhoan"];
            chkTaoThiNghiem.Checked = Convert.ToBoolean(Convert.ToInt32(tblND["TaoThiNghiem"]));
            chkSuaThiNghiem.Checked = Convert.ToBoolean(Convert.ToInt32(tblND["SuaThiNghiem"]));
            chkXuatBaoCao.Checked   = Convert.ToBoolean(Convert.ToInt32(tblND["XuatBaoCao"]));
            DataTable listLTN = DAO.clsLoaiThiNghiemDAO.getListLoaiThiNghiem();

            rptPhanQuyen.DataSource = listLTN;
            rptPhanQuyen.DataBind();
            DataTable listThiNghiem = DAO.clsPhanQuyenDAO.getList(Convert.ToInt32(lblID_NguoiDung.Text));

            foreach (RepeaterItem item in rptPhanQuyen.Items)
            {
                Repeater rptThiNghiem     = item.FindControl("rptThiNghiem") as Repeater;
                Label    ID_LoaiThiNghiem = item.FindControl("lblID_LoaiThiNghiem") as Label;
                DataView tn = new DataView(listThiNghiem);
                tn.RowFilter            = "ID_LoaiThiNghiem=" + Convert.ToInt32(ID_LoaiThiNghiem.Text);
                tn.Sort                 = "ChiSo ASC";
                rptThiNghiem.DataSource = tn;
                rptThiNghiem.DataBind();
            }

            // ddlVaiTroBind
            DataTable t = DAO.clsVaiTroDAO.getList();

            ddlVaiTro.DataSource     = t;
            ddlVaiTro.DataTextField  = "Ten";
            ddlVaiTro.DataValueField = "VaiTro";
            ddlVaiTro.SelectedValue  = tblND["VaiTro"].ToString();
            ddlVaiTro.DataBind();
        }