コード例 #1
0
ファイル: ProcedureLogic.cs プロジェクト: nampn/ODental
        ///<summary>The supplied DataRows must include the following columns: ProcStatus(optional),Priority(optional),ToothRange,ToothNum,ProcCode.  This sorts procedures based on priority, then tooth number, then procCode.  It does not care about dates or status.  Currently used in TP module and Chart module sorting.</summary>
        public static int CompareProcedures(DataRow x, DataRow y)
        {
            //first, by status
            if (x.Table.Columns.Contains("ProcStatus") && y.Table.Columns.Contains("ProcStatus"))
            {
                if (x["ProcStatus"].ToString() != y["ProcStatus"].ToString())
                {
                    //Cn,TP,R,EO,EC,C,D
                    int xIdx = 0;
                    switch (x["ProcStatus"].ToString())
                    {
                    case "7":                            //Cn
                        xIdx = 0;
                        break;

                    case "1":                            //TP
                        xIdx = 1;
                        break;

                    case "5":                            //R
                        xIdx = 2;
                        break;

                    case "4":                            //EO
                        xIdx = 3;
                        break;

                    case "3":                            //EC
                        xIdx = 4;
                        break;

                    case "2":                            //C
                        xIdx = 5;
                        break;

                    case "6":                            //D
                        xIdx = 6;
                        break;
                    }
                    int yIdx = 0;
                    switch (y["ProcStatus"].ToString())
                    {
                    case "7":                            //Cn
                        yIdx = 0;
                        break;

                    case "1":                            //TP
                        yIdx = 1;
                        break;

                    case "5":                            //R
                        yIdx = 2;
                        break;

                    case "4":                            //EO
                        yIdx = 3;
                        break;

                    case "3":                            //EC
                        yIdx = 4;
                        break;

                    case "2":                            //C
                        yIdx = 5;
                        break;

                    case "6":                            //D
                        yIdx = 6;
                        break;
                    }
                    return(xIdx.CompareTo(yIdx));
                }
            }
            //by priority
            if (x.Table.Columns.Contains("Priority") && y.Table.Columns.Contains("Priority"))
            {
                if (x["Priority"].ToString() != y["Priority"].ToString())               //if priorities are different
                {
                    if (x["Priority"].ToString() == "0")
                    {
                        return(1);                       //x is greater than y. Priorities always come first.
                    }
                    if (y["Priority"].ToString() == "0")
                    {
                        return(-1);                       //x is less than y. Priorities always come first.
                    }
                    return(DefC.GetOrder(DefCat.TxPriorities, PIn.Long(x["Priority"].ToString())).CompareTo
                               (DefC.GetOrder(DefCat.TxPriorities, PIn.Long(y["Priority"].ToString()))));
                }
            }
            //priorities are the same, so sort by toothrange
            if (x["ToothRange"].ToString() != y["ToothRange"].ToString())
            {
                //empty toothranges come before filled toothrange values
                return(x["ToothRange"].ToString().CompareTo(y["ToothRange"].ToString()));
            }
            //toothranges are the same (usually empty), so compare toothnumbers
            if (x["ToothNum"].ToString() != y["ToothNum"].ToString())
            {
                //this also puts invalid or empty toothnumbers before the others.
                return(Tooth.ToInt(x["ToothNum"].ToString()).CompareTo(Tooth.ToInt(y["ToothNum"].ToString())));
            }
            //priority and toothnums are the same, so sort by proccode.
            return(x["ProcCode"].ToString().CompareTo(y["ProcCode"].ToString()));
            //return 0;//priority, tooth number, and proccode are all the same
        }
コード例 #2
0
ファイル: Documents.cs プロジェクト: nampn/ODental
        public static DataTable GetTreeListTableForPatient(string patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), patNum));
            }
            DataConnection dcon  = new DataConnection();
            DataTable      table = new DataTable("DocumentList");
            DataRow        row;
            DataTable      raw;
            string         command;
            //Rows are first added to the resultSet list so they can be sorted at the end as a larger group, then
            //they are placed in the datatable to be returned.
            List <Object> resultSet = new List <Object>();

            //columns that start with lowercase are altered for display rather than being raw data.
            table.Columns.Add("DocNum");
            table.Columns.Add("MountNum");
            table.Columns.Add("DocCategory");
            table.Columns.Add("DateCreated");
            table.Columns.Add("docFolder");            //The folder order to which the Document category corresponds.
            table.Columns.Add("description");
            table.Columns.Add("ImgType");
            //Move all documents which are invisible to the first document category.
            command = "SELECT DocNum FROM document WHERE PatNum='" + patNum + "' AND "
                      + "DocCategory<0";
            raw = dcon.GetTable(command);
            if (raw.Rows.Count > 0)          //Are there any invisible documents?
            {
                command = "UPDATE document SET DocCategory='" + DefC.GetList(DefCat.ImageCats)[0].DefNum
                          + "' WHERE PatNum='" + patNum + "' AND (";
                for (int i = 0; i < raw.Rows.Count; i++)
                {
                    command += "DocNum='" + PIn.Long(raw.Rows[i]["DocNum"].ToString()) + "' ";
                    if (i < raw.Rows.Count - 1)
                    {
                        command += "OR ";
                    }
                }
                command += ")";
                dcon.NonQ(command);
            }
            //Load all documents into the result table.
            command = "SELECT DocNum,DocCategory,DateCreated,Description,ImgType,MountItemNum FROM document WHERE PatNum='" + patNum + "'";
            raw     = dcon.GetTable(command);
            for (int i = 0; i < raw.Rows.Count; i++)
            {
                //Make sure hidden documents are never added (there is a small possibility that one is added after all are made visible).
                if (DefC.GetOrder(DefCat.ImageCats, PIn.Long(raw.Rows[i]["DocCategory"].ToString())) < 0)
                {
                    continue;
                }
                //Do not add individual documents which are part of a mount object.
                if (PIn.Long(raw.Rows[i]["MountItemNum"].ToString()) != 0)
                {
                    continue;
                }
                row                = table.NewRow();
                row["DocNum"]      = PIn.Long(raw.Rows[i]["DocNum"].ToString());
                row["MountNum"]    = 0;
                row["DocCategory"] = PIn.Long(raw.Rows[i]["DocCategory"].ToString());
                row["DateCreated"] = PIn.Date(raw.Rows[i]["DateCreated"].ToString());
                row["docFolder"]   = DefC.GetOrder(DefCat.ImageCats, PIn.Long(raw.Rows[i]["DocCategory"].ToString()));
                row["description"] = PIn.Date(raw.Rows[i]["DateCreated"].ToString()).ToString("d") + ": "
                                     + PIn.String(raw.Rows[i]["Description"].ToString());
                row["ImgType"] = PIn.Long(raw.Rows[i]["ImgType"].ToString());
                resultSet.Add(row);
            }
            //Move all mounts which are invisible to the first document category.
            command = "SELECT MountNum FROM mount WHERE PatNum='" + patNum + "' AND "
                      + "DocCategory<0";
            raw = dcon.GetTable(command);
            if (raw.Rows.Count > 0)           //Are there any invisible mounts?
            {
                command = "UPDATE mount SET DocCategory='" + DefC.GetList(DefCat.ImageCats)[0].DefNum
                          + "' WHERE PatNum='" + patNum + "' AND (";
                for (int i = 0; i < raw.Rows.Count; i++)
                {
                    command += "MountNum='" + PIn.Long(raw.Rows[i]["MountNum"].ToString()) + "' ";
                    if (i < raw.Rows.Count - 1)
                    {
                        command += "OR ";
                    }
                }
                command += ")";
                dcon.NonQ(command);
            }
            //Load all mounts into the result table.
            command = "SELECT MountNum,DocCategory,DateCreated,Description,ImgType FROM mount WHERE PatNum='" + patNum + "'";
            raw     = dcon.GetTable(command);
            for (int i = 0; i < raw.Rows.Count; i++)
            {
                //Make sure hidden mounts are never added (there is a small possibility that one is added after all are made visible).
                if (DefC.GetOrder(DefCat.ImageCats, PIn.Long(raw.Rows[i]["DocCategory"].ToString())) < 0)
                {
                    continue;
                }
                row                = table.NewRow();
                row["DocNum"]      = 0;
                row["MountNum"]    = PIn.Long(raw.Rows[i]["MountNum"].ToString());
                row["DocCategory"] = PIn.Long(raw.Rows[i]["DocCategory"].ToString());
                row["DateCreated"] = PIn.Date(raw.Rows[i]["DateCreated"].ToString());
                row["docFolder"]   = DefC.GetOrder(DefCat.ImageCats, PIn.Long(raw.Rows[i]["DocCategory"].ToString()));
                row["description"] = PIn.Date(raw.Rows[i]["DateCreated"].ToString()).ToString("d") + ": "
                                     + PIn.String(raw.Rows[i]["Description"].ToString());
                row["ImgType"] = PIn.Long(raw.Rows[i]["ImgType"].ToString());
                resultSet.Add(row);
            }
            //We must sort the results after they are returned from the database, because the database software (i.e. MySQL)
            //cannot return sorted results from two or more result sets like we have here.
            resultSet.Sort(delegate(Object o1, Object o2) {
                DataRow r1     = (DataRow)o1;
                DataRow r2     = (DataRow)o2;
                int docFolder1 = Convert.ToInt32(r1["docFolder"].ToString());
                int docFolder2 = Convert.ToInt32(r2["docFolder"].ToString());
                if (docFolder1 < docFolder2)
                {
                    return(-1);
                }
                else if (docFolder1 > docFolder2)
                {
                    return(1);
                }
                return(PIn.Date(r1["DateCreated"].ToString()).CompareTo(PIn.Date(r2["DateCreated"].ToString())));
            });
            //Finally, move the results from the list into a data table.
            for (int i = 0; i < resultSet.Count; i++)
            {
                table.Rows.Add((DataRow)resultSet[i]);
            }
            return(table);
        }