Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
                CurrentUser = (AUser)Session["user"];
            if (!Page.IsPostBack)
            {
                string sid = Request.QueryString["view"];
                int id;
                int.TryParse(sid, out id);

                db = new DBHelper(AgentUtileries.dbcstring);
                Session["db"] = db;
                CurrentActivity = db.GetActivity(id);

                // Si hay una actividad actual, obtener sus otros datos.
                if (CurrentActivity != null)
                {
                    OwnerProject = db.GetProject(CurrentActivity.ProjectID);
                    ParentActivity = db.GetActivity(CurrentActivity.Parent);
                    ChildActivities = db.GetChildActivities(CurrentActivity.ID);
                    ActivityImages = db.GetImages(CurrentActivity.ID);
                    Session["activity"] = CurrentActivity;
                }
            }
            else
            {
                CurrentActivity = (AActivity)Session["activity"];
                db = (DBHelper)Session["db"];
                if (CurrentActivity != null)
                {
                    OwnerProject = db.GetProject(CurrentActivity.ProjectID);
                    ParentActivity = db.GetActivity(CurrentActivity.Parent);
                    ChildActivities = db.GetChildActivities(CurrentActivity.ID);
                    Title = CurrentActivity.Title;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Obtiene una actividad según su identificador.
 /// </summary>
 /// <param name="id">Identificador de la actividad.</param>
 /// <returns>Instancia de la actividad solicitada.</returns>
 public AActivity GetActivity(int id)
 {
     conn.Open();
     SqlCommand command = new SqlCommand("select * from [dbo].[fGetActivity] (" + id + ")", conn);
     SqlDataAdapter adapter = new SqlDataAdapter(command);
     DataTable table = new DataTable("activity");
     adapter.Fill(table);
     conn.Close();
     if (table.Rows.Count > 0)
     {
         int rowid = (int)table.Rows[0]["ID"];
         string rowtitle = table.Rows[0]["Title"].ToString();
         DateTime due = (DateTime)table.Rows[0]["DueDate"];
         DateTime created = (DateTime)table.Rows[0]["Created"];
         DateTime reminder = (DateTime)table.Rows[0]["Reminder"];
         short priority = (short)table.Rows[0]["Priority"];
         bool completed = (bool)table.Rows[0]["Completed"];
         int parentActivity = (int)table.Rows[0]["ParentActivity"];
         AActivity result = new AActivity(rowid, rowtitle, due, reminder, byte.Parse(priority.ToString()), completed) { Created = created, ProjectID = int.Parse(table.Rows[0]["Project"].ToString()), Parent = parentActivity };
         return result;
     }
     else
     {
         return null;
     }
 }