Example #1
0
        ///<summary>Primarily used when user clicks OK from the InsPlan window.  Gets a carrierNum from the database based on the other supplied carrier data.  Sets the CarrierNum accordingly. If there is no matching carrier, then a new carrier is created.  The end result is a valid carrierNum to use.</summary>
        public static Carrier GetIndentical(Carrier carrier)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Carrier>(MethodBase.GetCurrentMethod(), carrier));
            }
            if (carrier.CarrierName == "")
            {
                return(new Carrier());               //should probably be null instead
            }
            Carrier retVal  = carrier.Copy();
            string  command = "SELECT CarrierNum FROM carrier WHERE "
                              + "CarrierName = '" + POut.String(carrier.CarrierName) + "' "
                              + "AND Address = '" + POut.String(carrier.Address) + "' "
                              + "AND Address2 = '" + POut.String(carrier.Address2) + "' "
                              + "AND City = '" + POut.String(carrier.City) + "' "
                              + "AND State = '" + POut.String(carrier.State) + "' "
                              + "AND Zip = '" + POut.String(carrier.Zip) + "' "
                              + "AND Phone = '" + POut.String(carrier.Phone) + "' "
                              + "AND ElectID = '" + POut.String(carrier.ElectID) + "' "
                              + "AND NoSendElect = '" + POut.Bool(carrier.NoSendElect) + "'";
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                //A matching carrier was found in the database, so we will use it.
                retVal.CarrierNum = PIn.Long(table.Rows[0][0].ToString());
                return(retVal);
            }
            //No match found.  Decide what to do.  Usually add carrier.--------------------------------------------------------------
            //Canada:
            if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))                           //Canadian. en-CA or fr-CA
            {
                throw new ApplicationException(Lans.g("Carriers", "Carrier not found.")); //gives user a chance to add manually.

                /*if(carrier.ElectID!=""){
                 *      command="SELECT CarrierNum FROM carrier WHERE "
                 +"ElectID = '"+POut.String(carrier.ElectID)+"' "
                 +"AND IsCDA=1";
                 *      table=Db.GetTable(command);
                 *      if(table.Rows.Count>0){//if there already exists a Canadian carrier with that ElectID
                 *              retVal.CarrierNum=PIn.Long(table.Rows[0][0].ToString());
                 *              //set carrier.CarrierNum to the carrier found (all other carrier fields will still be wrong)
                 *              //throw new ApplicationException(Lans.g("Carriers","The carrier information was changed based on the EDI Code provided."));
                 *              return retVal;
                 *      }
                 * }*/
                //Notice that if inserting a carrier, it's never possible to create a canadian carrier.
            }
            Insert(carrier);
            retVal.CarrierNum = carrier.CarrierNum;
            return(retVal);
        }
Example #2
0
        ///<summary>Primarily used when user clicks OK from the InsPlan window.  Gets a carrierNum from the database based on the other supplied carrier
        ///data.  Sets the CarrierNum accordingly. If there is no matching carrier, then a new carrier is created.  The end result is a valid carrierNum
        ///to use.</summary>
        public static Carrier GetIdentical(Carrier carrier, Carrier carrierOld = null)
        {
            if (carrier.CarrierName == "")
            {
                return(new Carrier());               //should probably be null instead
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Carrier>(MethodBase.GetCurrentMethod(), carrier, carrierOld));
            }
            Carrier retVal  = carrier.Copy();
            string  command = "SELECT CarrierNum,Phone FROM carrier WHERE "
                              + "CarrierName = '" + POut.String(carrier.CarrierName) + "' "
                              + "AND Address = '" + POut.String(carrier.Address) + "' "
                              + "AND Address2 = '" + POut.String(carrier.Address2) + "' "
                              + "AND City = '" + POut.String(carrier.City) + "' "
                              + "AND State LIKE '" + POut.String(carrier.State) + "' "//This allows user to remove trailing spaces from the FormInsPlan interface.
                              + "AND Zip = '" + POut.String(carrier.Zip) + "' "
                              + "AND ElectID = '" + POut.String(carrier.ElectID) + "' "
                              + "AND NoSendElect = " + POut.Int((int)carrier.NoSendElect);
            DataTable table = Db.GetTable(command);
            //Previously carrier.Phone has been given to us after being formatted by ValidPhone in the UI (FormInsPlan).
            //Strip all formatting from the given phone number and the DB phone numbers to compare.
            //The phone in the database could be in a different format if it was imported in an old version.
            string carrierPhoneStripped = carrier.Phone.StripNonDigits();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                string phone = PIn.String(table.Rows[i]["Phone"].ToString());
                if (phone.StripNonDigits() == carrierPhoneStripped)
                {
                    //A matching carrier was found in the database, so we will use it.
                    retVal.CarrierNum = PIn.Long(table.Rows[i][0].ToString());
                    return(retVal);
                }
            }
            //No match found.  Decide what to do.  Usually add carrier.--------------------------------------------------------------
            //Canada:
            if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))                           //Canadian. en-CA or fr-CA
            {
                throw new ApplicationException(Lans.g("Carriers", "Carrier not found.")); //gives user a chance to add manually.
            }
            //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
            carrier.SecUserNumEntry = Security.CurUser.UserNum;
            Insert(carrier, carrierOld);            //insert function takes care of logging.
            retVal.CarrierNum = carrier.CarrierNum;
            return(retVal);
        }
Example #3
0
        ///<summary>Primarily used when user clicks OK from the InsPlan window.  Gets a carrierNum from the database based on the other supplied carrier
        ///data.  Sets the CarrierNum accordingly. If there is no matching carrier, then a new carrier is created.  The end result is a valid carrierNum
        ///to use.  No need to pass in userNum, it's set before remoting role check and passed to the server if necessary.</summary>
        public static Carrier GetIdentical(Carrier carrier, long userNum = 0, Carrier carrierOld = null)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <Carrier>(MethodBase.GetCurrentMethod(), carrier, userNum, carrierOld));
            }
            if (carrier.CarrierName == "")
            {
                return(new Carrier());               //should probably be null instead
            }
            Carrier retVal  = carrier.Copy();
            string  command = "SELECT CarrierNum FROM carrier WHERE "
                              + "CarrierName = '" + POut.String(carrier.CarrierName) + "' "
                              + "AND Address = '" + POut.String(carrier.Address) + "' "
                              + "AND Address2 = '" + POut.String(carrier.Address2) + "' "
                              + "AND City = '" + POut.String(carrier.City) + "' "
                              + "AND State LIKE '" + POut.String(carrier.State) + "' "//This allows user to remove trailing spaces from the FormInsPlan interface.
                              + "AND Zip = '" + POut.String(carrier.Zip) + "' "
                              + "AND Phone = '" + POut.String(carrier.Phone) + "' "
                              + "AND ElectID = '" + POut.String(carrier.ElectID) + "' "
                              + "AND NoSendElect = '" + POut.Bool(carrier.NoSendElect) + "'";
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count > 0)
            {
                //A matching carrier was found in the database, so we will use it.
                retVal.CarrierNum = PIn.Long(table.Rows[0][0].ToString());
                return(retVal);
            }
            //No match found.  Decide what to do.  Usually add carrier.--------------------------------------------------------------
            //Canada:
            if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))                           //Canadian. en-CA or fr-CA
            {
                throw new ApplicationException(Lans.g("Carriers", "Carrier not found.")); //gives user a chance to add manually.
            }
            carrier.SecUserNumEntry = userNum;
            Insert(carrier, carrierOld);            //insert function takes care of logging.
            retVal.CarrierNum = carrier.CarrierNum;
            return(retVal);
        }
Example #4
0
 ///<summary>Surround with try/catch if possibly adding a Canadian carrier.</summary>
 public static long Insert(Carrier carrier, Carrier carrierOld = null)
 {
     if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
     {
         carrier.SecUserNumEntry = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
     }
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         carrier.CarrierNum = Meth.GetLong(MethodBase.GetCurrentMethod(), carrier, carrierOld);
         return(carrier.CarrierNum);
     }
     //string command;
     if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
     {
         if (carrier.IsCDA)
         {
             if (carrier.ElectID == "")
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required."));
             }
             if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$"))
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers."));
             }
         }
     }
     if (carrierOld == null)
     {
         carrierOld = carrier.Copy();
     }
     Crud.CarrierCrud.Insert(carrier);
     if (carrierOld.CarrierNum != 0)
     {
         InsEditLogs.MakeLogEntry(carrier, carrierOld, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     else
     {
         InsEditLogs.MakeLogEntry(carrier, null, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     return(carrier.CarrierNum);
 }
Example #5
0
 ///<summary>Surround with try/catch if possibly adding a Canadian carrier.</summary>
 public static long Insert(Carrier carrier, Carrier carrierOld = null, bool useExistingPriKey = false)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         carrier.CarrierNum = Meth.GetLong(MethodBase.GetCurrentMethod(), carrier, carrierOld, useExistingPriKey);
         return(carrier.CarrierNum);
     }
     //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
     carrier.SecUserNumEntry = Security.CurUser.UserNum;
     //string command;
     if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
     {
         if (carrier.IsCDA)
         {
             if (carrier.ElectID == "")
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required."));
             }
             if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$"))
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers."));
             }
         }
     }
     if (carrierOld == null)
     {
         carrierOld = carrier.Copy();
     }
     Crud.CarrierCrud.Insert(carrier, useExistingPriKey);
     if (carrierOld.CarrierNum != 0)
     {
         InsEditLogs.MakeLogEntry(carrier, carrierOld, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     else
     {
         InsEditLogs.MakeLogEntry(carrier, null, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     return(carrier.CarrierNum);
 }
Example #6
0
File: Carriers.cs Project: mnisl/OD
		///<summary>Primarily used when user clicks OK from the InsPlan window.  Gets a carrierNum from the database based on the other supplied carrier data.  Sets the CarrierNum accordingly. If there is no matching carrier, then a new carrier is created.  The end result is a valid carrierNum to use.</summary>
		public static Carrier GetIndentical(Carrier carrier){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<Carrier>(MethodBase.GetCurrentMethod(),carrier);
			}
			if(carrier.CarrierName=="") {
				return new Carrier();//should probably be null instead
			}
			Carrier retVal=carrier.Copy();
			string command="SELECT CarrierNum FROM carrier WHERE " 
				+"CarrierName = '"    +POut.String(carrier.CarrierName)+"' "
				+"AND Address = '"    +POut.String(carrier.Address)+"' "
				+"AND Address2 = '"   +POut.String(carrier.Address2)+"' "
				+"AND City = '"       +POut.String(carrier.City)+"' "
				+"AND State LIKE '"   +POut.String(carrier.State)+"' "//This allows user to remove trailing spaces from the FormInsPlan interface.
				+"AND Zip = '"        +POut.String(carrier.Zip)+"' "
				+"AND Phone = '"      +POut.String(carrier.Phone)+"' "
				+"AND ElectID = '"    +POut.String(carrier.ElectID)+"' "
				+"AND NoSendElect = '"+POut.Bool  (carrier.NoSendElect)+"'";
			DataTable table=Db.GetTable(command);
			if(table.Rows.Count>0){
				//A matching carrier was found in the database, so we will use it.
				retVal.CarrierNum=PIn.Long(table.Rows[0][0].ToString());
				return retVal;
			}
			//No match found.  Decide what to do.  Usually add carrier.--------------------------------------------------------------
			//Canada:
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				throw new ApplicationException(Lans.g("Carriers","Carrier not found."));//gives user a chance to add manually.
				/*if(carrier.ElectID!=""){
					command="SELECT CarrierNum FROM carrier WHERE "
						+"ElectID = '"+POut.String(carrier.ElectID)+"' "
						+"AND IsCDA=1";
					table=Db.GetTable(command);
					if(table.Rows.Count>0){//if there already exists a Canadian carrier with that ElectID
						retVal.CarrierNum=PIn.Long(table.Rows[0][0].ToString());
						//set carrier.CarrierNum to the carrier found (all other carrier fields will still be wrong)
						//throw new ApplicationException(Lans.g("Carriers","The carrier information was changed based on the EDI Code provided."));
						return retVal;
					}
				}*/
				//Notice that if inserting a carrier, it's never possible to create a canadian carrier.
			}
			Insert(carrier);
			retVal.CarrierNum=carrier.CarrierNum;
			return retVal;
		}