Пример #1
0
        //Conference Room--------------------------------------------
        private void butGetConfRoom_Click(object sender, EventArgs e)
        {
            if (_listPhones == null || _listPhoneEmpDefaults == null)
            {
                FillTile();
            }
            PhoneEmpDefault ped = null;

            try {
                //phoneTile.PhoneCur could be null which the following line would fail so we will surround this with a try / catch.
                ped = _listPhoneEmpDefaults.FirstOrDefault(x => x.PhoneExt == phoneTile.PhoneCur.Extension);
                if (ped == null)
                {
                    throw new ApplicationException("Invalid PhoneEmpDefault");
                }
            }
            catch (Exception ex) {
                ex.DoNothing();
                MsgBox.Show(this, "This extension is not currently associated to a valid PhoneEmpDefault row.");
                return;
            }
            if (ped.SiteNum < 1)
            {
                MsgBox.Show(this, "This extension is not currently associated to a site.\r\n"
                            + "A site must first be set within the Edit Employee Setting window.");
                return;
            }
            timerConfRoom.Stop();
            labelConfRoom.Text    = "Reserving Conf Room...";
            labelConfRoom.Visible = true;
            _phoneConf            = PhoneConfs.GetAndReserveConfRoom(ped.SiteNum);
            _dateTimeConfRoom     = DateTime.Now;
            _dateTimeConfRoomEnd  = _dateTimeConfRoom.AddMinutes(5);
            timerConfRoom.Start();
        }
Пример #2
0
        ///<summary>Inserts one PhoneConf into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(PhoneConf phoneConf, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO phoneconf (";

            if (!useExistingPK && isRandomKeys)
            {
                phoneConf.PhoneConfNum = ReplicationServers.GetKeyNoCache("phoneconf", "PhoneConfNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "PhoneConfNum,";
            }
            command += "ButtonIndex,Occupants,Extension,DateTimeReserved,UserNum,SiteNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(phoneConf.PhoneConfNum) + ",";
            }
            command +=
                POut.Int(phoneConf.ButtonIndex) + ","
                + POut.Int(phoneConf.Occupants) + ","
                + POut.Int(phoneConf.Extension) + ","
                + POut.DateT(phoneConf.DateTimeReserved) + ","
                + POut.Long(phoneConf.UserNum) + ","
                + POut.Long(phoneConf.SiteNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                phoneConf.PhoneConfNum = Db.NonQ(command, true, "PhoneConfNum", "phoneConf");
            }
            return(phoneConf.PhoneConfNum);
        }
Пример #3
0
 ///<summary>Returns true if Update(PhoneConf,PhoneConf) 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(PhoneConf phoneConf, PhoneConf oldPhoneConf)
 {
     if (phoneConf.ButtonIndex != oldPhoneConf.ButtonIndex)
     {
         return(true);
     }
     if (phoneConf.Occupants != oldPhoneConf.Occupants)
     {
         return(true);
     }
     if (phoneConf.Extension != oldPhoneConf.Extension)
     {
         return(true);
     }
     if (phoneConf.DateTimeReserved != oldPhoneConf.DateTimeReserved)
     {
         return(true);
     }
     if (phoneConf.UserNum != oldPhoneConf.UserNum)
     {
         return(true);
     }
     if (phoneConf.SiteNum != oldPhoneConf.SiteNum)
     {
         return(true);
     }
     return(false);
 }
Пример #4
0
 ///<summary>Inserts one PhoneConf into the database.  Returns the new priKey.</summary>
 public static long Insert(PhoneConf phoneConf)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         phoneConf.PhoneConfNum = DbHelper.GetNextOracleKey("phoneconf", "PhoneConfNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(phoneConf, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     phoneConf.PhoneConfNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(phoneConf, false));
     }
 }
Пример #5
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PhoneConf> TableToList(DataTable table){
			List<PhoneConf> retVal=new List<PhoneConf>();
			PhoneConf phoneConf;
			for(int i=0;i<table.Rows.Count;i++) {
				phoneConf=new PhoneConf();
				phoneConf.PhoneConfNum= PIn.Long  (table.Rows[i]["PhoneConfNum"].ToString());
				phoneConf.ButtonIndex = PIn.Int   (table.Rows[i]["ButtonIndex"].ToString());
				phoneConf.Occupants   = PIn.Int   (table.Rows[i]["Occupants"].ToString());
				phoneConf.Extension   = PIn.Int   (table.Rows[i]["Extension"].ToString());
				retVal.Add(phoneConf);
			}
			return retVal;
		}
Пример #6
0
        ///<summary>Updates one PhoneConf in the database.</summary>
        public static void Update(PhoneConf phoneConf)
        {
            string command = "UPDATE phoneconf SET "
                             + "ButtonIndex     =  " + POut.Int(phoneConf.ButtonIndex) + ", "
                             + "Occupants       =  " + POut.Int(phoneConf.Occupants) + ", "
                             + "Extension       =  " + POut.Int(phoneConf.Extension) + ", "
                             + "DateTimeReserved=  " + POut.DateT(phoneConf.DateTimeReserved) + ", "
                             + "UserNum         =  " + POut.Long(phoneConf.UserNum) + ", "
                             + "SiteNum         =  " + POut.Long(phoneConf.SiteNum) + " "
                             + "WHERE PhoneConfNum = " + POut.Long(phoneConf.PhoneConfNum);

            Db.NonQ(command);
        }
Пример #7
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            PhoneConf phoneConf = new PhoneConf();

            phoneConf.ButtonIndex = -1;
            phoneConf.IsNew       = true;
            FormPhoneConfEdit FormPCE = new FormPhoneConfEdit(phoneConf);

            FormPCE.ShowDialog();
            if (FormPCE.DialogResult == DialogResult.OK)
            {
                FillGrid();
            }
        }
Пример #8
0
 ///<summary>Inserts one PhoneConf into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PhoneConf phoneConf)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(phoneConf, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             phoneConf.PhoneConfNum = DbHelper.GetNextOracleKey("phoneconf", "PhoneConfNum");                  //Cacheless method
         }
         return(InsertNoCache(phoneConf, true));
     }
 }
Пример #9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PhoneConf> TableToList(DataTable table)
        {
            List <PhoneConf> retVal = new List <PhoneConf>();
            PhoneConf        phoneConf;

            foreach (DataRow row in table.Rows)
            {
                phoneConf = new PhoneConf();
                phoneConf.PhoneConfNum     = PIn.Long(row["PhoneConfNum"].ToString());
                phoneConf.ButtonIndex      = PIn.Int(row["ButtonIndex"].ToString());
                phoneConf.Occupants        = PIn.Int(row["Occupants"].ToString());
                phoneConf.Extension        = PIn.Int(row["Extension"].ToString());
                phoneConf.DateTimeReserved = PIn.DateT(row["DateTimeReserved"].ToString());
                phoneConf.UserNum          = PIn.Long(row["UserNum"].ToString());
                phoneConf.SiteNum          = PIn.Long(row["SiteNum"].ToString());
                retVal.Add(phoneConf);
            }
            return(retVal);
        }
Пример #10
0
		///<summary>Inserts one PhoneConf into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(PhoneConf phoneConf,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				phoneConf.PhoneConfNum=ReplicationServers.GetKey("phoneconf","PhoneConfNum");
			}
			string command="INSERT INTO phoneconf (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="PhoneConfNum,";
			}
			command+="ButtonIndex,Occupants,Extension) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(phoneConf.PhoneConfNum)+",";
			}
			command+=
				     POut.Int   (phoneConf.ButtonIndex)+","
				+    POut.Int   (phoneConf.Occupants)+","
				+    POut.Int   (phoneConf.Extension)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				phoneConf.PhoneConfNum=Db.NonQ(command,true);
			}
			return phoneConf.PhoneConfNum;
		}
Пример #11
0
		///<summary>Inserts one PhoneConf into the database.  Returns the new priKey.</summary>
		public static long Insert(PhoneConf phoneConf){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				phoneConf.PhoneConfNum=DbHelper.GetNextOracleKey("phoneconf","PhoneConfNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(phoneConf,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							phoneConf.PhoneConfNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(phoneConf,false);
			}
		}
Пример #12
0
		///<summary>Updates one PhoneConf 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(PhoneConf phoneConf,PhoneConf oldPhoneConf){
			string command="";
			if(phoneConf.ButtonIndex != oldPhoneConf.ButtonIndex) {
				if(command!=""){ command+=",";}
				command+="ButtonIndex = "+POut.Int(phoneConf.ButtonIndex)+"";
			}
			if(phoneConf.Occupants != oldPhoneConf.Occupants) {
				if(command!=""){ command+=",";}
				command+="Occupants = "+POut.Int(phoneConf.Occupants)+"";
			}
			if(phoneConf.Extension != oldPhoneConf.Extension) {
				if(command!=""){ command+=",";}
				command+="Extension = "+POut.Int(phoneConf.Extension)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE phoneconf SET "+command
				+" WHERE PhoneConfNum = "+POut.Long(phoneConf.PhoneConfNum);
			Db.NonQ(command);
			return true;
		}
Пример #13
0
		///<summary>Updates one PhoneConf in the database.</summary>
		public static void Update(PhoneConf phoneConf){
			string command="UPDATE phoneconf SET "
				+"ButtonIndex =  "+POut.Int   (phoneConf.ButtonIndex)+", "
				+"Occupants   =  "+POut.Int   (phoneConf.Occupants)+", "
				+"Extension   =  "+POut.Int   (phoneConf.Extension)+" "
				+"WHERE PhoneConfNum = "+POut.Long(phoneConf.PhoneConfNum);
			Db.NonQ(command);
		}
Пример #14
0
 public FormPhoneConfEdit(PhoneConf phoneConf)
 {
     InitializeComponent();
     Lan.F(this);
     _phoneConf = phoneConf.Copy();
 }
Пример #15
0
        ///<summary>Updates one PhoneConf 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(PhoneConf phoneConf, PhoneConf oldPhoneConf)
        {
            string command = "";

            if (phoneConf.ButtonIndex != oldPhoneConf.ButtonIndex)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ButtonIndex = " + POut.Int(phoneConf.ButtonIndex) + "";
            }
            if (phoneConf.Occupants != oldPhoneConf.Occupants)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Occupants = " + POut.Int(phoneConf.Occupants) + "";
            }
            if (phoneConf.Extension != oldPhoneConf.Extension)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Extension = " + POut.Int(phoneConf.Extension) + "";
            }
            if (phoneConf.DateTimeReserved != oldPhoneConf.DateTimeReserved)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeReserved = " + POut.DateT(phoneConf.DateTimeReserved) + "";
            }
            if (phoneConf.UserNum != oldPhoneConf.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(phoneConf.UserNum) + "";
            }
            if (phoneConf.SiteNum != oldPhoneConf.SiteNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SiteNum = " + POut.Long(phoneConf.SiteNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE phoneconf SET " + command
                      + " WHERE PhoneConfNum = " + POut.Long(phoneConf.PhoneConfNum);
            Db.NonQ(command);
            return(true);
        }
Пример #16
0
 ///<summary>Inserts one PhoneConf into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PhoneConf phoneConf)
 {
     return(InsertNoCache(phoneConf, false));
 }