Esempio n. 1
0
 private void initControl(int Id)
 {
     if (Id > 0)
     {
         btn_add.Visible  = false;
         btn_edit.Visible = true;
         DistrictService objlogic = new DistrictService();
         District        obj      = new District();
         obj = objlogic.FindByKey(Id);
         if (obj != null)
         {
             txtTitle.Text = obj.DistrictName;
             txtCode.Text  = obj.DistrictCode;
             if (obj.ProvinceId > 0)
             {
                 ddlParent.SelectedValue = obj.ProvinceId.ToString();
             }
             txtSorOrder.Text = obj.SortOrder.ToString();
             //if (obj.GroupArea > 0)
             //    ddlLinhVuc.SelectedValue = obj.GroupArea.ToString();
         }
     }
     else
     {
         btn_add.Visible  = true;
         btn_edit.Visible = false;
     }
 }
Esempio n. 2
0
    protected void grvArea_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int iEditId = 0;

        iEditId = Convert.ToInt32(e.CommandArgument.ToString());
        string aName = e.CommandName.ToLower();

        if (iEditId > 0)
        {
            DistrictService objlogic = new DistrictService();
            if (aName.Contains("_edit"))
            {
                District obj = new District();
                obj = objlogic.FindByKey(iEditId);
                if (obj != null)
                {
                    hdnEditId.Value  = iEditId.ToString();
                    txtCode.Text     = obj.DistrictCode;
                    txtSorOrder.Text = obj.SortOrder.ToString();
                    txtTitle.Text    = obj.DistrictName;
                    if (obj.ProvinceId > 0)
                    {
                        ddlParent.SelectedValue = obj.ProvinceId.ToString();
                    }
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatedistrict();", true);
                }
            }
            else if (aName.Contains("_delete"))
            {
                if (objlogic.Delete(Convert.ToInt32(iEditId)) > 0)
                {
                    BindData();
                }
            }
        }
    }