protected void btnSuaThiNghiem_Click(object sender, EventArgs e) { DTO.clsThiNghiemDTO TN = new DTO.clsThiNghiemDTO(); TN.XuatXu = txtXuatXu.Text; TN.SearchXuatXu = DAO.clsString.convertToUnSign3(txtXuatXu.Text); int flag = 0; 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 = Convert.ToInt32(Request.QueryString["ID"]); TN.Updated_by = Session["TenHienThi"].ToString(); TN.Copy = 0; if (flag == 0 && DAO.clsThiNghiemDAO.updateThiNghiemByID(TN)) { Response.Write("<script>alert(\"Cập Nhật Thành Công\");</script>"); } else { Response.Write("<script>alert(\"Sai Định Dạng\");</script>"); } }
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>"); } }