protected void btnOk_Click(object sender, EventArgs e)
    {
        // Cập nhật vào DB
        string stitle = txtTitle.Text.Trim();

        if (stitle == string.Empty || stitle == "")
        {
            spanTB.Visible = true;
            return;
        }
        if (KT)
        {
            sThuoctinh.Insert(stitle, id, string.Empty); // thêm mới
        }
        else
        {
            // update;
            sThuoctinh.Update(IdUpdate, stitle); // Update
        }
        // Cap nhat lai thong tin sua hoac them mơi
        Response.Redirect(Globals.UrlRoot + "temp.aspx?url=" + Request.Url);
        //GetData();
    }
Example #2
0
 protected void rptGaitri_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "AddRow")
     {
         GetData();
         dt.Rows.Add(0, ""); // Thêm một dòng vào dt và vẽ nó ở rpt
         rptGaitri.DataSource = dt;
         rptGaitri.DataBind();
         return;
     }
     if (e.CommandName == "edit")
     {
         // sửa, cập nhật lại giá trị của thuộc tính
         ((TextBox)e.Item.FindControl("txtValue")).Enabled     = true;
         ((LinkButton)e.Item.FindControl("lnkEdit")).Visible   = false;
         ((LinkButton)e.Item.FindControl("lnkDelete")).Visible = false;
         ((LinkButton)e.Item.FindControl("lnkUpdate")).Visible = true;
         ((LinkButton)e.Item.FindControl("lnkCancel")).Visible = true;
     }
     if (e.CommandName == "cancel")
     {
         // sửa, cập nhật lại giá trị của thuộc tính
         ((TextBox)e.Item.FindControl("txtValue")).Enabled     = false;
         ((LinkButton)e.Item.FindControl("lnkEdit")).Visible   = true;
         ((LinkButton)e.Item.FindControl("lnkDelete")).Visible = true;
         ((LinkButton)e.Item.FindControl("lnkUpdate")).Visible = false;
         ((LinkButton)e.Item.FindControl("lnkCancel")).Visible = false;
     }
     if (e.CommandName == "update")
     {
         string stitle = ((TextBox)e.Item.FindControl("txtValue")).Text;
         string idT    = e.CommandArgument.ToString();
         if (stitle == string.Empty || stitle == null)
         {
             spanTB.Visible = true;
             return;
         }
         else
         {
             // Khác 0 chứng tỏ là sửa
             if (e.CommandArgument.ToString() != "0")
             {
                 // Update
                 clthuoctinh.Update(idT, stitle);
                 ((TextBox)e.Item.FindControl("txtValue")).Enabled     = false;
                 ((LinkButton)e.Item.FindControl("lnkEdit")).Visible   = true;
                 ((LinkButton)e.Item.FindControl("lnkDelete")).Visible = true;
                 ((LinkButton)e.Item.FindControl("lnkUpdate")).Visible = false;
                 ((LinkButton)e.Item.FindControl("lnkCancel")).Visible = false;
             }
             //Thêm mới
             else
             {
                 // Inset
                 clthuoctinh.Insert(stitle, groupid, id);
                 ((TextBox)e.Item.FindControl("txtValue")).Enabled     = false;
                 ((LinkButton)e.Item.FindControl("lnkEdit")).Visible   = true;
                 ((LinkButton)e.Item.FindControl("lnkDelete")).Visible = true;
                 ((LinkButton)e.Item.FindControl("lnkUpdate")).Visible = false;
                 ((LinkButton)e.Item.FindControl("lnkCancel")).Visible = false;
             }
         }
         // update
     }
     if (e.CommandName == "delete" && e.CommandArgument.ToString() != "")
     {
         string id = e.CommandArgument.ToString();
         clthuoctinh.Delete(id);
         Response.Redirect(Request.Url.AbsoluteUri, true);
     }
 }