Esempio n. 1
0
        ///<summary>Surround with try/catch.  Deletes all existing practice, provider, and employee schedules for a day and then saves the provided list.</summary>
        public static void SetForDay(List <Schedule> SchedList, DateTime schedDate)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), SchedList, schedDate);
                return;
            }
            for (int i = 0; i < SchedList.Count; i++)
            {
                if (SchedList[i].StartTime > SchedList[i].StopTime)
                {
                    throw new Exception(Lans.g("Schedule", "Stop time must be later than start time."));
                }
            }
            //make deleted entries for synch purposes:
            string command = "SELECT ScheduleNum FROM schedule WHERE SchedDate= " + POut.Date(schedDate) + " "
                             + "AND SchedType=" + POut.Long((int)ScheduleType.Provider);
            DataTable table = Db.GetTable(command);

            for (int i = 0; i < table.Rows.Count; i++)
            {
                DeletedObjects.SetDeleted(DeletedObjectType.ScheduleProv, PIn.Long(table.Rows[i][0].ToString()));
            }
            //Then, bulk delete.
            command = "DELETE FROM schedule WHERE SchedDate= " + POut.Date(schedDate) + " "
                      + "AND (SchedType=0 OR SchedType=1 OR SchedType=3)";
            Db.NonQ(command);
            for (int i = 0; i < SchedList.Count; i++)
            {
                Insert(SchedList[i], false);
            }
        }
Esempio n. 2
0
        ///<summary>Surround with try/catch, because it will throw an exception if any patient is using this def.</summary>
        public static void Delete(DiseaseDef def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
                return;
            }
            string command = "SELECT LName,FName,patient.PatNum FROM patient,disease WHERE "
                             + "patient.PatNum=disease.PatNum "
                             + "AND disease.DiseaseDefNum='" + POut.Long(def.DiseaseDefNum) + "' "
                             + "GROUP BY patient.PatNum";
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                string s = Lans.g("DiseaseDef", "Not allowed to delete. Already in use by ") + table.Rows.Count.ToString()
                           + " " + Lans.g("DiseaseDef", "patients, including") + " \r\n";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 5)
                    {
                        break;
                    }
                    s += table.Rows[i][0].ToString() + ", " + table.Rows[i][1].ToString() + "\r\n";
                }
                throw new ApplicationException(s);
            }
            command = "DELETE FROM diseasedef WHERE DiseaseDefNum =" + POut.Long(def.DiseaseDefNum);
            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.DiseaseDef, def.DiseaseDefNum);
        }
Esempio n. 3
0
 ///<summary></summary>
 public static void DeleteObject(long pharmacyNum)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), pharmacyNum);
         return;
     }
     Crud.PharmacyCrud.Delete(pharmacyNum);
     DeletedObjects.SetDeleted(DeletedObjectType.Pharmacy, pharmacyNum);
 }
Esempio n. 4
0
 public static void DeleteObject(long statementNum)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), statementNum);
         return;
     }
     Crud.StatementCrud.Delete(statementNum);
     DeletedObjects.SetDeleted(DeletedObjectType.Statement, statementNum);
 }
Esempio n. 5
0
        ///<summary>Surround with try-catch</summary>
        public static void Delete(long employeeNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), employeeNum);
                return;
            }
            //appointment.Assistant will not block deletion
            //schedule.EmployeeNum will not block deletion
            string command = "SELECT COUNT(*) FROM clockevent WHERE EmployeeNum=" + POut.Long(employeeNum);

            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached clock events."));
            }
            command = "SELECT COUNT(*) FROM timeadjust WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached time adjustments."));
            }
            command = "SELECT COUNT(*) FROM userod WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached user."));
            }
            command = "UPDATE appointment SET Assistant=0 WHERE Assistant=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "SELECT ScheduleNum FROM schedule WHERE EmployeeNum=" + POut.Long(employeeNum);
            DataTable     table            = Db.GetTable(command);
            List <string> listScheduleNums = new List <string>();        //Used for deleting scheduleops below

            for (int i = 0; i < table.Rows.Count; i++)
            {
                //Add entry to deletedobjects table if it is a provider schedule type
                DeletedObjects.SetDeleted(DeletedObjectType.ScheduleProv, PIn.Long(table.Rows[i]["ScheduleNum"].ToString()));
                listScheduleNums.Add(table.Rows[i]["ScheduleNum"].ToString());
            }
            if (listScheduleNums.Count > 0)
            {
                command = "DELETE FROM scheduleop WHERE ScheduleNum IN(" + POut.String(String.Join(",", listScheduleNums)) + ")";
                Db.NonQ(command);
            }
            //command="DELETE FROM scheduleop WHERE ScheduleNum IN(SELECT ScheduleNum FROM schedule WHERE EmployeeNum="+POut.Long(employeeNum)+")";
            //Db.NonQ(command);
            command = "DELETE FROM schedule WHERE EmployeeNum=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM employee WHERE EmployeeNum =" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM timecardrule WHERE EmployeeNum=" + POut.Long(employeeNum);
            Db.NonQ(command);
        }
Esempio n. 6
0
 ///<summary></summary>
 public static void DeleteObject(Statement statement)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), statement);
         return;
     }
     //validate that not already in use.
     Crud.StatementCrud.Delete(statement.StatementNum);
     DeletedObjects.SetDeleted(DeletedObjectType.Statement, statement.StatementNum);
 }
Esempio n. 7
0
        ///<summary></summary>
        public static void Delete(long allergyNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), allergyNum);
                return;
            }
            string command = "DELETE FROM allergy WHERE AllergyNum = " + POut.Long(allergyNum);

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.Allergy, allergyNum);
        }
Esempio n. 8
0
        ///<summary></summary>
        public static void Delete(Document doc)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), doc);
                return;
            }
            string command = "DELETE from document WHERE DocNum = '" + doc.DocNum.ToString() + "'";

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.Document, doc.DocNum);
        }
Esempio n. 9
0
        ///<summary></summary>
        public static void Delete(long labPanelNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), labPanelNum);
                return;
            }
            string command = "DELETE FROM labpanel WHERE LabPanelNum = " + POut.Long(labPanelNum);

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.LabPanel, labPanelNum);
        }
Esempio n. 10
0
        ///<summary></summary>
        public static void Delete(Disease disease)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), disease);
                return;
            }
            string command = "DELETE FROM disease WHERE DiseaseNum =" + POut.Long(disease.DiseaseNum);

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.Disease, disease.DiseaseNum);
        }
Esempio n. 11
0
        ///<summary></summary>
        public static void Delete(long rxNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), rxNum);
                return;
            }
            string command = "DELETE FROM rxpat WHERE RxNum = '" + POut.Long(rxNum) + "'";

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.RxPat, rxNum);
        }
Esempio n. 12
0
        ///<summary>Only used from FormProvEdit if user clicks cancel before finishing entering a new provider.</summary>
        public static void Delete(Provider prov)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), prov);
                return;
            }
            string command = "DELETE from provider WHERE provnum = '" + prov.ProvNum.ToString() + "'";

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.Provider, prov.ProvNum);
        }
Esempio n. 13
0
        ///<summary>Dependent brands and patients will already be checked.</summary>
        public static void Delete(Medication Cur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), Cur);
                return;
            }
            string command = "DELETE from medication WHERE medicationNum = '" + Cur.MedicationNum.ToString() + "'";

            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.Medication, Cur.MedicationNum);
        }
Esempio n. 14
0
        ///<summary></summary>
        public static void Delete(Schedule sched)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), sched);
                return;
            }
            string command = "DELETE from schedule WHERE schedulenum = '" + POut.Long(sched.ScheduleNum) + "'";

            Db.NonQ(command);
            if (sched.SchedType == ScheduleType.Provider)
            {
                DeletedObjects.SetDeleted(DeletedObjectType.ScheduleProv, sched.ScheduleNum);
            }
        }
Esempio n. 15
0
        ///<summary>Surround with a try/catch.  Will fail if drug unit is in use.</summary>
        public static void Delete(long drugUnitNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), drugUnitNum);
                return;
            }
            //validation
            string command;

            //no longer used in labresult
            //command="SELECT COUNT(*) FROM labresult WHERE DrugUnitNum="+POut.Long(drugUnitNum);
            //if(Db.GetCount(command)!="0") {
            //	throw new ApplicationException(Lans.g("FormDrugUnitEdit","Cannot delete: DrugUnit is in use by LabResult."));
            //}
            command = "SELECT COUNT(*) FROM vaccinepat WHERE DrugUnitNum=" + POut.Long(drugUnitNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormDrugUnitEdit", "Cannot delete: DrugUnit is in use by VaccinePat."));
            }
            command = "DELETE FROM drugunit WHERE DrugUnitNum = " + POut.Long(drugUnitNum);
            Db.NonQ(command);
            DeletedObjects.SetDeleted(DeletedObjectType.DrugUnit, drugUnitNum);
        }
Esempio n. 16
0
        ///<summary>Clears all schedule entries for the given date range and the given providers, employees, and practice.</summary>
        public static void Clear(DateTime dateStart, DateTime dateEnd, List <long> provNums, List <long> empNums, bool includePractice)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), dateStart, dateEnd, provNums, empNums, includePractice);
                return;
            }
            if (provNums.Count == 0 && empNums.Count == 0 && !includePractice)
            {
                return;
            }
            string command;
            string orClause = "";

            //make deleted entries for synch purposes:
            if (provNums.Count > 0)
            {
                for (int i = 0; i < provNums.Count; i++)
                {
                    if (orClause != "")
                    {
                        orClause += "OR ";
                    }
                    orClause += "schedule.ProvNum=" + POut.Long(provNums[i]) + " ";
                }
                command = "SELECT ScheduleNum FROM schedule "
                          + "WHERE SchedDate >= " + POut.Date(dateStart) + " "
                          + "AND SchedDate <= " + POut.Date(dateEnd) + " "
                          + "AND SchedType=" + POut.Long((int)ScheduleType.Provider)
                          + " AND (" + orClause + ")";
                DataTable table = Db.GetTable(command);
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    DeletedObjects.SetDeleted(DeletedObjectType.ScheduleProv, PIn.Long(table.Rows[i][0].ToString()));
                }
            }
            //Then, the usual deletion for everything
            command = "DELETE FROM schedule "
                      + "WHERE SchedDate >= " + POut.Date(dateStart) + " "
                      + "AND SchedDate <= " + POut.Date(dateEnd) + " "
                      + "AND (";
            orClause = "";          //this is guaranteed to be non empty by the time the command is assembled.
            if (includePractice)
            {
                orClause = "SchedType=0 ";
            }
            for (int i = 0; i < provNums.Count; i++)
            {
                if (orClause != "")
                {
                    orClause += "OR ";
                }
                orClause += "schedule.ProvNum=" + POut.Long(provNums[i]) + " ";
            }
            for (int i = 0; i < empNums.Count; i++)
            {
                if (orClause != "")
                {
                    orClause += "OR ";
                }
                orClause += "schedule.EmployeeNum=" + POut.Long(empNums[i]) + " ";
            }
            command += orClause + ")";
            Db.NonQ(command);
        }