Beispiel #1
0
 ///<summary>Inserts one ProcButton into the database.  Returns the new priKey.</summary>
 public static long Insert(ProcButton procButton)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         procButton.ProcButtonNum = DbHelper.GetNextOracleKey("procbutton", "ProcButtonNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(procButton, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     procButton.ProcButtonNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(procButton, false));
     }
 }
Beispiel #2
0
        private void butUp_Click(object sender, System.EventArgs e)
        {
            int selected = 0;

            if (listViewButtons.SelectedIndices.Count == 0)
            {
                return;
            }
            else if (listViewButtons.SelectedIndices[0] == 0)
            {
                return;
            }
            else
            {
                ProcButton but = ButtonList[listViewButtons.SelectedIndices[0]].Copy();
                but.ItemOrder--;
                ProcButtons.Update(but);
                selected = but.ItemOrder;
                but      = ButtonList[listViewButtons.SelectedIndices[0] - 1].Copy();
                but.ItemOrder++;
                ProcButtons.Update(but);
            }
            FillButtons();
            changed = true;
            listViewButtons.SelectedIndices.Clear();
            listViewButtons.SelectedIndices.Add(selected);
        }
Beispiel #3
0
 ///<summary>Inserts one ProcButton into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(ProcButton procButton,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         procButton.ProcButtonNum=ReplicationServers.GetKey("procbutton","ProcButtonNum");
     }
     string command="INSERT INTO procbutton (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="ProcButtonNum,";
     }
     command+="Description,ItemOrder,Category,ButtonImage) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(procButton.ProcButtonNum)+",";
     }
     command+=
          "'"+POut.String(procButton.Description)+"',"
         +    POut.Int   (procButton.ItemOrder)+","
         +    POut.Long  (procButton.Category)+","
         +DbHelper.ParamChar+"paramButtonImage)";
     if(procButton.ButtonImage==null) {
         procButton.ButtonImage="";
     }
     OdSqlParameter paramButtonImage=new OdSqlParameter("paramButtonImage",OdDbType.Text,procButton.ButtonImage);
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command,paramButtonImage);
     }
     else {
         procButton.ProcButtonNum=Db.NonQ(command,true,paramButtonImage);
     }
     return procButton.ProcButtonNum;
 }
Beispiel #4
0
 ///<summary>Inserts one ProcButton into the database.  Returns the new priKey.</summary>
 internal static long Insert(ProcButton procButton)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         procButton.ProcButtonNum=DbHelper.GetNextOracleKey("procbutton","ProcButtonNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(procButton,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     procButton.ProcButtonNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(procButton,false);
     }
 }
Beispiel #5
0
        ///<summary>Updates one ProcButton 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(ProcButton procButton, ProcButton oldProcButton)
        {
            string command = "";

            if (procButton.Description != oldProcButton.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(procButton.Description) + "'";
            }
            if (procButton.ItemOrder != oldProcButton.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(procButton.ItemOrder) + "";
            }
            if (procButton.Category != oldProcButton.Category)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Category = " + POut.Long(procButton.Category) + "";
            }
            if (procButton.ButtonImage != oldProcButton.ButtonImage)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ButtonImage = " + DbHelper.ParamChar + "paramButtonImage";
            }
            if (procButton.IsMultiVisit != oldProcButton.IsMultiVisit)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsMultiVisit = " + POut.Bool(procButton.IsMultiVisit) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (procButton.ButtonImage == null)
            {
                procButton.ButtonImage = "";
            }
            OdSqlParameter paramButtonImage = new OdSqlParameter("paramButtonImage", OdDbType.Text, POut.StringParam(procButton.ButtonImage));

            command = "UPDATE procbutton SET " + command
                      + " WHERE ProcButtonNum = " + POut.Long(procButton.ProcButtonNum);
            Db.NonQ(command, paramButtonImage);
            return(true);
        }
Beispiel #6
0
        ///<summary></summary>
        public static void Delete(ProcButton but)
        {
            string command = "DELETE FROM procbuttonitem WHERE ProcButtonNum = '"
                             + POut.PInt(but.ProcButtonNum) + "'";

            General.NonQ(command);
            command = "DELETE FROM procbutton WHERE ProcButtonNum = '"
                      + POut.PInt(but.ProcButtonNum) + "'";
            General.NonQ(command);
        }
Beispiel #7
0
        ///<summary>must have already checked ADACode for nonduplicate.</summary>
        public static void Insert(ProcButton but)
        {
            string command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES("
                             + "'" + POut.PString(but.Description) + "', "
                             + "'" + POut.PInt(but.ItemOrder) + "', "
                             + "'" + POut.PInt(but.Category) + "', "
                             + "'" + POut.PBitmap(but.ButtonImage) + "')";

            but.ProcButtonNum = General.NonQ(command, true);
        }
Beispiel #8
0
        ///<summary></summary>
        public static void Update(ProcButton but)
        {
            string command = "UPDATE procbutton SET "
                             + "Description = '" + POut.PString(but.Description) + "'"
                             + ",ItemOrder = '" + POut.PInt(but.ItemOrder) + "'"
                             + ",Category = '" + POut.PInt(but.Category) + "'"
                             + ",ButtonImage = '" + POut.PBitmap(but.ButtonImage) + "'"
                             + " WHERE ProcButtonNum = '" + POut.PInt(but.ProcButtonNum) + "'";

            General.NonQ(command);
        }
Beispiel #9
0
        private void listViewButtons_DoubleClick(object sender, EventArgs e)
        {
            if (listViewButtons.SelectedIndices.Count == 0)
            {
                return;
            }
            ProcButton         but     = ButtonList[listViewButtons.SelectedIndices[0]].Copy();
            FormProcButtonEdit FormPBE = new FormProcButtonEdit(but);

            FormPBE.ShowDialog();
            changed = true;
            FillButtons();
        }
Beispiel #10
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ProcButton> TableToList(DataTable table){
			List<ProcButton> retVal=new List<ProcButton>();
			ProcButton procButton;
			for(int i=0;i<table.Rows.Count;i++) {
				procButton=new ProcButton();
				procButton.ProcButtonNum= PIn.Long  (table.Rows[i]["ProcButtonNum"].ToString());
				procButton.Description  = PIn.String(table.Rows[i]["Description"].ToString());
				procButton.ItemOrder    = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				procButton.Category     = PIn.Long  (table.Rows[i]["Category"].ToString());
				procButton.ButtonImage  = PIn.String(table.Rows[i]["ButtonImage"].ToString());
				retVal.Add(procButton);
			}
			return retVal;
		}
Beispiel #11
0
        void ReleaseDesignerOutlets()
        {
            if (ProcButton != null)
            {
                ProcButton.Dispose();
                ProcButton = null;
            }

            if (IdleLabel != null)
            {
                IdleLabel.Dispose();
                IdleLabel = null;
            }

            if (IdleLevel != null)
            {
                IdleLevel.Dispose();
                IdleLevel = null;
            }

            if (LoadLabel != null)
            {
                LoadLabel.Dispose();
                LoadLabel = null;
            }

            if (LoadLevel != null)
            {
                LoadLevel.Dispose();
                LoadLevel = null;
            }

            if (ReasonLabel != null)
            {
                ReasonLabel.Dispose();
                ReasonLabel = null;
            }

            if (VarLabel != null)
            {
                VarLabel.Dispose();
                VarLabel = null;
            }

            if (VarLevel != null)
            {
                VarLevel.Dispose();
                VarLevel = null;
            }
        }
Beispiel #12
0
        ///<summary></summary>
        public static ProcButton[] GetForCat(int selectedCat)
        {
            ArrayList AL = new ArrayList();

            for (int i = 0; i < List.Length; i++)
            {
                if (List[i].Category == selectedCat)
                {
                    AL.Add(List[i]);
                }
            }
            ProcButton[] retVal = new ProcButton[AL.Count];
            AL.CopyTo(retVal);
            return(retVal);
        }
Beispiel #13
0
 ///<summary>Inserts one ProcButton into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcButton procButton)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(procButton, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             procButton.ProcButtonNum = DbHelper.GetNextOracleKey("procbutton", "ProcButtonNum");                  //Cacheless method
         }
         return(InsertNoCache(procButton, true));
     }
 }
Beispiel #14
0
        ///<summary></summary>
        public static void Refresh()
        {
            string    command = "SELECT * FROM procbutton ORDER BY ItemOrder";
            DataTable table   = General.GetTable(command);

            List = new ProcButton[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new ProcButton();
                List[i].ProcButtonNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].Description   = PIn.PString(table.Rows[i][1].ToString());
                List[i].ItemOrder     = PIn.PInt(table.Rows[i][2].ToString());
                List[i].Category      = PIn.PInt(table.Rows[i][3].ToString());
                List[i].ButtonImage   = PIn.PBitmap(table.Rows[i][4].ToString());
            }
        }
Beispiel #15
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            if (listCategories.SelectedIndex == -1)
            {
                return;
            }
            ProcButton but = new ProcButton();

            but.Category  = selectedCat;
            but.ItemOrder = listViewButtons.Items.Count;
            FormProcButtonEdit FormPBE = new FormProcButtonEdit(but);

            FormPBE.IsNew = true;
            FormPBE.ShowDialog();
            changed = true;
            FillButtons();
        }
Beispiel #16
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProcButton> TableToList(DataTable table)
        {
            List <ProcButton> retVal = new List <ProcButton>();
            ProcButton        procButton;

            foreach (DataRow row in table.Rows)
            {
                procButton = new ProcButton();
                procButton.ProcButtonNum = PIn.Long(row["ProcButtonNum"].ToString());
                procButton.Description   = PIn.String(row["Description"].ToString());
                procButton.ItemOrder     = PIn.Int(row["ItemOrder"].ToString());
                procButton.Category      = PIn.Long(row["Category"].ToString());
                procButton.ButtonImage   = PIn.String(row["ButtonImage"].ToString());
                retVal.Add(procButton);
            }
            return(retVal);
        }
Beispiel #17
0
        ///<summary>Updates one ProcButton in the database.</summary>
        public static void Update(ProcButton procButton)
        {
            string command = "UPDATE procbutton SET "
                             + "Description  = '" + POut.String(procButton.Description) + "', "
                             + "ItemOrder    =  " + POut.Int(procButton.ItemOrder) + ", "
                             + "Category     =  " + POut.Long(procButton.Category) + ", "
                             + "ButtonImage  =  " + DbHelper.ParamChar + "paramButtonImage "
                             + "WHERE ProcButtonNum = " + POut.Long(procButton.ProcButtonNum);

            if (procButton.ButtonImage == null)
            {
                procButton.ButtonImage = "";
            }
            OdSqlParameter paramButtonImage = new OdSqlParameter("paramButtonImage", OdDbType.Text, POut.StringParam(procButton.ButtonImage));

            Db.NonQ(command, paramButtonImage);
        }
Beispiel #18
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProcButton> TableToList(DataTable table)
        {
            List <ProcButton> retVal = new List <ProcButton>();
            ProcButton        procButton;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                procButton = new ProcButton();
                procButton.ProcButtonNum = PIn.Long(table.Rows[i]["ProcButtonNum"].ToString());
                procButton.Description   = PIn.String(table.Rows[i]["Description"].ToString());
                procButton.ItemOrder     = PIn.Int(table.Rows[i]["ItemOrder"].ToString());
                procButton.Category      = PIn.Long(table.Rows[i]["Category"].ToString());
                procButton.ButtonImage   = PIn.String(table.Rows[i]["ButtonImage"].ToString());
                retVal.Add(procButton);
            }
            return(retVal);
        }
Beispiel #19
0
 ///<summary>Returns true if Update(ProcButton,ProcButton) 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(ProcButton procButton, ProcButton oldProcButton)
 {
     if (procButton.Description != oldProcButton.Description)
     {
         return(true);
     }
     if (procButton.ItemOrder != oldProcButton.ItemOrder)
     {
         return(true);
     }
     if (procButton.Category != oldProcButton.Category)
     {
         return(true);
     }
     if (procButton.ButtonImage != oldProcButton.ButtonImage)
     {
         return(true);
     }
     return(false);
 }
Beispiel #20
0
        ///<summary>Inserts one ProcButton into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ProcButton procButton, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO procbutton (";

            if (!useExistingPK && isRandomKeys)
            {
                procButton.ProcButtonNum = ReplicationServers.GetKeyNoCache("procbutton", "ProcButtonNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ProcButtonNum,";
            }
            command += "Description,ItemOrder,Category,ButtonImage,IsMultiVisit) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(procButton.ProcButtonNum) + ",";
            }
            command +=
                "'" + POut.String(procButton.Description) + "',"
                + POut.Int(procButton.ItemOrder) + ","
                + POut.Long(procButton.Category) + ","
                + DbHelper.ParamChar + "paramButtonImage,"
                + POut.Bool(procButton.IsMultiVisit) + ")";
            if (procButton.ButtonImage == null)
            {
                procButton.ButtonImage = "";
            }
            OdSqlParameter paramButtonImage = new OdSqlParameter("paramButtonImage", OdDbType.Text, POut.StringParam(procButton.ButtonImage));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramButtonImage);
            }
            else
            {
                procButton.ProcButtonNum = Db.NonQ(command, true, "ProcButtonNum", "procButton", paramButtonImage);
            }
            return(procButton.ProcButtonNum);
        }
Beispiel #21
0
        ///<summary>Inserts one ProcButton into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ProcButton procButton, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                procButton.ProcButtonNum = ReplicationServers.GetKey("procbutton", "ProcButtonNum");
            }
            string command = "INSERT INTO procbutton (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ProcButtonNum,";
            }
            command += "Description,ItemOrder,Category,ButtonImage) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(procButton.ProcButtonNum) + ",";
            }
            command +=
                "'" + POut.String(procButton.Description) + "',"
                + POut.Int(procButton.ItemOrder) + ","
                + POut.Long(procButton.Category) + ","
                + DbHelper.ParamChar + "paramButtonImage)";
            if (procButton.ButtonImage == null)
            {
                procButton.ButtonImage = "";
            }
            OdSqlParameter paramButtonImage = new OdSqlParameter("paramButtonImage", OdDbType.Text, POut.StringParam(procButton.ButtonImage));

            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command, paramButtonImage);
            }
            else
            {
                procButton.ProcButtonNum = Db.NonQ(command, true, "ProcButtonNum", "procButton", paramButtonImage);
            }
            return(procButton.ProcButtonNum);
        }
Beispiel #22
0
 ///<summary>Inserts one ProcButton into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProcButton procButton)
 {
     return(InsertNoCache(procButton, false));
 }
 ///<summary></summary>
 public FormProcButtonEdit(ProcButton procButtonCur)
 {
     InitializeComponent();
     Lan.F(this);
     ProcButtonCur = procButtonCur;
 }
Beispiel #24
0
 ///<summary>Updates one ProcButton 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>
 internal static void Update(ProcButton procButton,ProcButton oldProcButton)
 {
     string command="";
     if(procButton.Description != oldProcButton.Description) {
         if(command!=""){ command+=",";}
         command+="Description = '"+POut.String(procButton.Description)+"'";
     }
     if(procButton.ItemOrder != oldProcButton.ItemOrder) {
         if(command!=""){ command+=",";}
         command+="ItemOrder = "+POut.Int(procButton.ItemOrder)+"";
     }
     if(procButton.Category != oldProcButton.Category) {
         if(command!=""){ command+=",";}
         command+="Category = "+POut.Long(procButton.Category)+"";
     }
     if(procButton.ButtonImage != oldProcButton.ButtonImage) {
         if(command!=""){ command+=",";}
         command+="ButtonImage = "+DbHelper.ParamChar+"paramButtonImage";
     }
     if(command==""){
         return;
     }
     if(procButton.ButtonImage==null) {
         procButton.ButtonImage="";
     }
     OdSqlParameter paramButtonImage=new OdSqlParameter("paramButtonImage",OdDbType.Text,procButton.ButtonImage);
     command="UPDATE procbutton SET "+command
         +" WHERE ProcButtonNum = "+POut.Long(procButton.ProcButtonNum);
     Db.NonQ(command,paramButtonImage);
 }
Beispiel #25
0
 ///<summary>Updates one ProcButton in the database.</summary>
 internal static void Update(ProcButton procButton)
 {
     string command="UPDATE procbutton SET "
         +"Description  = '"+POut.String(procButton.Description)+"', "
         +"ItemOrder    =  "+POut.Int   (procButton.ItemOrder)+", "
         +"Category     =  "+POut.Long  (procButton.Category)+", "
         +"ButtonImage  =  "+DbHelper.ParamChar+"paramButtonImage "
         +"WHERE ProcButtonNum = "+POut.Long(procButton.ProcButtonNum);
     if(procButton.ButtonImage==null) {
         procButton.ButtonImage="";
     }
     OdSqlParameter paramButtonImage=new OdSqlParameter("paramButtonImage",OdDbType.Text,procButton.ButtonImage);
     Db.NonQ(command,paramButtonImage);
 }