Example #1
0
        ///<summary>Inserts one Reconcile into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(Reconcile reconcile, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO reconcile (";

            if (!useExistingPK && isRandomKeys)
            {
                reconcile.ReconcileNum = ReplicationServers.GetKeyNoCache("reconcile", "ReconcileNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ReconcileNum,";
            }
            command += "AccountNum,StartingBal,EndingBal,DateReconcile,IsLocked) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(reconcile.ReconcileNum) + ",";
            }
            command +=
                POut.Long(reconcile.AccountNum) + ","
                + "'" + POut.Double(reconcile.StartingBal) + "',"
                + "'" + POut.Double(reconcile.EndingBal) + "',"
                + POut.Date(reconcile.DateReconcile) + ","
                + POut.Bool(reconcile.IsLocked) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                reconcile.ReconcileNum = Db.NonQ(command, true, "ReconcileNum", "reconcile");
            }
            return(reconcile.ReconcileNum);
        }
Example #2
0
        ///<summary>Inserts one Reconcile into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(Reconcile reconcile, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                reconcile.ReconcileNum = ReplicationServers.GetKey("reconcile", "ReconcileNum");
            }
            string command = "INSERT INTO reconcile (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ReconcileNum,";
            }
            command += "AccountNum,StartingBal,EndingBal,DateReconcile,IsLocked) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(reconcile.ReconcileNum) + ",";
            }
            command +=
                POut.Long(reconcile.AccountNum) + ","
                + "'" + POut.Double(reconcile.StartingBal) + "',"
                + "'" + POut.Double(reconcile.EndingBal) + "',"
                + POut.Date(reconcile.DateReconcile) + ","
                + POut.Bool(reconcile.IsLocked) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                reconcile.ReconcileNum = Db.NonQ(command, true);
            }
            return(reconcile.ReconcileNum);
        }
Example #3
0
 ///<summary>Inserts one Reconcile into the database.  Returns the new priKey.</summary>
 public static long Insert(Reconcile reconcile)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         reconcile.ReconcileNum = DbHelper.GetNextOracleKey("reconcile", "ReconcileNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(reconcile, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     reconcile.ReconcileNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(reconcile, false));
     }
 }
Example #4
0
 ///<summary>Inserts one Reconcile into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Reconcile reconcile,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         reconcile.ReconcileNum=ReplicationServers.GetKey("reconcile","ReconcileNum");
     }
     string command="INSERT INTO reconcile (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ReconcileNum,";
     }
     command+="AccountNum,StartingBal,EndingBal,DateReconcile,IsLocked) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(reconcile.ReconcileNum)+",";
     }
     command+=
              POut.Long  (reconcile.AccountNum)+","
         +"'"+POut.Double(reconcile.StartingBal)+"',"
         +"'"+POut.Double(reconcile.EndingBal)+"',"
         +    POut.Date  (reconcile.DateReconcile)+","
         +    POut.Bool  (reconcile.IsLocked)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         reconcile.ReconcileNum=Db.NonQ(command,true);
     }
     return reconcile.ReconcileNum;
 }
Example #5
0
 ///<summary>Inserts one Reconcile into the database.  Returns the new priKey.</summary>
 internal static long Insert(Reconcile reconcile)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         reconcile.ReconcileNum=DbHelper.GetNextOracleKey("reconcile","ReconcileNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(reconcile,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     reconcile.ReconcileNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(reconcile,false);
     }
 }
Example #6
0
        ///<summary></summary>
        public static void Insert(Reconcile reconcile)
        {
            if (PrefB.RandomKeys)
            {
                reconcile.ReconcileNum = MiscData.GetKey("reconcile", "ReconcileNum");
            }
            string command = "INSERT INTO reconcile (";

            if (PrefB.RandomKeys)
            {
                command += "ReconcileNum,";
            }
            command += "AccountNum,StartingBal,EndingBal,DateReconcile,IsLocked) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(reconcile.ReconcileNum) + "', ";
            }
            command +=
                "'" + POut.PInt(reconcile.AccountNum) + "', "
                + "'" + POut.PDouble(reconcile.StartingBal) + "', "
                + "'" + POut.PDouble(reconcile.EndingBal) + "', "
                + POut.PDate(reconcile.DateReconcile) + ", "
                + "'" + POut.PBool(reconcile.IsLocked) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                reconcile.ReconcileNum = General.NonQ(command, true);
            }
        }
 /// <summary/>
 public ForcedAcknowledgementRequest CreateForcedAcknowledgementRequest(Reconcile reconcile)
 {
     return(new ForcedAcknowledgementRequest(
                config: RequestConfig,
                originatorId: OriginatorId,
                reconcile: reconcile
                ));
 }
Example #8
0
        ///<summary></summary>
        public static void Update(Reconcile reconcile)
        {
            string command = "UPDATE reconcile SET "
                             + "AccountNum = '" + POut.PInt(reconcile.AccountNum) + "' "
                             + ",StartingBal= '" + POut.PDouble(reconcile.StartingBal) + "' "
                             + ",EndingBal = '" + POut.PDouble(reconcile.EndingBal) + "' "
                             + ",DateReconcile = " + POut.PDate(reconcile.DateReconcile) + " "
                             + ",IsLocked = '" + POut.PBool(reconcile.IsLocked) + "' "
                             + "WHERE ReconcileNum = '" + POut.PInt(reconcile.ReconcileNum) + "'";

            General.NonQ(command);
        }
Example #9
0
        ///<summary>Throws exception if Reconcile is in use.</summary>
        public static void Delete(Reconcile reconcile)
        {
            //check to see if any journal entries are attached to this Reconcile
            string command = "SELECT COUNT(*) FROM journalentry WHERE ReconcileNum=" + POut.PInt(reconcile.ReconcileNum);

            if (General.GetCount(command) != "0")
            {
                throw new ApplicationException(Lan.g("FormReconcileEdit",
                                                     "Not allowed to delete a Reconcile with existing journal entries."));
            }
            command = "DELETE FROM reconcile WHERE ReconcileNum = " + POut.PInt(reconcile.ReconcileNum);
            General.NonQ(command);
        }
Example #10
0
 ///<summary>Inserts one Reconcile into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Reconcile reconcile)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(reconcile, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             reconcile.ReconcileNum = DbHelper.GetNextOracleKey("reconcile", "ReconcileNum");                  //Cacheless method
         }
         return(InsertNoCache(reconcile, true));
     }
 }
Example #11
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Reconcile> TableToList(DataTable table){
			List<Reconcile> retVal=new List<Reconcile>();
			Reconcile reconcile;
			for(int i=0;i<table.Rows.Count;i++) {
				reconcile=new Reconcile();
				reconcile.ReconcileNum = PIn.Long  (table.Rows[i]["ReconcileNum"].ToString());
				reconcile.AccountNum   = PIn.Long  (table.Rows[i]["AccountNum"].ToString());
				reconcile.StartingBal  = PIn.Double(table.Rows[i]["StartingBal"].ToString());
				reconcile.EndingBal    = PIn.Double(table.Rows[i]["EndingBal"].ToString());
				reconcile.DateReconcile= PIn.Date  (table.Rows[i]["DateReconcile"].ToString());
				reconcile.IsLocked     = PIn.Bool  (table.Rows[i]["IsLocked"].ToString());
				retVal.Add(reconcile);
			}
			return retVal;
		}
Example #12
0
        private static Reconcile[] RefreshAndFill(string command)
        {
            DataTable table = General.GetTable(command);

            Reconcile[] List = new Reconcile[table.Rows.Count];
            for (int i = 0; i < List.Length; i++)
            {
                List[i] = new Reconcile();
                List[i].ReconcileNum  = PIn.PInt(table.Rows[i][0].ToString());
                List[i].AccountNum    = PIn.PInt(table.Rows[i][1].ToString());
                List[i].StartingBal   = PIn.PDouble(table.Rows[i][2].ToString());
                List[i].EndingBal     = PIn.PDouble(table.Rows[i][3].ToString());
                List[i].DateReconcile = PIn.PDate(table.Rows[i][4].ToString());
                List[i].IsLocked      = PIn.PBool(table.Rows[i][5].ToString());
            }
            return(List);
        }
Example #13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <Reconcile> TableToList(DataTable table)
        {
            List <Reconcile> retVal = new List <Reconcile>();
            Reconcile        reconcile;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                reconcile = new Reconcile();
                reconcile.ReconcileNum  = PIn.Long(table.Rows[i]["ReconcileNum"].ToString());
                reconcile.AccountNum    = PIn.Long(table.Rows[i]["AccountNum"].ToString());
                reconcile.StartingBal   = PIn.Double(table.Rows[i]["StartingBal"].ToString());
                reconcile.EndingBal     = PIn.Double(table.Rows[i]["EndingBal"].ToString());
                reconcile.DateReconcile = PIn.Date(table.Rows[i]["DateReconcile"].ToString());
                reconcile.IsLocked      = PIn.Bool(table.Rows[i]["IsLocked"].ToString());
                retVal.Add(reconcile);
            }
            return(retVal);
        }
Example #14
0
		///<summary>Updates one Reconcile in the database.</summary>
		public static void Update(Reconcile reconcile){
			string command="UPDATE reconcile SET "
				+"AccountNum   =  "+POut.Long  (reconcile.AccountNum)+", "
				+"StartingBal  = '"+POut.Double(reconcile.StartingBal)+"', "
				+"EndingBal    = '"+POut.Double(reconcile.EndingBal)+"', "
				+"DateReconcile=  "+POut.Date  (reconcile.DateReconcile)+", "
				+"IsLocked     =  "+POut.Bool  (reconcile.IsLocked)+" "
				+"WHERE ReconcileNum = "+POut.Long(reconcile.ReconcileNum);
			Db.NonQ(command);
		}
Example #15
0
 ///<summary>Inserts one Reconcile into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Reconcile reconcile)
 {
     return(InsertNoCache(reconcile, false));
 }
 /// <summary/>
 public string ForcedAcknowledgement(Reconcile reconcile)
 => ReadyRequest(CreateForcedAcknowledgementRequest(reconcile));
Example #17
0
		///<summary>Updates one Reconcile in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Reconcile reconcile,Reconcile oldReconcile){
			string command="";
			if(reconcile.AccountNum != oldReconcile.AccountNum) {
				if(command!=""){ command+=",";}
				command+="AccountNum = "+POut.Long(reconcile.AccountNum)+"";
			}
			if(reconcile.StartingBal != oldReconcile.StartingBal) {
				if(command!=""){ command+=",";}
				command+="StartingBal = '"+POut.Double(reconcile.StartingBal)+"'";
			}
			if(reconcile.EndingBal != oldReconcile.EndingBal) {
				if(command!=""){ command+=",";}
				command+="EndingBal = '"+POut.Double(reconcile.EndingBal)+"'";
			}
			if(reconcile.DateReconcile != oldReconcile.DateReconcile) {
				if(command!=""){ command+=",";}
				command+="DateReconcile = "+POut.Date(reconcile.DateReconcile)+"";
			}
			if(reconcile.IsLocked != oldReconcile.IsLocked) {
				if(command!=""){ command+=",";}
				command+="IsLocked = "+POut.Bool(reconcile.IsLocked)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE reconcile SET "+command
				+" WHERE ReconcileNum = "+POut.Long(reconcile.ReconcileNum);
			Db.NonQ(command);
			return true;
		}