protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { RefreshGrid(); if (e.Argument == "new") { RadGrid1.CurrentPageIndex = RadGrid1.PageCount - 1; RadGrid1.Rebind(); } if (e.Argument == "yes") { if (Session["DeleteId"] != null) { try { UnitTypeId = (int)Session["DeleteId"]; AriCliModel.UnitType ser = (from s in ctx.UnitTypes where s.UnitTypeId == UnitTypeId select s).FirstOrDefault <AriCliModel.UnitType>(); ctx.Delete(ser); ctx.SaveChanges(); RefreshGrid(); Session["DeleteId"] = null; } catch (Exception ex) { Session["Exception"] = ex; string command = String.Format("showDialog('Error','{0}','error',null, 0, 0)" , Resources.GeneralResource.DeleteRecordFail); RadAjaxManager1.ResponseScripts.Add(command); } } } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) { Response.Redirect("Default.aspx"); } else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "UnitType" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["UnitTypeId"] != null) { unitTypeId = Int32.Parse(Request.QueryString["UnitTypeId"]); unitType = CntAriCli.GetUnitType(unitTypeId, ctx); LoadData(unitType); } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "UnitType" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["UnitTypeId"] != null) { unitTypeId = Int32.Parse(Request.QueryString["UnitTypeId"]); unitType = CntAriCli.GetUnitType(unitTypeId, ctx); LoadData(unitType); } }
protected bool CreateChange() { if (!DataOk()) { return(false); } if (unitType == null) { unitType = new AriCliModel.UnitType(); UnloadData(unitType); ctx.Add(unitType); } else { unitType = CntAriCli.GetUnitType(unitTypeId, ctx); UnloadData(unitType); } ctx.SaveChanges(); return(true); }
protected void UnloadData(AriCliModel.UnitType unitType) { unitType.Name = txtName.Text; }
protected void LoadData(AriCliModel.UnitType unitType) { txtUnitTypeId.Text = unitType.UnitTypeId.ToString(); txtName.Text = unitType.Name; }
protected bool CreateChange() { if (!DataOk()) return false; if (unitType == null) { unitType = new AriCliModel.UnitType(); UnloadData(unitType); ctx.Add(unitType); } else { unitType = CntAriCli.GetUnitType(unitTypeId, ctx); UnloadData(unitType); } ctx.SaveChanges(); return true; }