protected void btnSave_Click(object sender, EventArgs e) { Vivina.Erp.DataClasses.Function originalFunction = new Vivina.Erp.DataClasses.Function(); FunctionManager functionManager = new FunctionManager(this); Vivina.Erp.DataClasses.Function function = new Vivina.Erp.DataClasses.Function(); if (Page.ViewState["FunctionId"] != null) { originalFunction = functionManager.GetFunction(Convert.ToInt32(Page.ViewState["FunctionId"])); function.CopyPropertiesFrom(originalFunction); } function.Name = txtName.Text; function.CodeName = txtCode.Text; function.Description = txtDescription.Value; SiteMapNode node = SiteMap.RootNode.GetAllNodes().Cast<SiteMapNode>().Where(n => n.ResourceKey == function.FunctionId.ToString()).FirstOrDefault(); if (node != null) node.Description = function.Description; if (Page.ViewState["FunctionId"] != null) //functionManager.update(originalFunction, function); functionManager.Update(originalFunction, function); else functionManager.InsertFunction(function); Server.Transfer("Functions.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { Vivina.Erp.DataClasses.Function originalFunction = new Vivina.Erp.DataClasses.Function(); FunctionManager functionManager = new FunctionManager(this); Vivina.Erp.DataClasses.Function function = new Vivina.Erp.DataClasses.Function(); if (Page.ViewState["FunctionId"] != null) { originalFunction = functionManager.GetFunction(Convert.ToInt32(Page.ViewState["FunctionId"])); function.CopyPropertiesFrom(originalFunction); } function.Name = txtName.Text; function.CodeName = txtCode.Text; function.Description = txtDescription.Value; SiteMapNode node = SiteMap.RootNode.GetAllNodes().Cast <SiteMapNode>().Where(n => n.ResourceKey == function.FunctionId.ToString()).FirstOrDefault(); if (node != null) { node.Description = function.Description; } if (Page.ViewState["FunctionId"] != null) { //functionManager.update(originalFunction, function); functionManager.Update(originalFunction, function); } else { functionManager.InsertFunction(function); } Server.Transfer("Functions.aspx"); }