Ejemplo n.º 1
0
    protected void gridDocs_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        var x = e;

        bool results_docVers = DxDbOps.BuildUpdateSqlCode(e, "tblDocVers", "backend");


        OrderedDictionary oldvals = e.OldValues;
        OrderedDictionary newvals = e.NewValues;
        OrderedDictionary keys    = new OrderedDictionary();

        keys.Add("DocID", oldvals["DocID"]);

        bool results_doc = DxDbOps.BuildUpdateSqlCode(keys, newvals, oldvals, "tblDoc", "backend");


        int measureID = Convert.ToInt32(Request.QueryString["mID"]);

        LoadDocs(measureID);

        e.Cancel = true;
        gridDocs.CancelEdit();

        //		gridDocs.EndUpdate();
    }
Ejemplo n.º 2
0
    protected void dxgrid_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildUpdateSqlCode(e, "tblStaff", "backend");
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 3
0
    protected void gv_pubs_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildInsertSqlCode(e, "tblPub", "backend", "dbo");
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 4
0
    protected void dxgrid_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildUpdateSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 5
0
    protected void gv_pubvar_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildDeleteSqlCode(e, "tblPubVar", "backend", "dbo");
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 6
0
    protected void gridLinkedREDCapForm_OnRowDeleting(object sender, ASPxDataDeletingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildDeleteSqlCode(e, "REDCap_Form", "data", "def");
        gv.CancelEdit();
        e.Cancel = true;
        Session["LinkedREDCapForm"] = null;

        LoadlinkedTables();
    }
Ejemplo n.º 7
0
    protected void dxgrid_OnRowDeleting(object sender, ASPxDataDeletingEventArgs e)
    {
        bool         proceed_as_normal = true;
        ASPxGridView gv     = (ASPxGridView)sender;
        string       result = "Error (uninitialized.)";

        #region Conditions for specific grids
        //For people, first check if there are any subjects
        if (gv.ClientInstanceName == "grid_tblgroup")
        {
            var       pk  = e.Keys[0];
            SQL_utils sql = new SQL_utils("backend");
            int       n   = sql.IntScalar_from_SQLstring("select count(*) from tblSubject where groupID=" + pk.ToString());

            if (n > 0)
            {
                string study   = (n == 1) ? " study" : " studies";
                string subject = (n == 1) ? " this subject" : " these subjects";
                string msg     = "This group is assigned to " + n.ToString() + " subjects.  Please delete these first.";
                result            = msg;
                proceed_as_normal = false;
            }
            else
            {
                try
                {
                    sql.NonQuery_from_SQLstring("delete from tblStudyActionGroup where groupID=" + pk.ToString());
                    sql.NonQuery_from_SQLstring("delete from tblStudyMeasGroup where groupID=" + pk.ToString());
                    sql.NonQuery_from_SQLstring("delete from tblLabGroup_Staff where labgroupID in (select labgroupID from tblLabGroup where groupID=" + pk.ToString() + ")");
                    sql.NonQuery_from_SQLstring("delete from tblLabGroup where groupID =" + pk.ToString());
                }
                catch (Exception ex)
                { }
            }
            sql.Close();
        }


        #endregion


        if (proceed_as_normal)
        {
            result = DxDbOps.BuildDeleteSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");
        }


        //
        ((ASPxGridView)sender).JSProperties["cpIsUpdated"] = String.Format("DELETED.{0}", result);
        gv.CancelEdit();
        e.Cancel = true;

        RefreshGrids();
    }
Ejemplo n.º 8
0
    protected void gridDict_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildUpdateSqlCode(e, "fld", "data", "def");
        //((ASPxGridView) sender).JSProperties["cpIsUpdated"] = gv.ClientInstanceName.ToString();
        gv.CancelEdit();
        e.Cancel = true;

        gridDict.DataBind();
    }
Ejemplo n.º 9
0
    protected void gridLinkedImportTbl_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        DxDbOps.BuildInsertSqlCode(e, "LinkedImportTbl", "data", "def");
        gv.CancelEdit();
        e.Cancel = true;
        Session["LinkedImports"]    = null;
        Session["LinkedImportTbls"] = null;

        LoadlinkedTables();
    }
Ejemplo n.º 10
0
    protected void dxgridPeople_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        //Add HouseholdID

        e.NewValues.Add("HouseholdID", Request.QueryString["hhID"]);

        bool result = DxDbOps.BuildInsertSqlCode(e, "tblPerson", "backend");

        ASPxGridView gv = (ASPxGridView)sender;

        gv.CancelEdit();
        e.Cancel = true;
        //test
    }
Ejemplo n.º 11
0
    protected void gridVallabels_BatchUpdate(object sender, DevExpress.Web.Data.ASPxDataBatchUpdateEventArgs e)
    {
        if (e.InsertValues.Count > 0)
        {
            foreach (var args in e.InsertValues)
            {
                var x = hidFieldValueSetID.Value;
                args.NewValues.Add("fieldvaluesetID", x);
            }
        }
        string results = DxDbOps.ProcessBatch(e, "datFieldValueSetItem", "data", "dbo");

        e.Handled = true;
    }
Ejemplo n.º 12
0
    protected void dxgrid_OnRowUpdating(object sender, ASPxDataUpdatingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        //For changes to ActionText
        if (gv.ID == "grid_tblstudyaction")
        {
            string pkfld   = "";
            int    pkvalue = -1;

            foreach (DictionaryEntry key in e.Keys)
            {
                pkfld   = key.Key.ToString();
                pkvalue = Convert.ToInt32(key.Value);
            }

            if (pkvalue > 0 && pkfld == "studyactionID")
            {
                foreach (DictionaryEntry newentry in e.NewValues)
                {
                    foreach (DictionaryEntry oldentry in e.OldValues)
                    {
                        var newfld = newentry.Key.ToString().ToLower();
                        var oldfld = oldentry.Key.ToString().ToLower();

                        if (newentry.Key == oldentry.Key && newentry.Key.ToString() == "actiontext")
                        {
                            var newval = (newentry.Value == null) ? null : newentry.Value.ToString();
                            var oldval = (oldentry.Value == null) ? null : oldentry.Value.ToString();

                            if (newval != oldval)
                            {
                                SQL_utils sql     = new SQL_utils("backend");
                                string    sqlcode = String.Format("update tblAction set actiontext=replace(actiontext,'{0}','{1}') where studyactionID={2}"
                                                                  , oldval, newval, pkvalue);

                                sql.NonQuery_from_SQLstring(sqlcode);
                            }
                        }
                    }
                }
            }
        }
        DxDbOps.BuildUpdateSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");

        ((ASPxGridView)sender).JSProperties["cpIsUpdated"] = gv.ClientInstanceName.ToString();
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 13
0
    protected void gridDict_OnRowDeleting(object sender, ASPxDataDeletingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        SQL_utils sql   = new SQL_utils("data");
        int       tblpk = sql.IntScalar_from_SQLstring("select tblpk from def.tbl where measureID=" + Request.QueryString["mID"]);



        DxDbOps.BuildDeleteSqlCode(e, "fld", "data", "def");
        //((ASPxGridView)sender).JSProperties["cpIsUpdated"] = gv.ClientInstanceName.ToString();
        gv.CancelEdit();
        e.Cancel = true;

        gridDict.DataBind();
    }
Ejemplo n.º 14
0
    protected void SaveButton_OnClick(object sender, EventArgs e)
    {
        int measureID          = Convert.ToInt32(Request.QueryString["mID"]);
        OrderedDictionary keys = new OrderedDictionary();

        keys.Add("measureID", measureID);

        OrderedDictionary newvalues = new DxDbOps.FormLayoutNewValues((ASPxFormLayout)FormLayout);

        newvalues.Add("measureID", measureID);

        OrderedDictionary oldvalues = (OrderedDictionary)Session["formlayoutoldvalues"];

        bool outcome  = DxDbOps.BuildUpdateSqlCode(keys, newvalues, oldvalues, "tblMeasure", "backend", "dbo");
        bool outcome2 = DxDbOps.BuildUpdateSqlCode(keys, newvalues, oldvalues, "tbl", "data", "def");

        LoadMeasureInfo(measureID);
    }
Ejemplo n.º 15
0
    protected void gridEditStaff_BatchUpdate(object sender, ASPxDataBatchUpdateEventArgs e)
    {
        int staffID = Convert.ToInt32(gridStaffList.GetSelectedFieldValues("staffID").First());

        List <bool> results = new List <bool>();

        foreach (ASPxDataUpdateValues args in e.UpdateValues)
        {
            if (Convert.ToInt32(args.Keys[0].ToString()) < 0)
            {
                //Add staffID to the NewValues
                //int staffID = Convert.ToInt32(cboStaffInLab.Value.ToString());



                args.NewValues["staffID"] = staffID;

                bool result = DxDbOps.BuildInsertSqlCode(args.NewValues, "tbllabgroup_staff", "backend");
                results.Add(result);

                if (result)
                {
                    needrefresh = true;
                }
            }
            else
            {
                bool result = DxDbOps.BuildUpdateSqlCode(args, "tbllabgroup_staff", "backend");
                results.Add(result);
                if (result)
                {
                    needrefresh = true;
                }
            }
        }


        DataTable dt = GetStaffToEdit(staffID);

        Session["labgroups_staff"] = dt;

        e.Handled = true;
    }
Ejemplo n.º 16
0
    protected void btnCreateNewValueSet_Click(object sender, EventArgs e)
    {
        string valuesetname = txtNewValueSet.Text;
        int    x            = 0;

        //Create new ValueSet and populate with 1 dummy value;
        bool addDummyItem = true;
        //string valuelabel = "New Value Labels for " + lblMeasName.Text;
        SQL_utils sql      = new SQL_utils("data");
        int       newfvsID = DxDbOps.CreateValueSet(sql, valuesetname, addDummyItem, new List <string>());

        var fldpk = hidField["fldpk"];

        string code = String.Format("update def.fld set fieldvaluesetID={0} where fldpk={1}", newfvsID, fldpk);

        sql.NonQuery_from_SQLstring(code);

        sql.Close();
    }
Ejemplo n.º 17
0
    protected void dxgrid_OnRowDeleting(object sender, ASPxDataDeletingEventArgs e)
    {
        bool         proceed_as_normal = true;
        ASPxGridView gv     = (ASPxGridView)sender;
        string       result = "Error (uninitialized.)";

        #region Conditions for specific grids
        //For people, first check if there are any subjects
        if (gv.ClientInstanceName == "dxgridPeople")
        {
            var personID = e.Keys[0];

            SQL_utils sql = new SQL_utils("backend");

            string personid = hidPersonID.Value.ToString();
            int    nsubj    = sql.IntScalar_from_SQLstring("select count(*) from tblSubject where personID=" + personID.ToString());
            sql.Close();

            if (nsubj > 0)
            {
                string study   = (nsubj == 1) ? " study" : " studies";
                string subject = (nsubj == 1) ? " this subject" : " these subjects";

                string msg = "This person is assigned to " + nsubj.ToString() + study + ".  Please delete" + subject + " first.";

                result            = msg;
                proceed_as_normal = false;
            }
        }
        #endregion


        if (proceed_as_normal)
        {
            result = DxDbOps.BuildDeleteSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");
        }

        //
        ((ASPxGridView)sender).JSProperties["cpIsUpdated"] = result;
        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 18
0
    protected void dxgrid_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        e.NewValues.Add("HouseholdID", Request.QueryString["hhID"]);
        bool execute = false;


        if (Master.Master_studyID > 0)
        {
            e.NewValues.Add("studyID", Master.Master_studyID.ToString());
            execute = true;
        }
        else
        {
            SQL_utils sql        = new SQL_utils("backend");
            int       hh_studyID = sql.IntScalar_from_SQLstring(
                "select top 1 studyID from trk.vwMasterStatus_S where householdID = " + Request.QueryString["hhID"] + " group by studyID order by count(*)  desc"
                );
            if (hh_studyID > 0)
            {
                sql.NonQuery_from_SQLstring("update tblStaff set defaultstudyID = " + hh_studyID.ToString() + " where  actdirID = sec.systemuser()");
                e.NewValues.Add("studyID", hh_studyID.ToString());
                execute = true;
            }
            sql.Close();
        }

        if (execute)
        {
            DxDbOps.BuildInsertSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");
            gv.CancelEdit();
            e.Cancel = true;
        }
        else
        {
            gv.CancelEdit();
            e.Cancel = true;
        }
    }
Ejemplo n.º 19
0
    protected void dxgrid_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        string shortname = String.Format("{0}{1}"
                                         , e.NewValues["firstname"].ToString().Substring(0, 1)
                                         , e.NewValues["lastname"].ToString());

        string staffinits = String.Format("{0}{1}"
                                          , e.NewValues["firstname"].ToString().Substring(0, 1)
                                          , e.NewValues["lastname"].ToString().Substring(0, 1));

        e.NewValues.Add("active", "1");
        e.NewValues.Add("staffshortname", shortname);
        e.NewValues.Add("staffinits", staffinits);


        bool result = DxDbOps.BuildInsertSqlCode(e, "tblStaff", "backend");

        gv.CancelEdit();
        e.Cancel = true;
    }
Ejemplo n.º 20
0
    protected void gridLinkedREDCapForm_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv      = (ASPxGridView)sender;
        SQL_utils    sql     = new SQL_utils("data");
        string       sqlcode = String.Format("select min(tokenID) from def.vwREDCap_Form where studyID={0} and measureID={1}",
                                             Session["studyID"].ToString(), cboMeas.Value.ToString());
        int tokenid = sql.IntScalar_from_SQLstring(sqlcode);

        sql.Close();

        int measureID = Convert.ToInt32(cboMeas.Value.ToString());

        e.NewValues.Add("tokenid", tokenid);
        e.NewValues.Add("measureid", measureID);


        DxDbOps.BuildInsertSqlCode(e, "REDCap_Form", "data", "def");
        gv.CancelEdit();
        e.Cancel = true;
        Session["LinkedREDCapForm"] = null;

        LoadlinkedTables();
    }
Ejemplo n.º 21
0
    protected void DeleteSubject(object sender, EventArgs e)
    {
        if (Convert.ToInt32(ddl_delSubj1.SelectedValue) == Convert.ToInt32(ddl_delSubj2.SelectedValue))
        {
            int subjID = Convert.ToInt32(ddl_delSubj1.SelectedValue);

            SQL_utils sql = new SQL_utils("backend");

            try{
                var del1 = DxDbOps.BuildDeleteSqlCode("tblstudymeassubj", "backend", "subjID", subjID);


                sql.NonQuery_from_SQLstring("update uwautism_research_backend.dbo.tblstudymeassubj set actionid = null where subjid = " + subjID.ToString());

//tblSubject
//tblaction
//tblReliabilityTracking
//tblSubjConsent
//tblstudymeassubj

                var del2 = DxDbOps.BuildDeleteSqlCode("tblapptstaff", "backend", "actionID in (select actionID from tblaction where subjID = " + subjID.ToString() + ")");
                var del3 = DxDbOps.BuildDeleteSqlCode("tblSubjConsentitem", "backend", "subjconsentid in (select subjconsentid from uwautism_research_backend.dbo.tblSubjConsent where subjid = " + subjID.ToString() + ")");
                var del4 = DxDbOps.BuildDeleteSqlCode("tblSubjConsent", "backend", "subjID", subjID);
                var del5 = DxDbOps.BuildDeleteSqlCode("tblReliabilityTracking", "backend", "subjID", subjID);
                var del6 = DxDbOps.BuildDeleteSqlCode("tblaction", "backend", "subjID", subjID);
                var del7 = DxDbOps.BuildDeleteSqlCode("tblSubject", "backend", "subjID", subjID);

                error_label.Text = "Subject deleted.";

                btnDelete.Visible = false;
            }
            catch (SqlException exc)
            {
                error_label.Text = exc.Message;
            }


            //SQL_utils sql = new SQL_utils("backend");
            //List<SqlParameter> ps = new List<SqlParameter>();
            //ps.Add(sql.CreateParam("subjID", ddl_delSubj1.SelectedValue, "int"));
            //ps.Add(sql.CreateParam("code", "Confirm deletion of " + Convert.ToString(ddl_delSubj1.SelectedValue), "text"));


            //try
            //{
            //	sql.NonQuery_from_ProcName("spDeleteSubject_from_web", ps);

            //}
            //catch (SqlException exc)
            //{
            //	error_label.Text = exc.Message;
            //}

            sql.Close();

            Populate_delSubj_ID_DDL();

            btnReset.Visible  = false;
            btnDelete.Visible = false;
            txtDelete.Text    = "";

            UpdatePanel01.Update();
        }
    }
Ejemplo n.º 22
0
    protected void dxgrid_OnRowInserting(object sender, ASPxDataInsertingEventArgs e)
    {
        ASPxGridView gv = (ASPxGridView)sender;

        e.NewValues.Add("HouseholdID", Request.QueryString["hhID"]);
        e.NewValues.Add("studyID", Master.Master_studyID.ToString());

        int       newgroupID = -1;
        int       staffID    = -1;
        int       labID      = -1;
        SQL_utils sql        = new SQL_utils("backend");

        if (gv.ClientInstanceName == "grid_tblgroup")
        {
            newgroupID             = sql.IntScalar_from_SQLstring("select max(groupID) + 1 from tblGroup");
            staffID                = sql.IntScalar_from_SQLstring("select sec.systemuser_staffID()");
            labID                  = sql.IntScalar_from_SQLstring("select labID from tblStudy where studyID=" + Master.Master_studyID.ToString());
            e.NewValues["groupID"] = newgroupID;
        }

        if (gv.ClientInstanceName == "grid_tblSSD")
        {
            int ssID = Convert.ToInt32(gv.GetMasterRowFieldValues("ssID").ToString());
            if (ssID > 0)
            {
                e.NewValues["ssID"] = ssID;
            }
        }


        DxDbOps.BuildInsertSqlCode(e, GridnameToTable(gv.ClientInstanceName), "backend");


        if (gv.ClientInstanceName == "grid_tblgroup")
        {
            if (newgroupID > 0 & staffID > 0 & labID > 0)
            {
                // Add the group to this lab
                string sqlcode = String.Format("insert into tbllabgroup(groupID, labID, labgroup_enabled) values({0},{1},{2})"
                                               , newgroupID.ToString(), labID, "1");
                sql.NonQuery_from_SQLstring(sqlcode);

                int labgroupID = sql.IntScalar_from_SQLstring(String.Format("select labgroupID from tbllabgroup where groupID={0} and labID={1}", newgroupID, labID));

                if (labgroupID > 0)
                {
                    // Add the group to this staff
                    string sqlcode2 = String.Format("insert into tbllabgroup_staff(StaffID, LabGroupID , DBroleID) values({0}, {1}, {2})"
                                                    , staffID, labgroupID, "1");
                    sql.NonQuery_from_SQLstring(sqlcode2);
                }
            }
        }


        ((ASPxGridView)sender).JSProperties["cpIsUpdated"] = gv.ClientInstanceName.ToString();
        gv.CancelEdit();
        e.Cancel = true;

        RefreshGrids();
    }