protected void ddlGroupParent_Load()
        {
            DropDownList drdList;
            BWorkGroup   obj = new BWorkGroup();

            // foreach loop is used to loop through each row of GridView Control.
            foreach (GridViewRow grdRow in grvWorkGroup.Rows)
            {
                // Nested DropDownList Control reference is passed to the DrdList object. This will allow you access the properties of dropdownlist placed inside the GridView Template column.
                drdList = (DropDownList)(grvWorkGroup.Rows[grdRow.RowIndex].Cells[4].FindControl("ddlGroupParent"));

                // DataBinding of nested DropDownList Control for each row of GridView Control.
                ListItem lit = new ListItem("Không có nhóm công việc cha", "0");


                drdList.DataSource     = obj.Get(0);
                drdList.DataValueField = "WorkGroupID";
                drdList.DataTextField  = "Name";

                drdList.DataBind();
                drdList.Items.Insert(0, lit);
                int Id       = Convert.ToInt32(grvWorkGroup.DataKeys[grdRow.RowIndex].Value);
                int IdParent = obj.Get(Id).First().WorkGroupParent;
                if (IdParent == 0)
                {
                    drdList.SelectedValue = "0";
                }
                else
                {
                    drdList.SelectedValue = IdParent.ToString();
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> PutBWorkGroup([FromRoute] int id, [FromBody] BWorkGroup bWorkGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bWorkGroup.Id)
            {
                return(BadRequest());
            }

            _context.Entry(bWorkGroup).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BWorkGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        protected void ddlWorkGroup_Load()
        {
            ddlWorkGroup.Items.Clear();
            BWorkGroup bwg = new BWorkGroup();

            ddlWorkGroup.DataSource     = bwg.Get(0);
            ddlWorkGroup.DataTextField  = "Name";
            ddlWorkGroup.DataValueField = "WorkGroupID";
            ddlWorkGroup.DataBind();
        }
Esempio n. 4
0
        public async Task <IActionResult> PostBWorkGroup([FromBody] BWorkGroup bWorkGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BWorkGroup.Add(bWorkGroup);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBWorkGroup", new { id = bWorkGroup.Id }, bWorkGroup));
        }
        protected void ddlWorkGroup_Load()
        {
            ListItem   lit = new ListItem("--Chọn nhóm công việc--", "0");
            BWorkGroup bwg = new BWorkGroup();

            ddlWorkGroup.DataSource     = bwg.Get(0);
            ddlWorkGroup.DataTextField  = "Name";
            ddlWorkGroup.DataValueField = "WorkGroupID";

            ddlWorkGroup.DataBind();
            ddlWorkGroup.Items.Insert(0, lit);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            OWorkGroup obj = new OWorkGroup();

            obj.Name        = txtWorkGroupName.Text;
            obj.Description = txtContent.Text;

            BWorkGroup ọbjB = new BWorkGroup();

            ọbjB.Add(obj);
            grvWorkGroup_Load();

            txtWorkGroupName.Text = string.Empty;
            txtContent.Text       = string.Empty;
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BWorkGroup obj = new BWorkGroup();

            foreach (GridViewRow row in grvWorkGroup.Rows)
            {
                CheckBox checkbox = (CheckBox)row.FindControl("MyCheckBox");

                if (checkbox.Checked == true)
                {
                    int Id = Convert.ToInt32(grvWorkGroup.DataKeys[row.RowIndex].Value);
                    obj.Delete(Id);
                }
            }
            grvWorkGroup_Load();
        }
        protected void grvWorkGroup_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int          Id              = Convert.ToInt32(grvWorkGroup.DataKeys[e.RowIndex].Value);
            string       textName        = ((TextBox)grvWorkGroup.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
            string       textDescription = ((TextBox)grvWorkGroup.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
            DropDownList ddl             = (DropDownList)grvWorkGroup.Rows[e.RowIndex].Cells[4].Controls[1];
            //ddl.Enabled = true;

            BWorkGroup obj = new BWorkGroup();

            obj.Update(Id, textName, textDescription, int.Parse(ddl.SelectedValue));
            grvWorkGroup.EditIndex = -1;
            grvWorkGroup_Load();

            txtWorkGroupName.Text = string.Empty;
            txtContent.Text       = string.Empty;
        }
        protected void grvWorkGroup_Load()
        {
            BWorkGroup objWorkGroup = new BWorkGroup();
            int        count        = objWorkGroup.Get(0).Count;

            ctlPagging.PageSize     = int.Parse(ddlPageSize.SelectedValue);
            spResultCount.InnerHtml = "Tìm thấy <b>" + count.ToString() + "</b> kết quả";
            if (count > ctlPagging.PageSize)
            {
                ctlPagging.Visible = true;
            }
            else
            {
                ctlPagging.Visible = false;
            }
            grvWorkGroup.DataSource = objWorkGroup.Get(0, CurrentPage, ctlPagging.PageSize);
            grvWorkGroup.DataBind();
            ddlGroupParent_Load();
            ctlPagging.CurrentIndex             = CurrentPage;
            ctlPagging.ItemCount                = count;
            ctlPagging.QueryStringParameterName = GenarateParam();
        }