Example #1
0
        ///<summary>The only allowed parameters are "InnoDB" or "MyISAM".  Converts tables to toEngine type and returns the number of tables converted.</summary>
        public static int ConvertTables(string fromEngine, string toEngine)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), fromEngine, toEngine));
            }
            int    numtables = 0;
            string command   = "SELECT DATABASE()";
            string database  = Db.GetScalar(command);

            command = @"SELECT table_name
				FROM information_schema.tables
				WHERE table_schema='"                 + POut.String(database) + "' AND information_schema.tables.engine='" + fromEngine + "'";
            DataTable results = Db.GetTable(command);

            command = "";
            if (results.Rows.Count == 0)
            {
                return(numtables);
            }
            for (int i = 0; i < results.Rows.Count; i++)
            {
                command += "ALTER TABLE `" + database + "`.`" + results.Rows[i]["table_name"].ToString() + "` ENGINE='" + toEngine + "'; ";
                numtables++;
            }
            Db.NonQ(command);
            return(numtables);
        }
Example #2
0
        ///<summary>returns int32</summary>
        public static int GetUniqueFileNum()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            string    command     = "SELECT ValueString FROM preference WHERE PrefName='TrojanExpressCollectPreviousFileNumber'";
            DataTable table       = Db.GetTable(command);
            int       previousNum = PIn.Int(table.Rows[0][0].ToString());
            int       thisNum     = previousNum + 1;

            command = "UPDATE preference SET ValueString='" + POut.Long(thisNum) +
                      "' WHERE PrefName='TrojanExpressCollectPreviousFileNumber'"
                      + " AND ValueString='" + POut.Long(previousNum) + "'";
            int result = Db.NonQ32(command);

            while (result != 1)           //someone else sent one at the same time
            {
                previousNum++;
                thisNum++;
                command = "UPDATE preference SET ValueString='" + POut.Long(thisNum) +
                          "' WHERE PrefName='TrojanExpressCollectPreviousFileNumber'"
                          + " AND ValueString='" + POut.Long(previousNum) + "'";
                result = Db.NonQ32(command);
            }
            return(thisNum);
        }
Example #3
0
        public static int GetPhoneExtension(string ipAddress, string computerName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), ipAddress, computerName));
            }
            string          command = "SELECT * FROM phoneempdefault WHERE ComputerName='" + POut.String(computerName) + "'";
            PhoneEmpDefault ped     = Crud.PhoneEmpDefaultCrud.SelectOne(command);

            if (ped != null)
            {
                return(ped.PhoneExt);
            }
            //there is no computername override entered by staff, so figure out what the extension should be
            int extension = 0;

            if (ipAddress.Contains("192.168.0.2"))
            {
                return(PIn.Int(ipAddress.ToString().Substring(10)) - 100);             //eg 205-100=105
            }
            else if (ipAddress.ToString().Contains("10.10.20.1"))
            {
                return(PIn.Int(ipAddress.ToString().Substring(9))); //eg 105
            }
            return(0);                                              //couldn't find good extension
        }
Example #4
0
        ///<summary>Returns the number of partial batch insurance payments or if there are any claimprocs with status Received that have InsPayAmts but
        ///are not associated to a claim payment. Used to warn users that reports will be inaccurate until insurance payments are finalized.</summary>
        public static int GetPartialPaymentsCount()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            //Union together two queries that look for incomplete insurance payments.
            //The first query will look for any partial batch insurance payments.
            //The second query will look for any claim payments (InsPayAmt > 0) that do not have a claim payment (no check / not finalized).
            string command = @"
				SELECT COUNT(*) 
				FROM ((SELECT claimpayment.ClaimPaymentNum 
					FROM claimpayment 
					WHERE claimpayment.IsPartial = 1 
					AND claimpayment.CheckDate <= "                     + POut.Date(DateTime.Now) + @" 
					AND claimpayment.CheckDate >= "                     + POut.Date(DateTime.Now.AddMonths(-1)) + @")
						UNION ALL
					(SELECT claimproc.ClaimProcNum 
					FROM claimproc
					WHERE claimproc.ClaimPaymentNum = 0
					AND claimproc.InsPayAmt != 0 
					AND claimproc.Status IN("                     + POut.Int((int)ClaimProcStatus.Received) + "," + POut.Int((int)ClaimProcStatus.Supplemental) + ","
                             + POut.Int((int)ClaimProcStatus.CapClaim) + @") 
					AND claimproc.DateEntry <= "                     + POut.Date(DateTime.Now) + @" 
					AND claimproc.DateEntry >= "                     + POut.Date(DateTime.Now.AddMonths(-1)) + @")
				) partialpayments"                ;//claimproc.DateEntry is updated when payment is received.

            return(PIn.Int(Db.GetCount(command), false));
        }
Example #5
0
        ///<summary>Turns "pooling" off, then opens the current database connection, adds that connection to the dictionary of MySqlConnections, then returns the unique ServerThread.
        ///The returned ServerThread can then be used later in order to stop the query in the middle of executing.
        ///A non-pooled connection will NOT attempt to re-use connections to the DB that already exist but are idle,
        ///rather it will create a brand new connection that no other connection can use.
        ///This is so that user queries can be safely cancelled if needed.
        ///Required as a first step for user queries (and ONLY user queries).
        ///Not currently Oracle compatible.</summary>
        public static int GetServerThread(bool isReportServer)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), isReportServer));
            }
            MySqlConnection con = new MySqlConnection();

            if (isReportServer)
            {
                con = new MySqlConnection(DataConnection.GetReportConnectionString() + ";pooling=false");
            }
            else
            {
                //all connection details are the same, except pooling should be false.
                con = new MySqlConnection(DataConnection.GetCurrentConnectionString() + ";pooling=false");
            }
            con.Open();
            int serverThread = con.ServerThread;

            //If the dictionary already contains the ServerThread key, then something went wrong. Just stop and throw.
            if (_dictCons.ContainsKey(serverThread))
            {
                con.Close();
                throw new ApplicationException("Critical error in GetServerThread: A duplicate connection was found via the server thread ID.");
            }
            lock (_lockObj) {
                _dictCons[serverThread] = con;
            }
            return(serverThread);
        }
Example #6
0
 public static int GetInt(int intVal)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetInt(MethodBase.GetCurrentMethod(), intVal));
     }
     return(2);
 }
Example #7
0
        ///<summary>Counts the number of fees in the db for this fee sched, including all clinic and prov overrides.</summary>
        public static int GetCountByFeeSchedNum(long feeSchedNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), feeSchedNum));
            }
            string command = "SELECT COUNT(*) FROM fee WHERE FeeSched =" + POut.Long(feeSchedNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Example #8
0
        ///<summary>Returns 0 if the extension could not be found.</summary>
        public static int GetExtForComputer(string computerName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), computerName));
            }
            string command = "SELECT PhoneExt FROM phonecomp WHERE ComputerName='" + POut.String(computerName) + "'";

            return(Db.GetInt(command));
        }
Example #9
0
        public static int GetUserNameCount(string userName, UserWebFKeyType fkeyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), userName, fkeyType));
            }
            string command = "SELECT COUNT(*) FROM userweb WHERE UserName='******' AND FKeyType=" + POut.Int((int)fkeyType);

            return(PIn.Int(Db.GetCount(command)));
        }
Example #10
0
        ///<summary></summary>
        public static int GetCountBySubNum(long insSubNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), insSubNum));
            }
            string command = "SELECT COUNT(*) FROM patplan WHERE InsSubNum='" + POut.Long(insSubNum) + "'";

            return(PIn.Int(Db.GetCount(command)));
        }
Example #11
0
        public static int GetCountForPatient(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT COUNT(*) FROM medlab WHERE PatNum=" + POut.Long(patNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Example #12
0
        ///<summary>Returns the number of refattaches that this referral has.</summary>
        public static int CountReferralAttach(long referralNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), referralNum));
            }
            string command = "SELECT COUNT(*) FROM refattach "
                             + "WHERE ReferralNum=" + POut.Long(referralNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Example #13
0
        /// <summary>Gets the maximum Terminal Num for the selected patient.  Returns 0 if there's no sheets marked to show in terminal.</summary>
        public static int GetMaxTerminalNum(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT MAX(ShowInTerminal) FROM sheet WHERE PatNum=" + POut.Long(patNum)
                             + " AND IsDeleted=0";

            return(Db.GetInt(command));
        }
Example #14
0
        public static int GetRecallUndoCount(DateTime date)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), date));
            }
            string command = "SELECT COUNT(*) FROM commlog "
                             + "WHERE " + DbHelper.DateColumn("CommDateTime") + " = " + POut.Date(date) + " "
                             + "AND (SELECT ItemValue FROM definition WHERE definition.DefNum=commlog.CommType) ='" + CommItemTypeAuto.RECALL.ToString() + "'";

            return(PIn.Int(Db.GetScalar(command)));
        }
Example #15
0
        ///<summary>Sets the global MySQL variable max_allowed_packet to the passed in size (in bytes).
        ///Returns the results of GetMaxAllowedPacket() after running the SET GLOBAL command.</summary>
        public static int SetMaxAllowedPacket(int sizeBytes)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), sizeBytes));
            }
            //As of MySQL 5.0.84 the session level max_allowed_packet variable is read only so we only need to change the global.
            string command = "SET GLOBAL max_allowed_packet=" + POut.Int(sizeBytes);

            Db.NonQ(command);
            return(GetMaxAllowedPacket());
        }
Example #16
0
        ///<summary>Gets a list of all payplans for a given patient, whether they are the patient or the guarantor.  This is only used in one place, when deleting a patient to check dependencies.</summary>
        public static int GetDependencyCount(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT COUNT(*) FROM payplan"
                             + " WHERE PatNum = " + POut.Long(patNum)
                             + " OR Guarantor = " + POut.Long(patNum);

            return(PIn.Int(Db.GetScalar(command)));
        }
Example #17
0
        ///<summary>Returns a count of the number of C, EC, and EO procedures attached to a group note.  Takes the ProcNum of a group note.
        ///Used when deleting group notes to determine which permission to check.</summary>
        public static int GetCountCompletedProcsForGroup(long groupNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), groupNum));
            }
            string command = "SELECT COUNT(*) FROM procgroupitem "
                             + "INNER JOIN procedurelog ON procedurelog.ProcNum=procgroupitem.ProcNum "
                             + "AND procedurelog.ProcStatus IN (" + POut.Int((int)ProcStat.C) + ", " + POut.Int((int)ProcStat.EO) + ", " + POut.Int((int)ProcStat.EC) + ") "
                             + "WHERE GroupNum = " + POut.Long(groupNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Example #18
0
        ///<summary>Gets the version that is considered 'stable' to the manual publisher. This will always be in the form '183', '184', '191' as far as I can tell.</summary>
        public static int GetStableManualVersion()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            string command = "SELECT VersionOd FROM version WHERE IsMainNoNumber=1";
            int    retval  = 0;

            DataAction.RunManualPublisherHQ(() => {
                retval = PIn.Int(Db.GetScalar(command));
            });
            return(retval);
        }
Example #19
0
        ///<summary>Gets all payments that have a ProcessStatus of OnlinePending for the clinic. Pass in a clinicNum of 0 to see all payments.</summary>
        public static int CountNeedingProcessed(long clinicNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), clinicNum));
            }
            string command = "SELECT COUNT(*) FROM payment WHERE ProcessStatus=" + POut.Int((int)ProcessStat.OnlinePending) + " ";

            if (clinicNum != 0)
            {
                command += "AND payment.ClinicNum=" + POut.Long(clinicNum);
            }
            return(PIn.Int(Db.GetCount(command)));
        }
Example #20
0
        ///<summary>Returns an empty list if planNum is 0.</summary>
        public static int GetPatCountForPlan(long planNum)
        {
            if (planNum == 0)
            {
                return(0);
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), planNum));
            }
            string command = "SELECT COUNT(PatNum) FROM patient WHERE DiscountPlanNum=" + POut.Long(planNum) + " " +
                             "AND PatStatus NOT IN(" + POut.Int((int)PatientStatus.Deleted) + "," + POut.Int((int)PatientStatus.Deceased) + ") ";

            return(PIn.Int(Db.GetCount(command)));
        }
Example #21
0
        ///<summary>Increments the PreviousFileNumber program property to the next available int and returns that new file number.</summary>
        public static int GetUniqueFileNum()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            long progNum = Programs.GetProgramNum(ProgramName.TrojanExpressCollect);
            int  fileNum = PIn.Int(ProgramProperties.GetValFromDb(progNum, "PreviousFileNumber"), false) + 1;

            while (ProgramProperties.SetProperty(progNum, "PreviousFileNumber", fileNum.ToString()) < 1)
            {
                fileNum++;
            }
            return(fileNum);
        }
Example #22
0
        ///<summary>Gets the extension for the employee.  Returns 0 if employee cannot be found.</summary>
        public static int GetExtensionForEmp(long employeeNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), employeeNum));
            }
            string    command = "SELECT Extension FROM phone WHERE EmployeeNum=" + POut.Long(employeeNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                return(PIn.Int(table.Rows[0]["Extension"].ToString()));
            }
            return(0);
        }
Example #23
0
        public static int GetServer_id()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            if (DataConnection.DBtype != DatabaseType.MySql)
            {
                return(0);
            }
            string    command = "SHOW VARIABLES LIKE 'server_id'";
            DataTable table   = Db.GetTable(command);

            return(PIn.Int(table.Rows[0][1].ToString()));
        }
Example #24
0
        ///<Summary>Gets from the database the next available itemOrder for the specified category.  Returns 0 if no items found in category.</Summary>
        public static int GetNextItemOrder(long catNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), catNum));
            }
            string command = "SELECT MAX(ItemOrder+1) FROM supply WHERE Category=" + POut.Long(catNum);

            try {
                return(PIn.Int(Db.GetScalar(command)));
            }
            catch (Exception ex) {
                return(0);
            }
        }
Example #25
0
        ///<summary>Sets the ordinal of the specified patPlan.  Rearranges the other patplans for the patient to keep the ordinal sequence contiguous.  Estimates must be recomputed after this.  FormInsPlan currently updates estimates every time it closes.  Only used in one place.  Returns the new ordinal.</summary>
        public static int SetOrdinal(long patPlanNum, int newOrdinal)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), patPlanNum, newOrdinal));
            }
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.Long(patPlanNum);
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(1);
            }
            long           patNum   = PIn.Long(table.Rows[0][0].ToString());
            List <PatPlan> patPlans = Refresh(patNum);

            //int oldOrdinal=GetFromList(patPlans,patPlanNum).Ordinal;
            if (newOrdinal > patPlans.Count)
            {
                newOrdinal = patPlans.Count;
            }
            if (newOrdinal < 1)
            {
                newOrdinal = 1;
            }
            int curOrdinal = 1;

            for (int i = 0; i < patPlans.Count; i++)      //Loop through each patPlan.
            {
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    continue;                    //the one we are setting will be handled later
                }
                if (curOrdinal == newOrdinal)
                {
                    curOrdinal++;                    //skip the newOrdinal when setting the sequence for the others.
                }
                command = "UPDATE patplan SET Ordinal=" + POut.Long(curOrdinal)
                          + " WHERE PatPlanNum=" + POut.Long(patPlans[i].PatPlanNum);
                Db.NonQ(command);
                curOrdinal++;
            }
            command = "UPDATE patplan SET Ordinal=" + POut.Long(newOrdinal)
                      + " WHERE PatPlanNum=" + POut.Long(patPlanNum);
            Db.NonQ(command);
//Cameron_ Possibly create outbound ADT message to update insurance info
            return(newOrdinal);
        }
Example #26
0
        ///<summary>Reprocess the original HL7 msgs for any MedLabs with PatNum 0, creates the embedded PDF files from the base64 text in the ZEF segments
        ///<para>The old method used when parsing MedLab HL7 msgs was to wait to extract these files until the msg was manually associated with a patient.
        ///Associating the MedLabs to a patient and reprocessing the HL7 messages using middle tier was very slow.</para>
        ///<para>The new method is to create the PDF files and save them in the image folder in a subdirectory called "MedLabEmbeddedFiles" if a patient
        ///isn't located from the details in the PID segment of the message.  Associating the MedLabs to a pat is now just a matter of moving the files to
        ///the pat's image folder and updating the PatNum columns.  All files are now extracted and stored, either in a pat's folder or in the
        ///"MedLabEmbeddedFiles" folder, by the HL7 service.</para>
        ///<para>This will reprocess all HL7 messages for MedLabs with PatNum=0 and replace the MedLab, MedLabResult, MedLabSpecimen, and MedLabFacAttach
        ///rows as well as create any embedded files and insert document table rows.  The document table rows will have PatNum=0, just like the MedLabs,
        ///if a pat is still not located with the details in the PID segment.  Once the user manually attaches the MedLab to a patient, all rows will be
        ///updated with the correct PatNum and the embedded PDFs will be moved to the pat's image folder.  The document.FileName column will contain the
        ///name of the file, regardless of where it is located.  The file name will be updated to a relevant name for the folder in which it is located.
        ///i.e. in the MedLabEmbeddedFiles directory it may be named 3YG8Z420150909100527.pdf, but once moved to a pat's folder it will be renamed to
        ///something like PatientAustin375.pdf and the document.FileName column will be the current name.</para>
        ///<para>If storing images in the db, the document table rows will contain the base64 text version of the PDFs with PatNum=0 and will be updated
        ///with the correct PatNum once associated.  The FileName will be just the extension ".pdf" until it is associated with a patient at which time it
        ///will be updated to something like PatientAustin375.pdf.</para></summary>
        public static int Reconcile()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            string        command     = "SELECT * FROM medlab WHERE PatNum=0";
            List <MedLab> listMedLabs = Crud.MedLabCrud.SelectMany(command);

            if (listMedLabs.Count < 1)
            {
                return(0);
            }
            List <long> listMedLabNumsNew = new List <long>();        //used to delete old MedLab objects after creating these new ones from the HL7 message text
            int         failedCount       = 0;

            foreach (string relativePath in listMedLabs.Select(x => x.FileName).Distinct().ToList())
            {
                string fileTextCur = "";
                try {
                    if (PrefC.AtoZfolderUsed != DataStorageType.InDatabase)
                    {
                        fileTextCur = FileAtoZ.ReadAllText(FileAtoZ.CombinePaths(ImageStore.GetPreferredAtoZpath(), relativePath));
                    }
                }
                catch (Exception ex) {
                    ex.DoNothing();                    //To avoid a warning message.  The ex is needed to ensure all exceptions are caught.
                    failedCount++;
                    continue;
                }
                MessageHL7  msg = new MessageHL7(fileTextCur);
                List <long> listMedLabNumsCur = MessageParserMedLab.Process(msg, relativePath, false);           //re-creates the documents from the ZEF segments
                if (listMedLabNumsCur == null || listMedLabNumsCur.Count < 1)
                {
                    failedCount++;
                    continue;                    //not sure what to do, just move on?
                }
                listMedLabNumsNew.AddRange(listMedLabNumsCur);
                MedLabs.UpdateFileNames(listMedLabNumsCur, relativePath);
            }
            //Delete all MedLabs, MedLabResults, MedLabSpecimens, and MedLabFacAttaches except the ones just created
            //Don't delete until we successfully process the messages and have valid new MedLab objects
            foreach (MedLab medLab in listMedLabs)
            {
                failedCount += DeleteLabsAndResults(medLab, listMedLabNumsNew);
            }
            return(failedCount);
        }
Example #27
0
        ///<summary>Gets the last ItemOrder for a category.  -1 if none in that category yet.</summary>
        public static int GetLastItemOrder(long category)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), category));
            }
            string command = "SELECT MAX(ItemOrder) FROM supply "
                             + "WHERE Category=" + POut.Long(category);
            string result = Db.GetScalar(command);

            if (result == "")
            {
                return(-1);
            }
            return(PIn.Int(result));
        }
Example #28
0
        ///<summary>Used when adding a provider to get the next available itemOrder.</summary>
        public static int GetNextItemOrder()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            //Is this valid in Oracle??
            string    command = "SELECT MAX(ItemOrder) FROM provider";
            DataTable table   = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(0);
            }
            return(PIn.Int(table.Rows[0][0].ToString()) + 1);
        }
Example #29
0
        ///<Summary>Gets from the database the last itemOrder for the specified category.  Used to send un unhidden supply to the end of the list.</Summary>
        public static int GetLastItemOrder(long supplierNum, long catNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), supplierNum, catNum));
            }
            string command = "SELECT MAX(ItemOrder) FROM supply WHERE SupplierNum=" + POut.Long(supplierNum)
                             + " AND Category=" + POut.Long(catNum) + " AND IsHidden=0";
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(-1);
            }
            return(PIn.Int(table.Rows[0][0].ToString()));
        }
Example #30
0
        ///<summary>Only used once.  Gets a count of subscribers from the database that have the specified plan. Used to display in the insplan window.  The returned count never includes the inssub that we're viewing.</summary>
        public static int GetSubscriberCountForPlan(long planNum, bool excludeSub)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), planNum, excludeSub));
            }
            string command = "SELECT COUNT(inssub.InsSubNum) "
                             + "FROM inssub "
                             + "WHERE inssub.PlanNum=" + POut.Long(planNum) + " ";
            int retVal = PIn.Int(Db.GetCount(command));

            if (excludeSub)
            {
                retVal = Math.Max(retVal - 1, 0);
            }
            return(retVal);
        }