protected void btnSave_Click(object sender, EventArgs e) { if (Request.QueryString["action"] != null) { clsTypeDetail about = new clsTypeDetail(); about.Stt = Convert.ToInt32(this.txtSTT.Text); about.TieuDe = this.txtTieuDe.Text; if (Request.QueryString["action"].ToString().Equals("new")) { obj.Insert(about); this.txtTieuDe.Text = ""; this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "show", "<script type='text/javascript'>alert('Thêm mới thành công')</script>"); } else { if (Request.QueryString["action"].ToString().Equals("edit")) { if (Request.QueryString["ID"] != null) { int id = Convert.ToInt32(Request.QueryString["ID"]); about.Id = id; obj.Update(about); this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "show", "<script type='text/javascript'>alert('Cập nhật thành công')</script>"); } } } } this.odsTypeDetail.DataBind(); this.GridView1.DataBind(); }
public void Update(clsTypeDetail obj) { try { this.obj.Update(obj); } catch (Exception) { throw; } }
public int Insert(clsTypeDetail obj) { try { return this.obj.Insert(obj); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { try { IOBusiness.clsBSDetail obj = new IOBusiness.clsBSDetail(); List<clsDetail> objD = new List<clsDetail>(); objD=obj.GetByTour(Convert.ToInt32(Request.QueryString["id"])); foreach (IOEntity.clsDetail item in objD) { IOBusiness.clsBSTypeDetail type = new IOBusiness.clsBSTypeDetail(); IOEntity.clsTypeDetail typeobj = new IOEntity.clsTypeDetail(); typeobj = type.GetById(item.TypeDetail.Id); AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel(); tab.HeaderText = typeobj.TieuDe; Label lb = new Label(); lb.Text = item.NoiDung; tab.Controls.Add(lb); this.TabContainer1.Tabs.AddAt(0,tab); //this.TabContainer1.Tabs[1] } this.TabContainer1.Tabs.RemoveAt(objD.Count); clsBSTour objtour = new clsBSTour(); clsTour t = new clsTour(); t = objtour.GetById(Convert.ToInt32(Request.QueryString["id"])); this.lblTour.Text = t.TieuDe; this.Label1.Text = t.TieuDe; this.DataList2.DataSource = objtour.GetByLoai(t.TheLoai.Id, Convert.ToInt32(Request.QueryString["id"])); DataList2.DataBind(); if (!Page.IsPostBack) { BindCountry(); } } catch (Exception) { throw; } }
public List<clsTypeDetail> GetAll() { try { List<clsTypeDetail> list = new List<clsTypeDetail>(); string str = "select * from tblTypeDetail"; SqlCommand com = new SqlCommand(str, con.getCon()); con.openCon(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { clsTypeDetail obj = new clsTypeDetail(); if (dr["tieude"] != DBNull.Value) { obj.TieuDe = dr["tieude"].ToString(); } if (dr["stt"] != DBNull.Value) { obj.Stt = Convert.ToInt32(dr["stt"].ToString()); } if (dr["id"] != DBNull.Value) { obj.Id = Convert.ToInt32(dr["id"].ToString()); } list.Add(obj); } return list; } catch (Exception) { throw; } finally { con.closeCon(); } }
public clsTypeDetail GetById(int id) { try { clsTypeDetail obj = new clsTypeDetail(); string str = "select * from tblTypeDetail where id=@id"; SqlCommand com = new SqlCommand(str, con.getCon()); com.Parameters.AddWithValue("@id", id); con.openCon(); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { obj.Id = id; if (dr["tieude"] != DBNull.Value) { obj.TieuDe = dr["tieude"].ToString(); } if (dr["stt"] != DBNull.Value) { obj.Stt = Convert.ToInt32(dr["stt"].ToString()); } } return obj; } catch (Exception) { throw; } finally { con.closeCon(); } }
public void Update(clsTypeDetail obj) { try { string str = "Update tblTypeDetail set tieude=@tieude,stt=@stt where id=@id"; SqlCommand com = new SqlCommand(str, con.getCon()); com.Parameters.AddWithValue("@tieude", obj.TieuDe); com.Parameters.AddWithValue("@stt", obj.Stt); com.Parameters.AddWithValue("@id", obj.Id); con.openCon(); com.ExecuteNonQuery(); con.closeCon(); } catch (Exception) { throw; } finally { con.closeCon(); } }
public int Insert(clsTypeDetail obj) { try { string str = "insert into tblTypeDetail(tieude,stt) values(@tieude,@stt)"; SqlCommand com = new SqlCommand(str, con.getCon()); com.Parameters.AddWithValue("@tieude", obj.TieuDe); com.Parameters.AddWithValue("@stt", obj.Stt); con.openCon(); com.ExecuteNonQuery(); con.closeCon(); return clsDAStaticMethod.getIDIdentity("tblTypeDetail"); } catch (Exception) { throw; } finally { con.closeCon(); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString["action"] != null) { if (this.pnInfo.Visible == false) { if (Request.QueryString["action"].ToString().Equals("new")) { this.pnInfo.Visible = true; this.txtTieuDe.Text = ""; this.txtSTT.Text = "1"; } else { if (Request.QueryString["action"].ToString().Equals("edit")) { if (Request.QueryString["ID"] != null) { this.pnInfo.Visible = true; int id = Convert.ToInt32(Request.QueryString["ID"]); clsTypeDetail about = new clsTypeDetail(); about = obj.GetById(id); this.txtSTT.Text = about.Stt.ToString(); this.txtTieuDe.Text = about.TieuDe; } } } } } else { this.pnInfo.Visible = false; } } catch (Exception) { throw; } }