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 = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "campaign" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["CampaignId"] != null) { campaignId = Int32.Parse(Request.QueryString["CampaignId"]); cpg = CntAriCli.GetCampaign(campaignId, ctx); LoadData(cpg); } }
protected void UnloadData(Request chn) { req.RequestDateTime = (DateTime)rdtRequestDateTime.SelectedDate; req.Status = txtStatus.Text; if (rdcCampaign.SelectedValue != "") { req.Campaign = CntAriCli.GetCampaign(int.Parse(rdcCampaign.SelectedValue), ctx); } if (rdcChannel.SelectedValue != "") { req.Channel = CntAriCli.GetChannel(int.Parse(rdcChannel.SelectedValue), ctx); } if (rdcSource.SelectedValue != "") { req.Source = CntAriCli.GetSource(int.Parse(rdcSource.SelectedValue), ctx); } if (rdcPatient.SelectedValue != "") { req.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx); } if (rdcClinic.SelectedValue != "") { req.Clinic = CntAriCli.GetClinic(int.Parse(rdcClinic.SelectedValue), ctx); } req.Surname1 = txtSurname1.Text; req.Surname2 = txtSurname2.Text; req.Name = txtName.Text; req.Sex = rdcbSex.SelectedValue; if (rdtBornDate.SelectedDate != null) { req.BornDate = (DateTime)rdtBornDate.SelectedDate; } req.PostalCode = txtCodPostal.Text; req.Dni = txtDni.Text; req.Email = txtEmail.Text; req.Telephone = txtTelephone.Text; if (rdcService.SelectedValue != "") { req.Service = CntAriCli.GetService(int.Parse(rdcService.SelectedValue), ctx); } req.Comments = txtComments.Text; req.FullName = String.Format("{0} {1}, {2}", req.Surname1, req.Surname2, req.Name); req.User = user; }
protected bool CreateChange() { if (!DataOk()) { return(false); } if (cpg == null) { cpg = new Campaign(); UnloadData(cpg); ctx.Add(cpg); } else { cpg = CntAriCli.GetCampaign(campaignId, ctx); UnloadData(cpg); } ctx.SaveChanges(); return(true); }