protected void Page_Load(object sender, EventArgs e) { txtid.Text = tm.taomangaunhien("GH"); if (!IsPostBack) { //load noi dung de xuat de tai txtmadetai.Text = Session["DungThucHien"].ToString(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("THUYETMINHDETAI_SELECT_ROW", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@TMDT_ID", txtmadetai.Text); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { txttendetai.Text = reader.GetString(2); } conn.Close(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (ViewState["stateThanhVien"] != null) { thanhviens = (List <thanhvien>)ViewState["stateThanhVien"]; } else { thanhviens = new List <thanhvien>(); } GridView1.DataSource = thanhviens; GridView1.DataBind(); if (!IsPostBack) { DateTime ngaybatdau = new DateTime(); DateTime ngayketthuc = new DateTime();; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("THOIGIANDANGKY_GETTIME1", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; //Truyen bien vao cau lenh conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ngaybatdau = reader.GetDateTime(1); ngayketthuc = reader.GetDateTime(2); } conn.Close(); } if (DateTime.Now < ngaybatdau || DateTime.Now > ngayketthuc) { Response.Redirect("baoloithoigiandangky.aspx"); } thanhviens = new List <thanhvien>(); taoma tm = new taoma(); txtMaDeTai.Text = tm.taomangaunhien("DX"); thanhvien tv1 = new thanhvien(); tv1.MaNV = ((dangnhapnguoidung)Session["dangnhap"]).cb_id; tv1.Hoten = ((dangnhapnguoidung)Session["dangnhap"]).cb_hoten; tv1.Vitri = "Chủ nhiệm đề tài"; tv1.Email = ((dangnhapnguoidung)Session["dangnhap"]).cb_email; thanhviens.Add(tv1); ViewState["stateThanhVien"] = thanhviens; GridView1.DataSource = thanhviens; GridView1.DataBind(); } } }
protected void btnluu_Click(object sender, EventArgs e) { //Chuan bi du lieu insert string chuoiLVNC = ""; foreach (ListItem item in chkLVNC.Items) { if (item.Selected) { if (chuoiLVNC.Length > 0) { // co dau ; trong cac chuoi chuoiLVNC = chuoiLVNC + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoiLVNC = chuoiLVNC + item.Value.ToString(); } } } //Chuan bi du lieu insert string chuoiLHNC = ""; foreach (ListItem item in chkLHNC.Items) { if (item.Selected) { if (chuoiLHNC.Length > 0) { // co dau ; trong cac chuoi chuoiLHNC = chuoiLHNC + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoiLHNC = chuoiLHNC + item.Value.ToString(); } } } //Chuan bi du lieu insert string chuoispkh = ""; foreach (ListItem item in chkspkh.Items) { if (item.Selected) { if (chuoispkh.Length > 0) { // co dau ; trong cac chuoi chuoispkh = chuoispkh + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoispkh = chuoispkh + item.Value.ToString(); } } } //Chuan bi du lieu insert string chuoispdt = ""; foreach (ListItem item in chkspdt.Items) { if (item.Selected) { if (chuoispdt.Length > 0) { // co dau ; trong cac chuoi chuoispdt = chuoispdt + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoispdt = chuoispdt + item.Value.ToString(); } } } //Chuan bi du lieu insert string chuoispud = ""; foreach (ListItem item in chkspud.Items) { if (item.Selected) { if (chuoispud.Length > 0) { // co dau ; trong cac chuoi chuoispud = chuoispud + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoispud = chuoispud + item.Value.ToString(); } } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("THUYETMINHDETAI_INSERT_FROM_TMDT", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@TMDT_ID", txtMaThuyetMinh.Text); cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.Parameters.AddWithValue("@TMDT_TENDETAI", txtTenDeTai.Text); cmd.Parameters.AddWithValue("@TMDT_LVNC", chuoiLVNC); cmd.Parameters.AddWithValue("@TMDT_LHNC", chuoiLHNC); cmd.Parameters.AddWithValue("@TMDT_TGTH", txtTGThucHien.Text); cmd.Parameters.AddWithValue("@TMDT_CQCT", txtCQCTDT.Text); cmd.Parameters.AddWithValue("@TMDT_CQCT_SDT", txtSDTCQCTDT.Text); cmd.Parameters.AddWithValue("@TMDT_CQCT_DC", txtDCCQCTDT.Text); cmd.Parameters.AddWithValue("@TMDT_DVTH", txtDVTH.Text); cmd.Parameters.AddWithValue("@TMDT_DVTH_SDT", txtSDTDVTH.Text); cmd.Parameters.AddWithValue("@TMDT_DVTH_DC", txtDCTDVTH.Text); cmd.Parameters.AddWithValue("@TMDT_NCTRONGNUOC", ckeTrongNuoc.Text); cmd.Parameters.AddWithValue("@TMDT_NCNGOAINUOC", ckeNgoaiNuoc.Text); cmd.Parameters.AddWithValue("@TMDT_TINHCAPTHIET", ckeTinhCapThiet.Text); cmd.Parameters.AddWithValue("@TMDT_MUCTIEU", ckeMucTieu.Text); cmd.Parameters.AddWithValue("@TMDT_NOIDUNG", ckeNoiDung.Text); cmd.Parameters.AddWithValue("@TMDT_SANPHAMKH", chuoispkh); cmd.Parameters.AddWithValue("@TMDT_SANPHAMDT", chuoispdt); cmd.Parameters.AddWithValue("@TMDT_SANPHAMUD", chuoispud); cmd.Parameters.AddWithValue("@TMDT_SANPHAMKHAC", txtSanPhamKhac.Text); cmd.Parameters.AddWithValue("@TMDT_HIEUQUA", ckeHieuQua.Text); cmd.Parameters.AddWithValue("@TMDT_DOITUONGNGHIENCUU", ckeDoiTuongNghienCuu.Text); cmd.Parameters.AddWithValue("@TMDT_PHAMVINGHIENCUU", ckephamvinghiencuu.Text); cmd.Parameters.AddWithValue("@TMDT_PHUONGTHUC_CHUYENGIAO", ckePTChuyenGiao.Text); cmd.Parameters.AddWithValue("@TMDT_CACHTIEPCAN", ckecachtiepcan.Text); cmd.Parameters.AddWithValue("@TMDT_PHUONGPHAPNGHIENCUU", ckephuongphapnghiencuu.Text); cmd.Parameters.AddWithValue("@TMDT_GIONCKH", txtGioNCKH.Text); cmd.Parameters.AddWithValue("@TMDT_KINHPHI", txtKinhPhi.Text); cmd.Parameters.AddWithValue("@TMDT_NGANSACHTRUONG", txtNganSachTruong.Text); cmd.Parameters.AddWithValue("@TMDT_CACNGUON_KPKHAC", txtCacNguonKPKhac.Text); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_DELETE_TV", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; conn.Open(); //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.ExecuteNonQuery(); conn.Close(); } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_INSERT_TV", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; conn.Open(); //Truyen bien vao cau lenh foreach (thanhvien tv in thanhviens) { taoma tm = new taoma(); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@DKDTTV_ID", tm.taomangaunhien("TV")); cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.Parameters.AddWithValue("@DKDTTV_MANV", tv.MaNV); cmd.Parameters.AddWithValue("@DKDTTV_HOTEN", tv.Hoten); cmd.Parameters.AddWithValue("@DKDTTV_VITRI", tv.Vitri); cmd.Parameters.AddWithValue("@DKDTTV_EMAIL", tv.Email); cmd.ExecuteNonQuery(); } conn.Close(); } } }
protected void btnthem_Click(object sender, EventArgs e) { TaoMoiAnButton(); ResetNoiDung(); txtHVID.Text = tm.taomangaunhien("HV"); }
protected void btnDuyet_Click(object sender, EventArgs e) { // tao du lieu thuyet minh de tai DataRow rowSelected = ((SqlDataSource1.Select(DataSourceSelectArguments.Empty) as DataView).ToTable()).Rows[vitri]; //Gan noi dung den tung text box txtid.Text = rowSelected.ItemArray[0].ToString(); txtTenDetai.Text = rowSelected.ItemArray[1].ToString(); //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("THUYETMINHDETAI_INSERT_FROM_TMDT", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; //Truyen bien vao cau lenh taoma tm = new taoma(); cmd.Parameters.AddWithValue("@TMDT_ID", tm.taomangaunhien("TM")); cmd.Parameters.AddWithValue("@DKDT_ID", txtid.Text); cmd.Parameters.AddWithValue("@TMDT_TENDETAI", txtTenDetai.Text); cmd.Parameters.AddWithValue("@TMDT_LVNC", rowSelected.ItemArray[2].ToString()); cmd.Parameters.AddWithValue("@TMDT_TINHCAPTHIET", rowSelected.ItemArray[3].ToString()); cmd.Parameters.AddWithValue("@TMDT_MUCTIEU", rowSelected.ItemArray[4].ToString()); cmd.Parameters.AddWithValue("@TMDT_NOIDUNG", rowSelected.ItemArray[5].ToString()); cmd.Parameters.AddWithValue("@TMDT_HIEUQUA", rowSelected.ItemArray[6].ToString()); cmd.Parameters.AddWithValue("@TMDT_GIONCKH", rowSelected.ItemArray[8].ToString()); cmd.Parameters.AddWithValue("@TMDT_KINHPHI", rowSelected.ItemArray[9].ToString()); cmd.Parameters.AddWithValue("@TMDT_NGANSACHTRUONG", rowSelected.ItemArray[10].ToString()); cmd.Parameters.AddWithValue("@TMDT_CACNGUON_KPKHAC", rowSelected.ItemArray[11].ToString()); cmd.Parameters.AddWithValue("@TMDT_TGTH", rowSelected.ItemArray[14].ToString()); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_DUYET", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; conn.Open(); //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@DKDT_ID", txtid.Text); //cmd.Parameters.AddWithValue("@CHUCNANG", '1'); cmd.ExecuteNonQuery(); conn.Close(); } } GridView1.DataBind(); txtid.Text = ""; txtTenDetai.Text = ""; btnChiTiet.Visible = false; btnDuyet.Visible = false; btnHuyNop.Visible = false; }
protected void btnluu_Click(object sender, EventArgs e) { //Chuan bi du lieu insert string chuoiLVNC = ""; foreach (ListItem item in chkLVNC.Items) { if (item.Selected) { if (chuoiLVNC.Length > 0) { // co dau ; trong cac chuoi chuoiLVNC = chuoiLVNC + ";" + item.Value.ToString(); } else { // khong co dau ; o dau cau chuoiLVNC = chuoiLVNC + item.Value.ToString(); } } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_INSERT", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.Parameters.AddWithValue("@DKDT_TENDETAI", txtTenDeTai.Text); cmd.Parameters.AddWithValue("@DKDT_LVNC", chuoiLVNC); cmd.Parameters.AddWithValue("@DKDT_TINHCAPTHIET", ckeTinhCapThiet.Text); cmd.Parameters.AddWithValue("@DKDT_MUCTIEU", ckeMucTieu.Text); cmd.Parameters.AddWithValue("@DKDT_NOIDUNG", ckeNoiDung.Text); cmd.Parameters.AddWithValue("@DKDT_HIEUQUA", ckeHieuQua.Text); cmd.Parameters.AddWithValue("@DKDT_SANPHAM", ckeSanPham.Text); cmd.Parameters.AddWithValue("@DKDT_GIONCKH", txtGioNCKH.Text); cmd.Parameters.AddWithValue("@DKDT_KINHPHI", txtKinhPhi.Text); cmd.Parameters.AddWithValue("@DKDT_NGANSACHTRUONG", txtNganSachTruong.Text); cmd.Parameters.AddWithValue("@DKDT_CACNGUON_KPKHAC", txtCacNguonKPKhac.Text); cmd.Parameters.AddWithValue("@DKDT_THOIGIANTH", txtThoiGianThucHien.Text); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_DELETE_TV", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; conn.Open(); //Truyen bien vao cau lenh cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.ExecuteNonQuery(); conn.Close(); } } //Tao ket noi CSDL using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString())) { // Goi cau lenh procedure using (SqlCommand cmd = new SqlCommand("DANGKYDETAI_INSERT_TV", conn)) { //Gan keu truy van la Procedure cmd.CommandType = CommandType.StoredProcedure; conn.Open(); //Truyen bien vao cau lenh foreach (thanhvien tv in thanhviens) { taoma tm = new taoma(); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@DKDTTV_ID", tm.taomangaunhien("TV")); cmd.Parameters.AddWithValue("@DKDT_ID", txtMaDeTai.Text); cmd.Parameters.AddWithValue("@DKDTTV_MANV", tv.MaNV); cmd.Parameters.AddWithValue("@DKDTTV_HOTEN", tv.Hoten); cmd.Parameters.AddWithValue("@DKDTTV_VITRI", tv.Vitri); cmd.Parameters.AddWithValue("@DKDTTV_EMAIL", tv.Email); cmd.ExecuteNonQuery(); } conn.Close(); } } }