private void Save(string strLink = "") { try { int _idroot = Utils.CIntDef(Drmenu_parent.SelectedValue); int rank = 1; int _idpar = 0; var getrank = db.MENU_PARENTs.Where(n => n.MENU_PAR_ID == _idroot).ToList(); if (getrank.Count > 0) { rank += Utils.CIntDef(getrank[0].MENU_RANK); _idpar = getrank[0].MENU_PAR_ID; } if (_menuid == 0) { MENU_PARENT menu = new MENU_PARENT(); menu.MENU_PARENT1 = _idpar; menu.MENU_RANK = rank; menu.MENU_NAME = Txtname.Text; menu.MENU_PARENT_LINK = txtlinkmenu.Text; menu.ORDERBY = Utils.CIntDef(txtOrderby.Text); menu.MENU_PAR_ACTIVE = Utils.CIntDef(rblActive.SelectedValue); db.MENU_PARENTs.InsertOnSubmit(menu); db.SubmitChanges(); var getlink = db.MENU_PARENTs.OrderByDescending(n => n.MENU_PAR_ID).Take(1).ToList(); if (getlink.Count > 0) { strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-menu-cha.aspx?menuid=" + getlink[0].MENU_PAR_ID : strLink; } } else { var list = db.MENU_PARENTs.Where(n => n.MENU_PAR_ID == _menuid).ToList(); foreach (var i in list) { i.MENU_RANK = rank; i.MENU_PARENT1 = _idpar; i.MENU_NAME = Txtname.Text; i.MENU_PARENT_LINK = txtlinkmenu.Text; i.ORDERBY = Utils.CIntDef(txtOrderby.Text); i.MENU_PAR_ACTIVE = Utils.CIntDef(rblActive.SelectedValue); } db.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-menu-cha.aspx?menuid=" + _menuid : strLink; } } catch (Exception) { throw; } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }
private void Save(string strLink = "") { try { int _idroot=Utils.CIntDef(Drmenu_parent.SelectedValue); int rank = 1; int _idpar = 0; var getrank = db.MENU_PARENTs.Where(n => n.MENU_PAR_ID == _idroot).ToList(); if (getrank.Count > 0) { rank +=Utils.CIntDef(getrank[0].MENU_RANK); _idpar = getrank[0].MENU_PAR_ID; } if (_menuid == 0) { MENU_PARENT menu = new MENU_PARENT(); menu.MENU_PARENT1 = _idpar; menu.MENU_RANK = rank; menu.MENU_NAME = Txtname.Text; menu.MENU_PARENT_LINK = txtlinkmenu.Text; menu.ORDERBY = Utils.CIntDef(txtOrderby.Text); menu.MENU_PAR_ACTIVE = Utils.CIntDef(rblActive.SelectedValue); db.MENU_PARENTs.InsertOnSubmit(menu); db.SubmitChanges(); var getlink = db.MENU_PARENTs.OrderByDescending(n => n.MENU_PAR_ID).Take(1).ToList(); if (getlink.Count > 0) { strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-menu-cha.aspx?menuid=" + getlink[0].MENU_PAR_ID : strLink; } } else { var list = db.MENU_PARENTs.Where(n => n.MENU_PAR_ID == _menuid).ToList(); foreach (var i in list) { i.MENU_RANK = rank; i.MENU_PARENT1 = _idpar; i.MENU_NAME = Txtname.Text; i.MENU_PARENT_LINK = txtlinkmenu.Text; i.ORDERBY = Utils.CIntDef(txtOrderby.Text); i.MENU_PAR_ACTIVE = Utils.CIntDef(rblActive.SelectedValue); } db.SubmitChanges(); strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-menu-cha.aspx?menuid=" + _menuid : strLink; } } catch (Exception) { throw; } finally { if (!string.IsNullOrEmpty(strLink)) { Response.Redirect(strLink); } } }