示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userid"] == null)
        {
            Response.Redirect("~/Default.aspx");
        }
        if (!IsPostBack)
        {
            string userid = Session["userid"].ToString();
            ds_analytics.m_usersRow user_row = m_users.getUserByUserid(userid)[0];
            lbl_user.Text = user_row.fullname;
            lbl_time.Text = user_row.lastlogintime.ToString("dd/MM/yyyy HH:mm");

            //Set Role/ModuleList DropDown
            ArrayList arr_mod = m_users.getModulesByUserid(userid);
            ddl_moduleList.DataSource = arr_mod;
            ddl_moduleList.DataBind();
            ddl_moduleList.SelectedValue = "Requests";

            //Setting display of Role Dropdown
            if (arr_mod.Count == 1)
            {
                ddl_moduleList.Visible = false;
            }

            //SetPage According to User Access Rights
            setPageByRights(userid);
        }
        else
        {
        }
    }
示例#2
0
    protected void imgbtn_Edit_Click(object sender, ImageClickEventArgs e)
    {
        GridViewRow gv_row = (GridViewRow)((sender as ImageButton).NamingContainer);
        string      userid = Convert.ToString(gv_users.DataKeys[gv_row.RowIndex].Value);

        ds_analytics.m_usersDataTable thisuser_dt = m_users.getUserByUserid(userid);
        if (thisuser_dt.Rows.Count > 0)
        {
            ds_analytics.m_usersRow user_row = thisuser_dt[0];
            lbl_userid.Text = user_row.userid;
            if (user_row.IsfullnameNull())
            {
                tb_username.Text = "";
            }
            else
            {
                tb_username.Text = user_row.fullname;
            }
            if (user_row.IsemailNull())
            {
                tb_email.Text = "";
            }
            else
            {
                tb_email.Text = user_row.email;
            }
            if (user_row.IsmblnoNull())
            {
                tb_mblno.Text = "";
            }
            else
            {
                tb_mblno.Text = user_row.mblno;
            }
            cb_isactive.Checked = user_row.isactive;

            foreach (TreeNode node_parent in TreeView1.Nodes)
            {
                foreach (TreeNode node_child in node_parent.ChildNodes)
                {
                    node_child.Checked = false;
                }
            }

            DataTable dt_rights = m_users.getAccessRightsByUserid(user_row.userid);
            foreach (DataRow dr in dt_rights.Rows)
            {
                TreeView1.FindNode(dr["module_key"].ToString() + TreeView1.PathSeparator + dr["submodule_key"].ToString()).Checked = true;
            }

            ViewState["user_row"] = user_row;

            btn_update.Visible = true;
            btn_cancel.Visible = true;
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "error", "<script>alert('Error in reading user details.');</script>");
        }
    }
示例#3
0
    protected void mail_to_lab(long labid)
    {
        string sub = "GSK: Samples for tests at your lab";
        string from;

        ds_analytics.m_usersRow receiver_row = m_users.getUserByUserid(req_row.responsible)[0];
        if (receiver_row.email != "")
        {
            from = receiver_row.email;
        }
        else
        {
            from = "*****@*****.**";
        }

        WebClient wclient = new WebClient();
        string    url     = HttpContext.Current.Request.Url.AbsoluteUri;

        url = url.Replace("UI/users/reqaction.aspx", "Mailer/reqlab.htm");
        string pagedata = wclient.DownloadString(url);
        string body     = pagedata;

        string[] to  = new string[2];
        string[] cc  = new string[2];
        string[] bcc = new string[2];

        //mail to lab
        ds_analytics.m_labsRow lab_row = m_labs.getLabByLabid(labid)[0];
        if (!lab_row.Isemail1Null() || !lab_row.Isemail2Null())
        {
            if (!lab_row.Isemail1Null() && !lab_row.Isemail2Null())
            {
                //notnull && notnull
                body  = body.Replace("!!~lab_manager~!!", lab_row.contact_person);
                to[0] = lab_row.email1;
                cc[0] = lab_row.email2;
            }
            else if (!lab_row.Isemail1Null() && lab_row.Isemail2Null())
            {
                //notnull && null
                body  = body.Replace("!!~lab_manager~!!", lab_row.contact_person);
                to[0] = lab_row.email1;
            }
            else if (lab_row.Isemail1Null() && !lab_row.Isemail2Null())
            {
                //null && notnull
                body  = body.Replace("!!~lab_manager~!!", lab_row.key_acc_person);
                to[0] = lab_row.email2;
            }
            analyticsmail ana_mail = new analyticsmail();
            ana_mail.sendmails(to, cc, bcc, from, sub, body, "");
        }
    }
示例#4
0
    private void do_mail(string req_status)
    {
        string sub = "Analytics: Your Request " + req_row.reqid + " has been " + req_status;
        string from;

        ds_analytics.m_usersRow receiver_row = m_users.getUserByUserid(req_row.responsible)[0];
        if (receiver_row.email != "")
        {
            from = receiver_row.email;
        }
        else
        {
            from = "*****@*****.**";
        }

        WebClient wclient = new WebClient();
        string    url     = HttpContext.Current.Request.Url.AbsoluteUri;

        url = url.Replace("UI/users/reqaction.aspx", "Mailer/reqapprove.htm");
        string pagedata = wclient.DownloadString(url);
        string body     = pagedata;

        //mail to requestor
        ds_analytics.m_usersRow requestor_row = m_users.getUserByUserid(req_row.reqfrom)[0];
        if (requestor_row != null && requestor_row.email != "")
        {
            //1. Creating login page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            int    len      = url.IndexOf("UI");
            string base_url = url.Substring(0, len);
            base_url = base_url + "Default.aspx?login="******"&redirect=";
            //2. Creating request page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            len = url.IndexOf("reqaction");
            string       redirect_url = url.Substring(0, len);
            Encryption64 e64          = new Encryption64();
            redirect_url = redirect_url + "reqaction_byme.aspx?reqid=" + e64.Encrypt(req_row.reqid);
            //3. Adding login + redirect link
            string web_link = "<a href='" + base_url + redirect_url + "' target='_blank'>Open Request</a>";
            body = body.Replace("!!~requestor_name~!!", requestor_row.fullname);
            body = body.Replace("!!~req_no~!!", req_row.reqid);
            body = body.Replace("!!~req_decision~!!", req_status);
            body = body.Replace("!!~receiver_name~!!", receiver_row.fullname);
            body = body.Replace("!!~You can open the request at web_link~!!", "You can open the request at " + web_link);

            string[]      to       = { requestor_row.email };
            string[]      cc       = new string[2];
            string[]      bcc      = new string[2];
            analyticsmail ana_mail = new analyticsmail();
            ana_mail.sendmails(to, cc, bcc, from, sub, body, "");
        }
    }
示例#5
0
    protected void lb_logout_Click(object sender, EventArgs e)
    {
        string userid = Session["userid"].ToString();

        ds_analytics.m_usersRow user_row = m_users.getUserByUserid(userid)[0];
        user_row.isloggedin    = false;
        user_row.lastlogintime = DateTime.Now;
        m_users.update(user_row);

        Session.Abandon();
        Session.RemoveAll();
        Session.Clear();

        Response.Redirect("~/Default.aspx?logout");
    }
示例#6
0
    protected void btn_update_Click(object sender, EventArgs e)
    {
        ds_analytics.m_usersRow users_row = ((ds_analytics.m_usersRow)(ViewState["user_row"]));
        //1 User Update
        users_row.fullname = tb_username.Text;
        if (tb_email.Text == "")
        {
            users_row.SetemailNull();
        }
        else
        {
            users_row.email = tb_email.Text;
        }
        if (tb_mblno.Text == "")
        {
            users_row.SetmblnoNull();
        }
        else
        {
            users_row.mblno = tb_mblno.Text;
        }
        users_row.isactive = cb_isactive.Checked;
        m_users.update(users_row);

        //2 User_Rights Update
        m_users_rights.delete(users_row.userid);
        foreach (TreeNode node_parent in TreeView1.Nodes)
        {
            foreach (TreeNode node_child in node_parent.ChildNodes)
            {
                if (node_child.Checked == true)
                {
                    m_users_rights.insert(users_row.userid, Convert.ToInt32(node_child.Value));
                }
            }
        }

        //Rebind GridView
        ds_analytics.m_usersDataTable users_dt = m_users.getAllUsers();
        bind_gv_users(users_dt);
        ViewState["dtStored"] = users_dt;

        //Reset Fields
        Reset();
        ClientScript.RegisterStartupScript(this.GetType(), "callfunction", "alert('User Updated.');", true);
    }
示例#7
0
    private void do_mail(string mode, string submitted_reqid)
    {
        ds_analytics.requestsDataTable req_dt            = requests.getRequestbyReqid(submitted_reqid);
        ds_analytics.requestsRow       submitted_req_row = req_dt[0];
        ds_analytics.m_usersRow        requestor_row     = m_users.getUserByUserid(submitted_req_row.reqfrom)[0];
        string sub = "";

        if (mode == "edit")
        {
            sub = "Analytics: Request " + submitted_req_row.reqid + " resubmitted by " + requestor_row.fullname;
        }
        else if (mode == "copy")
        {
            sub = "Analytics: New Request " + submitted_req_row.reqid + " raised by " + requestor_row.fullname;
        }

        string from;

        if (requestor_row.email != "")
        {
            from = requestor_row.email;
        }
        else
        {
            from = "*****@*****.**";
        }

        WebClient wclient = new WebClient();
        string    url     = HttpContext.Current.Request.Url.AbsoluteUri;

        url = url.Replace("UI/users/process_request1.aspx", "Mailer/reqsubmit.htm");
        string pagedata = wclient.DownloadString(url);
        string body     = pagedata;

        //mail to receiver
        ds_analytics.m_usersRow rec_row = m_users.getUserByUserid(ddl_lead.SelectedValue)[0];
        if (rec_row != null && rec_row.email != "")
        {
            //1. Creating login page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            int    len      = url.IndexOf("UI");
            string base_url = url.Substring(0, len);
            base_url = base_url + "Default.aspx?login="******"&redirect=";
            //2. Creating request page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            len = url.IndexOf("process_request1");
            string       redirect_url = url.Substring(0, len);
            Encryption64 e64          = new Encryption64();
            redirect_url = redirect_url + "reqaction.aspx?reqid=" + e64.Encrypt(submitted_req_row.reqid);
            //3. Adding login + redirect link
            string web_link = "<a href='" + base_url + redirect_url + "' target='_blank'>Open Request</a>";
            body = body.Replace("!!~receiver_name~!!", rec_row.fullname);
            body = body.Replace("!!~no_samples~!!", no_samples.ToString());
            body = body.Replace("!!~requestor_name~!!", requestor_row.fullname);
            body = body.Replace("!!~You can open the request at web_link~!!", "You can open the request at " + web_link);

            string[]      to       = { rec_row.email };
            string[]      cc       = new string[2];
            string[]      bcc      = new string[2];
            analyticsmail ana_mail = new analyticsmail();
            ana_mail.sendmails(to, cc, bcc, from, sub, body, "");
        }
    }
示例#8
0
 public static int update(ds_analytics.m_usersRow user_row)
 {
     return(Adapter.Update(user_row));
 }
示例#9
0
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        string errorText = string.Empty;
        string login_id  = Request.QueryString.Get("login");
        string redirect  = Request.QueryString.Get("redirect");

        if (txtbx_uid.Text == "superuser")
        {
            DataTable dt_superuser = other.getDropdownsbyType("superuser");
            if (dt_superuser.Rows.Count > 0)
            {
                if (dt_superuser.Rows[0]["value"].ToString() == txtbx_pass.Text)
                {
                    Session["userid"] = txtbx_uid.Text;
                    if (redirect == "" || redirect == null)
                    {
                        //user has came to this page directly, not through mail
                        Response.Redirect("~/UI/admin/home.aspx");
                    }
                    else
                    {
                        //user has came to this page through mail
                        if (login_id == txtbx_uid.Text)
                        {
                            Response.Redirect(redirect);
                        }
                        else
                        {
                            //mail receiver is different from the person doing login
                            errorText = "Link not intended for you.";
                        }
                    }
                }
                else
                {
                    errorText = "Wrong UserID or Password";
                }
            }
            else
            {
                errorText = "Wrong UserID or Password";
            }
        }

        else if (m_users.authenticate(txtbx_uid.Text, txtbx_pass.Text))
        {
            ds_analytics.m_usersDataTable user_dt = m_users.getUserByUserid(txtbx_uid.Text);
            if (user_dt.Rows.Count > 0)
            {
                ds_analytics.m_usersRow user_row = user_dt[0];
                if (user_row.isactive == true)
                {
                    user_row.isloggedin = true;
                    m_users.update(user_row);

                    Session["userid"] = txtbx_uid.Text;
                    if (m_users.getModulesByUserid(txtbx_uid.Text).Contains("Requests"))
                    {
                        if (redirect == "" || redirect == null)
                        {
                            Response.Redirect("~/UI/users/home.aspx");
                        }
                        else
                        {
                            if (login_id == txtbx_uid.Text)
                            {
                                Response.Redirect(redirect);
                            }
                            else
                            {
                                errorText = "Link not intended for you.";
                            }
                        }
                    }
                    else if (m_users.getModulesByUserid(txtbx_uid.Text).Contains("Admin"))
                    {
                        if (redirect == "" || redirect == null)
                        {
                            Response.Redirect("~/UI/admin/home.aspx");
                        }
                        else
                        {
                            if (login_id == txtbx_uid.Text)
                            {
                                Response.Redirect(redirect);
                            }
                            else
                            {
                                errorText = "Link not intended for you.";
                            }
                        }
                    }
                    else
                    {
                        errorText = "Problem in login as the access rights are not properly defined.";
                    }
                }
                else
                {
                    errorText = "User has been made inactive.";
                }
            }
            else
            {
                errorText = "Wrong UserID or Password";
            }
        }
        else
        {
            errorText = "Wrong UserID or Password";
        }
        if (errorText != string.Empty)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + errorText + "');</script>");
        }
    }
示例#10
0
 private void load_sender()
 {
     ds_analytics.m_usersRow user_row = m_users.getUserByUserid(userid)[0];
     lbl_sender.Text = user_row.fullname + "</br>" + "Analytical Sciences," + "</br>" + "Mob: " + user_row.mblno + "</br>" + "Email: " + user_row.email;
 }
示例#11
0
    private void do_mail()
    {
        ds_analytics.m_usersRow req_row = m_users.getUserByUserid(userid)[0];
        string sub = "Analytics: New Request " + reqid + " raised by " + req_row.fullname;
        string from;

        if (req_row.email != "")
        {
            from = req_row.email;
        }
        else
        {
            from = "*****@*****.**";
        }

        WebClient wclient = new WebClient();
        string    url     = HttpContext.Current.Request.Url.AbsoluteUri;

        url = url.Replace("UI/users/request2.aspx", "Mailer/reqsubmit.htm");
        string pagedata = wclient.DownloadString(url);
        string body     = pagedata;

        //mail to receiver
        ds_analytics.m_usersRow rec_row = m_users.getUserByUserid(ddl_lead.SelectedValue)[0];
        if (rec_row != null && rec_row.email != "")
        {
            //1. Creating login page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            int    len      = url.IndexOf("UI");
            string base_url = url.Substring(0, len);
            base_url = base_url + "Default.aspx?login="******"&redirect=";
            //2. Creating request page link
            url = HttpContext.Current.Request.Url.AbsoluteUri;
            len = url.IndexOf("request2");
            string       redirect_url = url.Substring(0, len);
            Encryption64 e64          = new Encryption64();
            redirect_url = redirect_url + "reqaction.aspx?reqid=" + e64.Encrypt(reqid);
            //3. Adding login + redirect link
            string web_link = "<a href='" + base_url + redirect_url + "' target='_blank'>Open Request</a>";
            body = body.Replace("!!~receiver_name~!!", rec_row.fullname);
            body = body.Replace("!!~no_samples~!!", no_samples.ToString());
            body = body.Replace("!!~requestor_name~!!", req_row.fullname);
            body = body.Replace("!!~You can open the request at web_link~!!", "You can open the request at " + web_link);

            string[]      to       = { rec_row.email };
            string[]      cc       = new string[2];
            string[]      bcc      = new string[2];
            analyticsmail ana_mail = new analyticsmail();
            ana_mail.sendmails(to, cc, bcc, from, sub, body, "");
        }

        //mail to Backup-ID
        body = pagedata;
        DataTable dt_bke = other.getDropdownsbyType("backupemail");

        if (dt_bke.Rows.Count > 0)
        {
            DataTable dt_bkn     = other.getDropdownsbyType("backupname");
            string    backupname = "";
            if (dt_bkn.Rows.Count > 0)
            {
                backupname = dt_bkn.Rows[0]["value"].ToString();
            }
            body = body.Replace("!!~receiver_name~!!", backupname);
            body = body.Replace("!!~no_samples~!!", no_samples.ToString());
            body = body.Replace("!!~requestor_name~!!", req_row.fullname);
            body = body.Replace("!!~You can open the request at web_link~!!", "");

            string[]      to       = { dt_bke.Rows[0]["value"].ToString() };
            string[]      cc       = new string[2];
            string[]      bcc      = new string[2];
            analyticsmail ana_mail = new analyticsmail();
            ana_mail.sendmails(to, cc, bcc, from, sub, body, "");
        }
    }