Пример #1
0
 /// <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>");
         }
     }
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
        public bool Add(ODocumentKind obj)
        {
            SqlParameter[] sqlPara = new SqlParameter[3];
            sqlPara[0]       = new SqlParameter("@Name", SqlDbType.NVarChar);
            sqlPara[0].Value = obj.Name;
            sqlPara[1]       = new SqlParameter("@Description", SqlDbType.NVarChar);
            sqlPara[1].Value = obj.Description;
            sqlPara[2]       = new SqlParameter("@DocumentKindParent", SqlDbType.Int);
            sqlPara[2].Value = obj.DocumentKindParent;

            return(RunProcudure("sp_tblDocumentKind_add", sqlPara));
        }