예제 #1
0
        public static int GetInterimCarrierCompanyID(ref DispatchData dispatch_data)
        {
            object  objTempID;
            int     intInterimCarrierCompID;
            string  strSQL         = "";
            Company interimCompany = Helper.GetInterimCompanyDetails(ref dispatch_data);

            strSQL = "select top 1 CompID from tbl_Company where CompName=" + DB.GetSingleQuoteValue(interimCompany.CompName)
                     + "and Carrier=1 "
                     + "and Addr1=" + DB.GetSingleQuoteValue(interimCompany.Addr1)
                     + "and Addr2=" + DB.GetSingleQuoteValue(interimCompany.Addr2)
                     + "and City=" + DB.GetSingleQuoteValue(interimCompany.City)
                     + "and State=" + DB.GetSingleQuoteValue(interimCompany.State)
                     + "and Zip=" + DB.GetSingleQuoteValue(interimCompany.Zip)
                     + "and Phone=" + DB.GetSingleQuoteValue(interimCompany.Phone)
                     + "and Fax=" + DB.GetSingleQuoteValue("");

            //comm.CommandText = strSQL;
            objTempID = HelperFuncs.ExecuteScalar(AppCodeConstants.connStringAesData, ref strSQL,
                                                  "Dispatch GetInterimCarrierCompanyID");
            //

            //
            if (objTempID != null)
            {
                intInterimCarrierCompID = Convert.ToInt32(objTempID);
            }
            else
            {
                strSQL = "insert into tbl_Company(CompName,Carrier,Addr1,Addr2,City,State,Zip,Phone,Fax)"
                         + " values("
                         + DB.GetSingleQuoteValue(interimCompany.CompName) + ",1"
                         + DB.GetCommaSingleQuoteValue(interimCompany.Addr1) + DB.GetCommaSingleQuoteValue(interimCompany.Addr2)
                         + DB.GetCommaSingleQuoteValue(interimCompany.City) + DB.GetCommaSingleQuoteValue(interimCompany.State)
                         + DB.GetCommaSingleQuoteValue(interimCompany.Zip) + DB.GetCommaSingleQuoteValue(interimCompany.Phone)
                         + DB.GetCommaSingleQuoteValue("")
                         + ")";
                //comm.CommandText = strSQL;
                //comm.ExecuteNonQuery();

                //intInterimCarrierCompID = HelperFuncs.GetLastAutogeneratedID(comm);

                intInterimCarrierCompID = HelperFuncs.ExecuteNonQuery_GetLastAutogeneratedID(
                    AppCodeConstants.connStringAesData, ref strSQL, "Dispatch GetInterimCarrierCompanyID");
            }

            return(intInterimCarrierCompID);
        }