private void rptDNCNBind()
        {
            DAO.clsNhapLieuDAO NLDAO   = new DAO.clsNhapLieuDAO();
            DataTable          tblDNCN = new DataTable();

            tblDNCN            = NLDAO.selectNhapLieu_DNCN(Convert.ToInt32(Request.QueryString["ID"]));
            rptDNCN.DataSource = tblDNCN;
            rptDNCN.DataBind();
        }
Exemple #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>");
            }
        }
Exemple #3
0
 protected void rptThiNghiem_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "btn_Sua")
     {
         Label id            = e.Item.FindControl("mazic_lblID") as Label;
         Label loaithinghiem = e.Item.FindControl("mazic_lblLoaiThiNghiem") as Label;
         Response.Redirect("SuaThiNghiem.aspx?ID=" + id.Text + "&ID_LoaiThiNghiem=" + loaithinghiem.Text);
     }
     if (e.CommandName == "btn_Khoa")
     {
         Label id       = e.Item.FindControl("mazic_lblID") as Label;
         Label quyensua = e.Item.FindControl("mazic_lblQuyenSua") as Label;
         int   quyen    = Convert.ToInt32(quyensua.Text) == 1 ? 0 : 1;
         DAO.clsThiNghiemDAO.updateQuyen(Convert.ToInt32(id.Text), quyen);
         rptThiNghiemBind();
     }
     if (e.CommandName == "btn_Xoa")
     {
         Label id = e.Item.FindControl("mazic_lblID") as Label;
         DAO.clsThiNghiemDAO.updateTrangThai(Convert.ToInt32(id.Text), 0);
         DAO.clsThiNghiemDAO TNDAO = new DAO.clsThiNghiemDAO();
         Global.numbMaxRow_ThiNghiem = TNDAO.getNumbMaxPage();
         rptThiNghiemBind();
     }
     if (e.CommandName == "btn_Copy")
     {
         Label idCopy              = e.Item.FindControl("mazic_lblID") as Label;
         Label loaithinghiem       = e.Item.FindControl("mazic_lblLoaiThiNghiem") as Label;
         DAO.clsThiNghiemDAO TNDAO = new DAO.clsThiNghiemDAO();
         int ID = TNDAO.lastID() + 1;
         if (DAO.clsThiNghiemDAO.insertCopy(ID, Convert.ToInt32(idCopy.Text), Session["TenHienThi"].ToString()))
         {
             // Thêm list NhapLieu
             DAO.clsNhapLieuDAO NLDAO = new DAO.clsNhapLieuDAO();
             NLDAO.insertNhapLieu(ID, Convert.ToInt32(loaithinghiem.Text));
             //
             Global.numbMaxRow_ThiNghiem = TNDAO.getNumbMaxPage();
             rptThiNghiemBind();
         }
         Global.numbMaxRow_ThiNghiem = TNDAO.getNumbMaxPage();
         rptThiNghiemBind();
     }
     if (e.CommandName == "btn_XuatBaoCao")
     {
         DAO.clsThiNghiemDAO.updateBaoCao(Convert.ToInt32(e.CommandArgument));
         rptThiNghiemBind();
     }
 }
 protected void rptDNCN_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "CapNhat")
     {
         RepeaterItem       t            = e.Item;
         Label              lblIDDacTinh = t.FindControl("lblID_DacTinh") as Label;
         TextBox            txtNoiDung   = t.FindControl("txtNoiDung") as TextBox;
         int                ID_ThiNghiem = Convert.ToInt32(lblID_ThiNghiem.Text);
         int                ID_DacTinh   = Convert.ToInt32(lblIDDacTinh.Text);
         string             NoiDung      = txtNoiDung.Text;
         string             ND           = Session["TenHienThi"].ToString();
         DAO.clsNhapLieuDAO NLDAO        = new DAO.clsNhapLieuDAO();
         NLDAO.updateNhapLieu_DNCN(ID_ThiNghiem, ID_DacTinh, NoiDung, ND);
         rptDNCNBind(ID_ThiNghiem);
     }
 }
        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();
            }
        }