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

            if (!useExistingPK && isRandomKeys)
            {
                accountingAutoPay.AccountingAutoPayNum = ReplicationServers.GetKeyNoCache("accountingautopay", "AccountingAutoPayNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "AccountingAutoPayNum,";
            }
            command += "PayType,PickList) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(accountingAutoPay.AccountingAutoPayNum) + ",";
            }
            command +=
                POut.Long(accountingAutoPay.PayType) + ","
                + "'" + POut.String(accountingAutoPay.PickList) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                accountingAutoPay.AccountingAutoPayNum = Db.NonQ(command, true, "AccountingAutoPayNum", "accountingAutoPay");
            }
            return(accountingAutoPay.AccountingAutoPayNum);
        }
Exemplo n.º 2
0
 ///<summary>Inserts one AccountingAutoPay into the database.  Returns the new priKey.</summary>
 public static long Insert(AccountingAutoPay accountingAutoPay)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         accountingAutoPay.AccountingAutoPayNum = DbHelper.GetNextOracleKey("accountingautopay", "AccountingAutoPayNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(accountingAutoPay, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     accountingAutoPay.AccountingAutoPayNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(accountingAutoPay, false));
     }
 }
        ///<summary>Updates one AccountingAutoPay 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(AccountingAutoPay accountingAutoPay, AccountingAutoPay oldAccountingAutoPay)
        {
            string command = "";

            if (accountingAutoPay.PayType != oldAccountingAutoPay.PayType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayType = " + POut.Long(accountingAutoPay.PayType) + "";
            }
            if (accountingAutoPay.PickList != oldAccountingAutoPay.PickList)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PickList = '" + POut.String(accountingAutoPay.PickList) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE accountingautopay SET " + command
                      + " WHERE AccountingAutoPayNum = " + POut.Long(accountingAutoPay.AccountingAutoPayNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 4
0
 ///<summary>Inserts one AccountingAutoPay into the database.  Returns the new priKey.</summary>
 internal static long Insert(AccountingAutoPay accountingAutoPay)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         accountingAutoPay.AccountingAutoPayNum=DbHelper.GetNextOracleKey("accountingautopay","AccountingAutoPayNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(accountingAutoPay,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     accountingAutoPay.AccountingAutoPayNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(accountingAutoPay,false);
     }
 }
        ///<summary>Inserts one AccountingAutoPay into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(AccountingAutoPay accountingAutoPay, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                accountingAutoPay.AccountingAutoPayNum = ReplicationServers.GetKey("accountingautopay", "AccountingAutoPayNum");
            }
            string command = "INSERT INTO accountingautopay (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "AccountingAutoPayNum,";
            }
            command += "PayType,PickList) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(accountingAutoPay.AccountingAutoPayNum) + ",";
            }
            command +=
                POut.Long(accountingAutoPay.PayType) + ","
                + "'" + POut.String(accountingAutoPay.PickList) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                accountingAutoPay.AccountingAutoPayNum = Db.NonQ(command, true, "AccountingAutoPayNum", "accountingAutoPay");
            }
            return(accountingAutoPay.AccountingAutoPayNum);
        }
Exemplo n.º 6
0
 private void butCancel_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         AutoPayCur = null;
     }
     DialogResult = DialogResult.Cancel;
 }
        ///<summary></summary>
        public static void Insert(AccountingAutoPay pay)
        {
            string command = "INSERT INTO accountingautopay (PayType,PickList) VALUES("
                             + "'" + POut.PInt(pay.PayType) + "', "
                             + "'" + POut.PString(pay.PickList) + "')";

            pay.AccountingAutoPayNum = General.NonQ(command, true);
        }
        ///<summary>Updates one AccountingAutoPay in the database.</summary>
        public static void Update(AccountingAutoPay accountingAutoPay)
        {
            string command = "UPDATE accountingautopay SET "
                             + "PayType             =  " + POut.Long(accountingAutoPay.PayType) + ", "
                             + "PickList            = '" + POut.String(accountingAutoPay.PickList) + "' "
                             + "WHERE AccountingAutoPayNum = " + POut.Long(accountingAutoPay.AccountingAutoPayNum);

            Db.NonQ(command);
        }
Exemplo n.º 9
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     AutoPayCur = null;
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     DialogResult = DialogResult.OK;
 }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<AccountingAutoPay> TableToList(DataTable table){
			List<AccountingAutoPay> retVal=new List<AccountingAutoPay>();
			AccountingAutoPay accountingAutoPay;
			for(int i=0;i<table.Rows.Count;i++) {
				accountingAutoPay=new AccountingAutoPay();
				accountingAutoPay.AccountingAutoPayNum= PIn.Long  (table.Rows[i]["AccountingAutoPayNum"].ToString());
				accountingAutoPay.PayType             = PIn.Long  (table.Rows[i]["PayType"].ToString());
				accountingAutoPay.PickList            = PIn.String(table.Rows[i]["PickList"].ToString());
				retVal.Add(accountingAutoPay);
			}
			return retVal;
		}
 ///<summary>Returns true if Update(AccountingAutoPay,AccountingAutoPay) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(AccountingAutoPay accountingAutoPay, AccountingAutoPay oldAccountingAutoPay)
 {
     if (accountingAutoPay.PayType != oldAccountingAutoPay.PayType)
     {
         return(true);
     }
     if (accountingAutoPay.PickList != oldAccountingAutoPay.PickList)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
        private void butAddPay_Click(object sender, EventArgs e)
        {
            AccountingAutoPay         autoPay = new AccountingAutoPay();
            FormAccountingAutoPayEdit FormA   = new FormAccountingAutoPayEdit();

            FormA.AutoPayCur = autoPay;
            FormA.IsNew      = true;
            if (FormA.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            payAL.Add(autoPay);
            FillPayGrid();
        }
Exemplo n.º 13
0
 ///<summary>Inserts one AccountingAutoPay into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(AccountingAutoPay accountingAutoPay)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(accountingAutoPay, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             accountingAutoPay.AccountingAutoPayNum = DbHelper.GetNextOracleKey("accountingautopay", "AccountingAutoPayNum");                  //Cacheless method
         }
         return(InsertNoCache(accountingAutoPay, true));
     }
 }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <AccountingAutoPay> TableToList(DataTable table)
        {
            List <AccountingAutoPay> retVal = new List <AccountingAutoPay>();
            AccountingAutoPay        accountingAutoPay;

            foreach (DataRow row in table.Rows)
            {
                accountingAutoPay = new AccountingAutoPay();
                accountingAutoPay.AccountingAutoPayNum = PIn.Long(row["AccountingAutoPayNum"].ToString());
                accountingAutoPay.PayType  = PIn.Long(row["PayType"].ToString());
                accountingAutoPay.PickList = PIn.String(row["PickList"].ToString());
                retVal.Add(accountingAutoPay);
            }
            return(retVal);
        }
Exemplo n.º 15
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <AccountingAutoPay> TableToList(DataTable table)
        {
            List <AccountingAutoPay> retVal = new List <AccountingAutoPay>();
            AccountingAutoPay        accountingAutoPay;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                accountingAutoPay = new AccountingAutoPay();
                accountingAutoPay.AccountingAutoPayNum = PIn.Long(table.Rows[i]["AccountingAutoPayNum"].ToString());
                accountingAutoPay.PayType  = PIn.Long(table.Rows[i]["PayType"].ToString());
                accountingAutoPay.PickList = PIn.String(table.Rows[i]["PickList"].ToString());
                retVal.Add(accountingAutoPay);
            }
            return(retVal);
        }
Exemplo n.º 16
0
        ///<summary>Converts the comma delimited list of AccountNums into an array of AccountNums.</summary>
        public static int[] GetPickListAccounts(AccountingAutoPay pay)
        {
            string[]  numArray = pay.PickList.Split(new char[] { ',' });
            ArrayList AL       = new ArrayList();

            for (int i = 0; i < numArray.Length; i++)
            {
                if (numArray[i] == "")
                {
                    continue;
                }
                AL.Add(PIn.PInt(numArray[i]));
            }
            int[] retVal = new int[AL.Count];
            AL.CopyTo(retVal);
            return(retVal);
        }
Exemplo n.º 17
0
        ///<summary>Converts the comma delimited list of AccountNums into full descriptions separated by carriage returns.</summary>
        public static string GetPickListDesc(AccountingAutoPay pay)
        {
            string[] numArray = pay.PickList.Split(new char[] { ',' });
            string   retVal   = "";

            for (int i = 0; i < numArray.Length; i++)
            {
                if (numArray[i] == "")
                {
                    continue;
                }
                if (retVal != "")
                {
                    retVal += "\r\n";
                }
                retVal += Accounts.GetDescript(PIn.PInt(numArray[i]));
            }
            return(retVal);
        }
Exemplo n.º 18
0
        ///<summary>Gets a list of all AccountingAutoPays.</summary>
        public static void Refresh()
        {
            string    command = "SELECT * FROM accountingautopay";
            DataTable table   = General.GetTable(command);

            AccountingAutoPay[] List = new AccountingAutoPay[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new AccountingAutoPay();
                List[i].AccountingAutoPayNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].PayType  = PIn.PInt(table.Rows[i][1].ToString());
                List[i].PickList = PIn.PString(table.Rows[i][2].ToString());
            }
            AList = new ArrayList();
            for (int i = 0; i < List.Length; i++)
            {
                AList.Add(List[i]);
            }
        }
		///<summary>Inserts one AccountingAutoPay into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(AccountingAutoPay accountingAutoPay,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				accountingAutoPay.AccountingAutoPayNum=ReplicationServers.GetKey("accountingautopay","AccountingAutoPayNum");
			}
			string command="INSERT INTO accountingautopay (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="AccountingAutoPayNum,";
			}
			command+="PayType,PickList) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(accountingAutoPay.AccountingAutoPayNum)+",";
			}
			command+=
				     POut.Long  (accountingAutoPay.PayType)+","
				+"'"+POut.String(accountingAutoPay.PickList)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				accountingAutoPay.AccountingAutoPayNum=Db.NonQ(command,true);
			}
			return accountingAutoPay.AccountingAutoPayNum;
		}
 ///<summary>Inserts one AccountingAutoPay into the database.  Returns the new priKey.</summary>
 public static long Insert(AccountingAutoPay accountingAutoPay)
 {
     return(Insert(accountingAutoPay, false));
 }
		///<summary>Updates one AccountingAutoPay in the database.</summary>
		public static void Update(AccountingAutoPay accountingAutoPay){
			string command="UPDATE accountingautopay SET "
				+"PayType             =  "+POut.Long  (accountingAutoPay.PayType)+", "
				+"PickList            = '"+POut.String(accountingAutoPay.PickList)+"' "
				+"WHERE AccountingAutoPayNum = "+POut.Long(accountingAutoPay.AccountingAutoPayNum);
			Db.NonQ(command);
		}
		///<summary>Updates one AccountingAutoPay 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.</summary>
		public static void Update(AccountingAutoPay accountingAutoPay,AccountingAutoPay oldAccountingAutoPay){
			string command="";
			if(accountingAutoPay.PayType != oldAccountingAutoPay.PayType) {
				if(command!=""){ command+=",";}
				command+="PayType = "+POut.Long(accountingAutoPay.PayType)+"";
			}
			if(accountingAutoPay.PickList != oldAccountingAutoPay.PickList) {
				if(command!=""){ command+=",";}
				command+="PickList = '"+POut.String(accountingAutoPay.PickList)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE accountingautopay SET "+command
				+" WHERE AccountingAutoPayNum = "+POut.Long(accountingAutoPay.AccountingAutoPayNum);
			Db.NonQ(command);
		}