Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Login())
     {
         Response.Redirect("/login.aspx");
     }
     else
     {
         ProjectReport pr = new ProjectReport();
         pr.UC          = UC;
         pr.prjID       = long.Parse(Request["prjId"]);
         prjStatus.Text = pr.FillStatus();
     }
 }
Ejemplo n.º 2
0
        void btnSendMails_Click(object sender, EventArgs e)
        {
            string  mailTo      = string.Empty;
            string  mailSubject = string.Empty;
            string  mailBody    = string.Empty;
            string  query       = string.Empty;
            DataSet ds          = new DataSet();

            switch (selectMailSend.SelectedValue)
            {
            case "0":
                string[] adminId = DatabaseConnection.SqlScalar("SELECT ADMINACCOUNT+CAST(OWNER AS VARCHAR(10)) FROM PROJECT WHERE ID=" + prjID).Split('|');
                foreach (string adm in adminId)
                {
                    if (adm.Length > 0)
                    {
                        mailTo += DatabaseConnection.SqlScalar("SELECT CASE ISNULL(NOTIFYEMAIL,'') WHEN '' THEN USERACCOUNT ELSE NOTIFYEMAIL END AS MAIL FROM ACCOUNT WHERE UID=" + adm) + ";";
                    }
                }
                query = string.Format(@"SELECT CASE ISNULL(ACCOUNT.NOTIFYEMAIL,'') WHEN '' THEN ACCOUNT.USERACCOUNT ELSE ACCOUNT.NOTIFYEMAIL END AS MAIL, PROJECT_MEMBERS.ID
FROM PROJECT_MEMBERS
INNER JOIN PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM=PROJECT_TEAMS.ID
INNER JOIN ACCOUNT ON ACCOUNT.UID=PROJECT_MEMBERS.USERID
WHERE PROJECT_TEAMS.PROJECTID={0} AND (PROJECT_MEMBERS.TYPE=0 OR PROJECT_MEMBERS.TYPE=2)
UNION
SELECT BASE_CONTACTS.EMAIL AS MAIL ,PROJECT_MEMBERS.ID
FROM PROJECT_MEMBERS
INNER JOIN PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM=PROJECT_TEAMS.ID
INNER JOIN BASE_CONTACTS ON BASE_CONTACTS.ID=PROJECT_MEMBERS.USERID
WHERE PROJECT_TEAMS.PROJECTID={0} AND (PROJECT_MEMBERS.TYPE=1)", this.prjID.Text);
                ds    = DatabaseConnection.CreateDataset(query);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    mailTo += dr[0].ToString() + ";";
                }
                break;

            case "1":
                adminId = DatabaseConnection.SqlScalar("SELECT ADMINACCOUNT+CAST(OWNER AS VARCHAR(10)) FROM PROJECT WHERE ID=" + prjID.Text).Split('|');
                foreach (string adm in adminId)
                {
                    if (adm.Length > 0)
                    {
                        mailTo += DatabaseConnection.SqlScalar("SELECT CASE ISNULL(NOTIFYEMAIL,'') WHEN '' THEN USERACCOUNT ELSE NOTIFYEMAIL END AS MAIL FROM ACCOUNT WHERE UID=" + adm) + ";";
                    }
                }
                break;

            case "2":
                if (MailOwnerType.Text == "0" || MailOwnerType.Text == "2")
                {
                    query = string.Format(@"SELECT CASE ISNULL(ACCOUNT.NOTIFYEMAIL,'') WHEN '' THEN ACCOUNT.USERACCOUNT ELSE ACCOUNT.NOTIFYEMAIL END AS MAIL, PROJECT_MEMBERS.ID
FROM PROJECT_MEMBERS
INNER JOIN PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM=PROJECT_TEAMS.ID
INNER JOIN ACCOUNT ON ACCOUNT.UID=PROJECT_MEMBERS.USERID
WHERE PROJECT_TEAMS.PROJECTID={0} AND PROJECT_MEMBERS.ID={1}", this.prjID.Text, MailOwnerRealID.Text);
                }
                else
                {
                    query = string.Format(@"SELECT BASE_CONTACTS.EMAIL AS MAIL ,PROJECT_MEMBERS.ID
FROM PROJECT_MEMBERS
INNER JOIN PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM=PROJECT_TEAMS.ID
INNER JOIN BASE_CONTACTS ON BASE_CONTACTS.ID=PROJECT_MEMBERS.USERID
WHERE PROJECT_TEAMS.PROJECTID={0} AND PROJECT_MEMBERS.ID={1}", this.prjID.Text, MailOwnerRealID.Text);
                }
                ds     = DatabaseConnection.CreateDataset(query);
                mailTo = ds.Tables[0].Rows[0][0].ToString();
                break;
            }

            ProjectReport pr = new ProjectReport();

            pr.UC = UC;
            switch (selectMailType.SelectedValue)
            {
            case "0":
                pr.prjID = long.Parse(this.prjID.Text);
                mailBody = pr.FillStatus();
                MessagesHandler.SendMail(mailTo, "*****@*****.**", mailSubject, mailBody);
                break;

            case "1":
                if (ds.Tables[0].Rows.Count > 0)
                {
                    pr.prjID = long.Parse(this.prjID.Text);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        pr.MemberId = long.Parse(dr[1].ToString());
                        mailBody    = pr.ToDoList();
                        MessagesHandler.SendMail(dr[0].ToString(), "*****@*****.**", mailSubject, mailBody);
                    }
                }
                break;
            }
        }