//them protected void submit_create_Click(object sender, EventArgs e) { //kiem tra trong if (txtTenNoiNgoaiThat.Text == "" || txtMoTaNgan.Text == "" || txtChiTiet.Text == "") { //ClientScript.RegisterStartupScript(this.GetType(), "vanh", "blank()", true); Response.Write("<script>Tất cả các trường các trường cần điền đầy đủ!</script>"); return; } //them DTO.NoiNgoaiThat nnt = new DTO.NoiNgoaiThat(); nnt.TenNoiNgoaiThat = txtTenNoiNgoaiThat.Text; nnt.MoTa = txtMoTaNgan.Text; nnt.ChiTiet = txtChiTiet.Text; nnt.status = checkStatus_create.Checked; nnt.created_at = DateTime.Now; nnt.DanhMucNoiNgoaiThat_Id = Int32.Parse(ddrDanhMuc.SelectedValue); string path = Server.MapPath("../assets/images/NoiNgoaiThat/"); FileUploadImage.SaveAs(path + FileUploadImage.FileName); nnt.Anh = FileUploadImage.FileName; Image2.ImageUrl = path; obj.create(nnt); //load list Response.Redirect(Request.Url.ToString()); }
public void create(DTO.NoiNgoaiThat c) { string sql = "insert tbl_NoiNgoaiThat values(N'" + c.TenNoiNgoaiThat + "' , '" + "~/assets/images/NoiNgoaiThat/" + c.Anh + "', N'" + c.MoTa + "', N'" + c.ChiTiet + "', '" + c.status + "', '" + c.created_at + "', '" + c.DanhMucNoiNgoaiThat_Id + "')"; obj.ExecuteNonQuery(sql); }
protected void submit_edit_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["Id"]); DTO.NoiNgoaiThat nnt = new DTO.NoiNgoaiThat(); nnt.TenNoiNgoaiThat = txtSuaTenNoiThat.Text; nnt.MoTa = txtSuaMoTa.Text; nnt.ChiTiet = txtSuaChiTiet.Text; nnt.status = ckSuaTrangThai.Checked; nnt.created_at = DateTime.Now; nnt.DanhMucNoiNgoaiThat_Id1 = Int32.Parse(drSuaDanhMuc.SelectedValue); //string path = Server.MapPath("../assets/images/NoiNgoaiThat/"); //SuaFileUpload.SaveAs(path + SuaFileUpload.FileName); //nnt.Anh = SuaFileUpload.FileName; if (SuaFileUpload.HasFile) { string path = Server.MapPath("../assets/images/NoiNgoaiThat/"); SuaFileUpload.SaveAs(path + SuaFileUpload.FileName); nnt.Anh = SuaFileUpload.FileName; string fileName = "~/assets/images/NoiNgoaiThat/" + SuaFileUpload.FileName; Image1.ImageUrl = fileName; } else { nnt.Anh = txtlink.Value; } obj.update(nnt, id); Response.Redirect("NoiNgoaiThat.aspx"); }
public void update(DTO.NoiNgoaiThat c, int id) { string sql = "update tbl_NoiNgoaiThat set TenNoiNgoaiThat = N'" + c.TenNoiNgoaiThat + "' , Anh = '~/assets/images/NoiNgoaiThat/" + c.Anh + "', MoTa = N'" + c.MoTa + "', ChiTiet = N'" + c.ChiTiet + "', status = '" + c.status + "',Created_at= '" + c.created_at + "',DanhMucNoiNgoaiThat_Id= '" + c.DanhMucNoiNgoaiThat_Id + "' where id = '" + id + "'"; obj.ExecuteNonQuery(sql); }