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 == "drug" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["DrugId"] != null) { drugId = Int32.Parse(Request.QueryString["DrugId"]); drug = CntAriCli.GetDrug(drugId, ctx); LoadData(drug); } }
protected void UnloadData(Treatment tr) { tr.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx); tr.TreatmentDate = (DateTime)rdpTreatmentDate.SelectedDate; tr.Drug = CntAriCli.GetDrug(int.Parse(rdcDrug.SelectedValue), ctx); if (visit != null) { tr.BaseVisit = visit; } tr.Recommend = txtRecommend.Text; if (txtQuantity.Text != "") { tr.Quantity = (decimal)txtQuantity.Value; } if (rdcProfessional.SelectedValue != "") { tr.Professional = CntAriCli.GetProfessional(int.Parse(rdcProfessional.SelectedValue), ctx); } }
protected bool CreateChange() { if (!DataOk()) { return(false); } if (drug == null) { drug = new Drug(); UnloadData(drug); ctx.Add(drug); } else { drug = CntAriCli.GetDrug(drugId, ctx); UnloadData(drug); } ctx.SaveChanges(); return(true); }
protected bool CreateChange() { if (!DataOk()) { return(false); } if (treatment == null) { treatment = new Treatment(); newTreatment = true; UnloadData(treatment); ctx.Add(treatment); } else { drug = CntAriCli.GetDrug(drugId, ctx); UnloadData(treatment); } ctx.SaveChanges(); return(true); }