예제 #1
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>");
            }
        }
예제 #2
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();
     }
 }