Esempio n. 1
0
    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 == "visitreason"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        // 
        if (Request.QueryString["VisitReasonId"] != null)
        {
            visitReasonId = Int32.Parse(Request.QueryString["VisitReasonId"]);
            visitReason = CntAriCli.GetVisitReason(visitReasonId, ctx);
            LoadData(visitReason);
        }
    }
Esempio n. 2
0
 protected bool CreateChange()
 {
     if (!DataOk())
         return false;
     if (visitReason == null)
     {
         visitReason = new VisitReason();
         UnloadData(visitReason);
         ctx.Add(visitReason);
     }
     else
     {
         visitReason = CntAriCli.GetVisitReason(visitReasonId, ctx);
         UnloadData(visitReason);
     }
     ctx.SaveChanges();
     return true;
 }
Esempio n. 3
0
 protected void UnloadData(VisitReason vr)
 {
     vr.Name = txtName.Text;
 }
Esempio n. 4
0
 protected void LoadData(VisitReason vr)
 {
     txtVisitReasonId.Text = vr.VisitReasonId.ToString();
     txtName.Text = vr.Name;
 }
Esempio n. 5
0
        public static void ImportVisitReasons(OleDbConnection con, AriClinicContext ctx)
        {
            // (0) Borra tipos previos
            ctx.Delete(ctx.VisitReasons);
            ctx.SaveChanges();

            // (1) Dar de alta los tipos de IVA importados.
            string sql = "SELECT * FROM Motivos";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConMotivos");
            int nreg = ds.Tables["ConMotivos"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConMotivos"].Rows)
            {
                DataRow localDr = dr;
                reg++;
                Console.WriteLine("Motivos visita {0:#####0} de {1:#####0} {2}", reg, nreg, (string)localDr["NomMot"]);
                VisitReason vr = (from v in ctx.VisitReasons
                                  where v.OftId == (int)localDr["IdMot"]
                                  select v).FirstOrDefault<VisitReason>();
                if (vr == null)
                {
                   vr = new VisitReason();
                   ctx.Add(vr);
                }
                vr.Name = (string)localDr["NomMot"];
                vr.OftId = (int)localDr["IdMot"];
            }
            ctx.SaveChanges();
        }
Esempio n. 6
0
        public static void ImportVisitReasons(OleDbConnection con, AriClinicContext ctx)
        {
            // (0) Borra tipos previos
            ctx.Delete(ctx.VisitReasons);

            // (1) Dar de alta los tipos de IVA importados.
            string sql = "SELECT * FROM Motivos";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConMotivos");
            int nreg = ds.Tables["ConMotivos"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConMotivos"].Rows)
            {
                reg++;

                VisitReason vr = new VisitReason();
                vr.Name = (string)dr["NomMot"];
                vr.OftId = (int)dr["IdMot"];
                ctx.Add(vr);
            }
            ctx.SaveChanges();
        }