/// <summary> /// Load danh sách chuyên mục /// </summary> private void BindData() { BDocumentKind ctl = new BDocumentKind(); grvDocumentKind.DataSource = ctl.Get(0); grvDocumentKind.DataBind(); }
/// <summary> /// Các thao tác trên danh sách /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grvDocumentKind_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("cmdEdit", StringComparison.OrdinalIgnoreCase)) { BDocumentKind ctl = new BDocumentKind(); ODocumentKind obj = ctl.Get(int.Parse(e.CommandArgument.ToString())).First(); if (obj != null) { txtDescription.Text = obj.Description; txtName.Text = obj.Name; hdfId.Value = obj.DocumentKindID.ToString(); try { ddlParent.ClearSelection(); ddlParent.Items.FindByValue(obj.DocumentKindParent.ToString()).Selected = true; } catch (Exception ex) { } } } else if (e.CommandName.Equals("cmdDelete", StringComparison.OrdinalIgnoreCase)) { BDocumentKind ctl = new BDocumentKind(); if (ctl.Delete(int.Parse(e.CommandArgument.ToString()))) { BindData(); } else { RegisterClientScriptBlock("Notification", "<script language='javascript'>alert('Đã tồn tại văn bản trong loại này!');</script>"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { BDocumentKind ctl = new BDocumentKind(); if (!string.IsNullOrEmpty(txtName.Text)) { ODocumentKind obj = new ODocumentKind(); obj.Name = txtName.Text; obj.Description = txtDescription.Text; try { obj.DocumentKindParent = int.Parse(ddlParent.SelectedValue); } catch (Exception ea) { obj.DocumentKindParent = 0; } if (hdfId.Value != "") { obj.DocumentKindID = int.Parse(hdfId.Value); ctl.Update(obj.DocumentKindID, obj.Name, obj.Description, obj.DocumentKindParent); hdfId.Value = ""; } else { ctl.Add(obj); } txtName.Text = ""; txtDescription.Text = ""; BindData(); } }
private void BindParent() { BDocumentKind ctl = new BDocumentKind(); ddlParent.DataSource = ctl.Get(0); ddlParent.DataBind(); ddlParent.Items.Insert(0, new ListItem("Không có cha", "")); }
/// <summary> /// Load ra danh sách loại tài liệu /// </summary> private void BindDocumentType() { BDocumentKind ctl = new BDocumentKind(); ddlDocumentType.ClearSelection(); ddlDocumentType.DataSource = ctl.Get(0); ddlDocumentType.DataBind(); ddlDocumentType.Items.Insert(0, new ListItem("Tất cả", "0")); }
/// <summary> /// Load danh sách chuyên mục /// </summary> private void BindData() { //-- Kiểm tra quyền dự thảo if (!Global.IsAdmin()) { Response.Redirect("/"); } BDocumentKind ctl = new BDocumentKind(); grvDocumentKind.DataSource = ctl.Get(0); grvDocumentKind.DataBind(); }
/// <summary> /// Lấy về tên lại công văn /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetName(object id) { BDocumentKind ctl = new BDocumentKind(); try{ if (int.Parse(id.ToString()) > 0) { return(ctl.Get(int.Parse(id.ToString()))[0].Name); } else { return(""); } }catch (Exception ex) { return(""); } }