// Call the GISPKG_CCB_ESILOCATION.ValidateESILocation stored procedure to validate // if the ESI Location is being used by a Premise record on a different Service Point. private bool ValidateDuplicate(string esiLocation, int g3eFID) { bool returnValue = true; try { ADODB.Command cmd = new ADODB.Command(); cmd.CommandText = "{call GISPKG_CCB_ESILOCATION.ValidateESILocation(?,?,?,?,?)}"; cmd.CommandType = CommandTypeEnum.adCmdText; ADODB.Parameter param = cmd.CreateParameter("ESILocation", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 10, esiLocation); cmd.Parameters.Append(param); param = cmd.CreateParameter("G3EFID", DataTypeEnum.adBigInt, ParameterDirectionEnum.adParamInput, 10, g3eFID); cmd.Parameters.Append(param); param = cmd.CreateParameter("ExistingFID", DataTypeEnum.adBigInt, ParameterDirectionEnum.adParamOutput, 10); cmd.Parameters.Append(param); param = cmd.CreateParameter("JobID", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamOutput, 30); cmd.Parameters.Append(param); param = cmd.CreateParameter("Status", DataTypeEnum.adSingle, ParameterDirectionEnum.adParamOutput, 1); cmd.Parameters.Append(param); int recordsAffected = 0; Recordset spRS = m_DataContext.ExecuteCommand(cmd, out recordsAffected); if (!Convert.ToBoolean(cmd.Parameters["Status"].Value)) { string job = string.Empty; if (cmd.Parameters["JobID"].Value.ToString().Length > 0) { job = " in Job " + cmd.Parameters["JobID"].Value; } if (m_InteractiveMode) { MessageBox.Show(ERROR_DUPLICATE_ESILOCATION + cmd.Parameters["ExistingFID"].Value + job, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } returnValue = false; } } catch (Exception ex) { if (m_InteractiveMode) { MessageBox.Show("Error in fiESILocationUpdate:ValidateDuplicate - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } returnValue = false; } return(returnValue); }
/// <summary> /// Inserts a record into the DEIS_TRANSACTION table. /// </summary> /// <returns>Boolean indicating status</returns> private bool InsertTransaction() { bool returnValue = false; try { ADODB.Command cmd = new ADODB.Command(); cmd.CommandText = "insert into deis_transaction (tran_code,tran_date,bank_fln,wr_no,serv_area,yard,user_id,conn_sec,existing_bank,wiring_config_code," + "locn,ins_trf1_company_no,ins_trf1_tsn,ins_trf1_kva_size,ins_trf1_phs_code,ins_trf1_type_code,ins_trf1_mount_code,ins_trf1_kind_code," + "ins_trf1_pri_volt_code,ins_trf1_sec_volt_code,ins_trf2_company_no,ins_trf2_tsn,ins_trf2_kva_size,ins_trf2_phs_code,ins_trf2_type_code," + "ins_trf2_mount_code,ins_trf2_kind_code,ins_trf2_pri_volt_code,ins_trf2_sec_volt_code,ins_trf3_company_no,ins_trf3_tsn,ins_trf3_kva_size," + "ins_trf3_phs_code,ins_trf3_type_code,ins_trf3_mount_code,ins_trf3_kind_code,ins_trf3_pri_volt_code,ins_trf3_sec_volt_code,rem_trf1_company_no," + "rem_trf1_tsn,rem_trf1_kva_size,rem_trf1_phs_code,rem_trf1_type_code,rem_trf1_mount_code,rem_trf1_kind_code,rem_trf1_pri_volt_code," + "rem_trf1_sec_volt_code,rem_trf2_company_no,rem_trf2_tsn,rem_trf2_kva_size,rem_trf2_phs_code,rem_trf2_type_code,rem_trf2_mount_code," + "rem_trf2_kind_code,rem_trf2_pri_volt_code,rem_trf2_sec_volt_code,rem_trf3_company_no,rem_trf3_tsn,rem_trf3_kva_size,rem_trf3_phs_code," + "rem_trf3_type_code,rem_trf3_mount_code,rem_trf3_kind_code,rem_trf3_pri_volt_code,rem_trf3_sec_volt_code) " + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) " + "returning tran_no into ?"; cmd.CommandType = CommandTypeEnum.adCmdText; // Input parameters ADODB.Parameter param = cmd.CreateParameter("TranCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 1, TransactionDEIS.TransactionCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("TranDate", DataTypeEnum.adDate, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.TransactionDate.Replace('T', ' ')); cmd.Parameters.Append(param); param = cmd.CreateParameter("BankFLN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.BankFLN); cmd.Parameters.Append(param); param = cmd.CreateParameter("WrNo", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.WrNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("ServArea", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.ServiceArea); cmd.Parameters.Append(param); param = cmd.CreateParameter("Yard", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.Yard); cmd.Parameters.Append(param); param = cmd.CreateParameter("UserID", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.UserID); cmd.Parameters.Append(param); param = cmd.CreateParameter("SecConn", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.SecondaryConnection); cmd.Parameters.Append(param); param = cmd.CreateParameter("ExistingBank", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.ExistingBank); cmd.Parameters.Append(param); param = cmd.CreateParameter("WiringConfigCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.WiringConfigCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("Location", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.Location); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.InsTrf1KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf1SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf1SecVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.InsTrf2KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf2SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf2SecVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.InsTrf3KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("InsTrf3SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.InsTrf3SecVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.RemTrf1KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf1SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf1SecVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.RemTrf2KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf2SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf2SecVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3CompanyNumber", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3CompanyNumber); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3TSN", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3TSN); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3KvaSize", DataTypeEnum.adDouble, ParameterDirectionEnum.adParamInput, 10, TransactionDEIS.RemTrf3KvaSize); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3PhaseCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3PhaseCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3TypeCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3TypeCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3MountCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3MountCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3KindCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3KindCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3PriVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3PriVoltCode); cmd.Parameters.Append(param); param = cmd.CreateParameter("RemTrf3SecVoltCode", DataTypeEnum.adVarChar, ParameterDirectionEnum.adParamInput, 30, TransactionDEIS.RemTrf3SecVoltCode); cmd.Parameters.Append(param); // Output parameter param = cmd.CreateParameter("TranNo", DataTypeEnum.adBigInt, ParameterDirectionEnum.adParamOutput, 10); cmd.Parameters.Append(param); int recordsAffected = 0; Recordset spRS = m_Application.DataContext.ExecuteCommand(cmd, out recordsAffected); m_Application.DataContext.Execute("commit", out recordsAffected, (int)CommandTypeEnum.adCmdText); if (!Convert.IsDBNull(cmd.Parameters["TranNo"].Value)) { TransactionDEIS.TransactionNumber = Convert.ToInt32(cmd.Parameters["TranNo"].Value); } returnValue = true; } catch (Exception ex) { TransactionDEIS.TransactionMessage = "FAILED - Error inserting record into " + TransactionDEIS.TABLE_DEIS_TRANSACTION + ": " + ex.Message; returnValue = false; } return(returnValue); }
private void PrepareParameters() { // Prepare parameters SQLParameter parameter; for (int index = 0; index < _parameterIndexes.Length; index++) { parameter = Parameters[_parameterIndexes[index]]; ADODB.Parameter aDOParameter = _command.CreateParameter(parameter.Name, ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, 0, Missing.Value); switch (parameter.Direction) { case SQLDirection.In: aDOParameter.Direction = ADODB.ParameterDirectionEnum.adParamInput; break; case SQLDirection.Out: aDOParameter.Direction = ADODB.ParameterDirectionEnum.adParamOutput; break; case SQLDirection.InOut: aDOParameter.Direction = ADODB.ParameterDirectionEnum.adParamInputOutput; break; case SQLDirection.Result: aDOParameter.Direction = ADODB.ParameterDirectionEnum.adParamReturnValue; break; default: aDOParameter.Direction = ADODB.ParameterDirectionEnum.adParamUnknown; break; } if (parameter.Type is SQLStringType) { aDOParameter.Type = ADODB.DataTypeEnum.adVarChar; aDOParameter.Size = ((SQLStringType)parameter.Type).Length; } else if (parameter.Type is SQLBooleanType) { aDOParameter.Type = ADODB.DataTypeEnum.adBoolean; } else if (parameter.Type is SQLIntegerType) { switch (((SQLIntegerType)parameter.Type).ByteCount) { case 1: aDOParameter.Type = ADODB.DataTypeEnum.adTinyInt; break; case 2: aDOParameter.Type = ADODB.DataTypeEnum.adSmallInt; break; case 8: aDOParameter.Type = ADODB.DataTypeEnum.adBigInt; break; default: aDOParameter.Type = ADODB.DataTypeEnum.adInteger; break; } } else if (parameter.Type is SQLNumericType) { SQLNumericType type = (SQLNumericType)parameter.Type; aDOParameter.Type = ADODB.DataTypeEnum.adNumeric; aDOParameter.NumericScale = type.Scale; aDOParameter.Precision = type.Precision; } else if (parameter.Type is SQLFloatType) { SQLFloatType type = (SQLFloatType)parameter.Type; if (type.Width == 1) { aDOParameter.Type = ADODB.DataTypeEnum.adSingle; } else { aDOParameter.Type = ADODB.DataTypeEnum.adDouble; } } else if (parameter.Type is SQLBinaryType) { aDOParameter.Type = ADODB.DataTypeEnum.adLongVarBinary; aDOParameter.Attributes |= (int)ADODB.ParameterAttributesEnum.adParamLong; aDOParameter.Size = 255; } else if (parameter.Type is SQLByteArrayType) { aDOParameter.Type = ADODB.DataTypeEnum.adBinary; aDOParameter.Size = ((SQLByteArrayType)parameter.Type).Length; } else if (parameter.Type is SQLTextType) { aDOParameter.Type = ADODB.DataTypeEnum.adLongVarChar; aDOParameter.Size = 255; } else if (parameter.Type is SQLDateTimeType) { aDOParameter.Type = ADODB.DataTypeEnum.adDBTimeStamp; } else if (parameter.Type is SQLDateType) { aDOParameter.Type = ADODB.DataTypeEnum.adDBDate; } else if (parameter.Type is SQLTimeType) { aDOParameter.Type = ADODB.DataTypeEnum.adDBTime; } else if (parameter.Type is SQLGuidType) { aDOParameter.Type = ADODB.DataTypeEnum.adChar; aDOParameter.Size = 38; //LADOParameter.Type = ADODB.DataTypeEnum.adGUID; } else if (parameter.Type is SQLMoneyType) { aDOParameter.Type = ADODB.DataTypeEnum.adCurrency; } else { throw new ConnectionException(ConnectionException.Codes.UnknownSQLDataType, parameter.Type.GetType().Name); } _command.Parameters.Append(aDOParameter); } }