Ejemplo n.º 1
0
/*****************************************************************************
 * データベースとの接続を閉じます。
 *****************************************************************************/
void DbSqlCeClient::close()
{
	if( m_pTran ){
		rollback_tran();
		// 中でNULL入れしてます。
	}

	if( m_IsOpened ){
		m_pDBinit->Uninitialize();
        m_IsOpened = false;
	}

	if( m_pCmdtext ){
		m_pCmdtext->Release();
		m_pCmdtext = NULL;
	}
	
	if( m_pCrtCmd ){
		m_pCrtCmd->Release();
		m_pCrtCmd = NULL;
	}

	if( m_pSession ){
		m_pSession->Release();
		m_pSession = NULL;
	}

	if( m_pDBinit ){
		m_pDBinit->Release();
		m_pDBinit = NULL;
	}
}
Ejemplo n.º 2
0
int
delete_rate_usage_or_db()
{
    int  i = 0, ret_code;

      dbcancel(dbproc1);
      if(begin_tran(dbproc1,"DELETE_RATE_USAGE_OVERRIDES") == FAILURE)
	      return(FAILURE);

      dbcmd(dbproc1," delete RATE_USAGE_BANDS_OVERRIDES ");
      dbfcmd(dbproc1," where seqnum = %s ",rate_usage_or_selected.seqnum);

      if(safe_dbupdate(dbproc1, "RATE_USAGE_BANDS_OVERRIDES",
            "delete_rate_usage_or_db"))
      {
	(void)rollback_tran(dbproc1, "delete_rate_usage_or_db");
	dbcancel(dbproc1);
        return(FAILURE);
      }

      dbcmd(dbproc1," delete RATE_USAGE_OVERRIDES ");
      dbfcmd(dbproc1, " where seqnum = %s ",rate_usage_or_selected.seqnum);

      if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
            "delete_rate_usage_or_db"))
      {
	(void)rollback_tran(dbproc1, "delete_rate_usage_or_db");
	dbcancel(dbproc1);
        return(FAILURE);
      }

   				    /* ************************ */
      (void)commit_tran(dbproc1);   /* ** COMMIT TRANSACTION ** */
				    /* ************************ */

      return(SUCCESS);
}
Ejemplo n.º 3
0
int
update_rate_usage_or_db(RATE_USAGE_OVERRIDES_STRUCT *rate_usage_or_entered, 
		     RATE_USAGE_BANDS_OVERRIDES_STRUCT *rate_usage_or_bands_entered,
		     int num_of_bands_entered,
		     int seqnum)
{
    int ret_code;
    char   fixed_charge_amt[19];
    int    i,unit_rate, add_fixed_amt;


    /* convert money string to money field in proper implied decimal place */

    money_str_to_arb_numeric(fixed_charge_amt,
       rate_usage_or_entered->fixed_charge_amt,
       (short)atoi(rate_usage_or_entered->currency_code));

    if(rate_str_to_int_new(&unit_rate,
       rate_usage_or_entered->add_unit_rate,
       (short)atoi(rate_usage_or_entered->currency_code),
       (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
    {
      sprintf(scratch, "Add. Unit Rate: %s would cause an integer overflow",
        rate_usage_or_entered->add_unit_rate);
      post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
               scratch);
      return FAILURE;
    }

    if(rate_str_to_int_new(&add_fixed_amt,
       rate_usage_or_entered->add_fixed_amt,
       (short)atoi(rate_usage_or_entered->currency_code),
       (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
    {
      sprintf(scratch, "Add. Fixed Amt: %s would cause an integer overflow",
        rate_usage_or_entered->add_fixed_amt);
      post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
               scratch);
      return FAILURE;
    }

    dbcancel(dbproc1);
    if(begin_tran(dbproc1,"UPDATE_RATE_USAGE_OVERRIDES") == FAILURE)
	    return(FAILURE);

    dbcmd(dbproc1," update RATE_USAGE_OVERRIDES ");
    dbfcmd(dbproc1," set corridor_plan_id = %d, ", 
      atoi(rate_usage_or_entered->corridor_plan_id));
    dbfcmd(dbproc1," rate_class = %d, ", 
      atoi(rate_usage_or_entered->rate_class));
    dbfcmd(dbproc1," jurisdiction = %d, ", 
      atoi(rate_usage_or_entered->jurisdiction));
    dbfcmd(dbproc1," rate_units_type = %d, ", 
      atoi(rate_usage_or_entered->rate_units_type));
    dbfcmd(dbproc1," type_id_usg = %d, ", 
      atoi(rate_usage_or_entered->type_id_usg));
    dbfcmd(dbproc1," distance_band_id = %d, ", 
      atoi(rate_usage_or_entered->distance_band_id));
    dbfcmd(dbproc1," bill_class = %d, ", 
      atoi(rate_usage_or_entered->bill_class));
    dbfcmd(dbproc1," element_id = %d, ", 
      atoi(rate_usage_or_entered->element_id));
    dbfcmd(dbproc1," equip_type_code = %d, ", 
      atoi(rate_usage_or_entered->equip_type));
    dbfcmd(dbproc1," equip_class_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class));
    dbfcmd(dbproc1," class_of_service_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class_of_service));
    dbfcmd(dbproc1," units_indicator = %d, ", 
      atoi(rate_usage_or_entered->units_indicator));
    dbfcmd(dbproc1," provider_class = %d, ", 
      atoi(rate_usage_or_entered->provider_class));
    dbfcmd(dbproc1," rate_period = '%s', ", 
      rate_usage_or_entered->rate_period);
    dbfcmd(dbproc1," currency_code = %d, ", 
      atoi(rate_usage_or_entered->currency_code));
    dbfcmd(dbproc1," fixed_charge_amt = %s, ", fixed_charge_amt);
    dbfcmd(dbproc1," incremental_bands = %s, ", 
      rate_usage_or_entered->incremental_bands);
    dbfcmd(dbproc1," add_unit_rate = %d, ", unit_rate);
    dbfcmd(dbproc1," add_fixed_amt = %d, ", add_fixed_amt);
    dbfcmd(dbproc1," add_implied_decimal = %d, ",
      atoi(rate_usage_or_entered->add_implied_decimal));
    dbfcmd(dbproc1," chg_dt = %s, ", arb_server_getdate());
    dbfcmd(dbproc1," chg_who = %s, ", arb_server_username());

    date_time_to_Arbdate(rate_usage_or_entered->active_dt,
      rate_usage_or_entered->active_time,
      &(rate_usage_or_entered->arb_active_dt));
    dbfcmd(dbproc1," active_dt = %t, ",
      &(rate_usage_or_entered->arb_active_dt));

    date_time_to_Arbdate(rate_usage_or_entered->inactive_dt,
      rate_usage_or_entered->inactive_time,
      &(rate_usage_or_entered->arb_inactive_dt));
    if(Arbdate_is_null(&(rate_usage_or_entered->arb_inactive_dt)))
      dbcmd(dbproc1," inactive_dt = NULL ");
    else
      dbfcmd(dbproc1," inactive_dt = %t ",
        &(rate_usage_or_entered->arb_inactive_dt));

    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }

    dbcmd(dbproc1," delete RATE_USAGE_BANDS_OVERRIDES ");
    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }
    
    for(i = 0; i < num_of_bands_entered; i++)
    {
      if(rate_str_to_int_new(&unit_rate,
         rate_usage_or_bands_entered[i].unit_rate,
         (short)atoi(rate_usage_or_entered->currency_code),
         (short)atoi(rate_usage_or_entered->add_implied_decimal)) == FAILURE)
      {
        (void)rollback_tran(dbproc1, "rate_usage_or_save_db");
        dbcancel(dbproc1);

        sprintf(scratch,
          "Band %d Unit Rate: %s would cause an integer overflow",
          i+1,
          rate_usage_or_bands_entered[i].unit_rate);
        post_dialog(rate_usage_or_shell,XmDIALOG_MESSAGE,
                  scratch);
        return FAILURE;
      }

      dbcmd(dbproc1,"insert into RATE_USAGE_BANDS_OVERRIDES(seqnum,rateband,");
      dbcmd(dbproc1,"num_units,unit_rate)");
      dbfcmd(dbproc1,"values(%d,%d,%s,%d)",
      seqnum, i + 1, rate_usage_or_bands_entered[i].num_units,unit_rate);

    
      if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
      {
        (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
         dbcancel(dbproc1);
        return(FAILURE);
      }
    }

   			          /* ************************ */
    (void)commit_tran(dbproc1);   /* ** COMMIT TRANSACTION ** */
				  /* ************************ */

    /* SUCCESS */
    return(SUCCESS);
}
Ejemplo n.º 4
0
int
update_rate_usage_or_db(RATE_USAGE_OVERRIDES_STRUCT *rate_usage_or_entered, 
		     RATE_USAGE_BANDS_OVERRIDES_STRUCT *rate_usage_or_bands_entered,
		     int num_of_bands_entered,
		     int seqnum)
{
    int ret_code;
    char   fixed_charge_amt[19];
    int    i,unit_rate, add_fixed_amt;

    /* convert dollars to cents */

    money_str_to_int_str(fixed_charge_amt,
      rate_usage_or_entered->fixed_charge_amt);
    unit_rate = (atof(rate_usage_or_entered->add_unit_rate) + 0.000005) * 100000;
    add_fixed_amt = (atof(rate_usage_or_entered->add_fixed_amt) + 0.000005) * 100000;

    dbcancel(dbproc1);
    if(begin_tran(dbproc1,"UPDATE_RATE_USAGE_OVERRIDES") == FAILURE)
	    return(FAILURE);

    dbcmd(dbproc1," update RATE_USAGE_OVERRIDES ");
    dbfcmd(dbproc1," set corridor_plan_id = %d, ", 
      atoi(rate_usage_or_entered->corridor_plan_id));
    dbfcmd(dbproc1," rate_class = %d, ", 
      atoi(rate_usage_or_entered->rate_class));
    dbfcmd(dbproc1," jurisdiction = %d, ", 
      atoi(rate_usage_or_entered->jurisdiction));
    dbfcmd(dbproc1," rate_units_type = %d, ", 
      atoi(rate_usage_or_entered->rate_units_type));
    dbfcmd(dbproc1," type_id_usg = %d, ", 
      atoi(rate_usage_or_entered->type_id_usg));
    dbfcmd(dbproc1," distance_band_id = %d, ", 
      atoi(rate_usage_or_entered->distance_band_id));
    dbfcmd(dbproc1," bill_class = %d, ", 
      atoi(rate_usage_or_entered->bill_class));
    dbfcmd(dbproc1," element_id = %d, ", 
      atoi(rate_usage_or_entered->element_id));
    dbfcmd(dbproc1," equip_type_code = %d, ", 
      atoi(rate_usage_or_entered->equip_type));
    dbfcmd(dbproc1," equip_class_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class));
    dbfcmd(dbproc1," class_of_service_code = %d, ", 
      atoi(rate_usage_or_entered->equip_class_of_service));
    dbfcmd(dbproc1," units_indicator = %d, ", 
      atoi(rate_usage_or_entered->units_indicator));
    dbfcmd(dbproc1," provider_class = %d, ", 
      atoi(rate_usage_or_entered->provider_class));
    dbfcmd(dbproc1," rate_period = '%s', ", 
      rate_usage_or_entered->rate_period);
    dbfcmd(dbproc1," currency_code = %d, ", 
      atoi(rate_usage_or_entered->currency_code));
    dbfcmd(dbproc1," fixed_charge_amt = %s, ", fixed_charge_amt);
    dbfcmd(dbproc1," incremental_bands = %s, ", 
      rate_usage_or_entered->incremental_bands);
    dbfcmd(dbproc1," add_unit_rate = %d, ", unit_rate);
    dbfcmd(dbproc1," add_fixed_amt = %d, ", add_fixed_amt);
    dbfcmd(dbproc1," chg_dt = %s, ", arb_server_getdate());
    dbfcmd(dbproc1," chg_who = %s, ", arb_server_username());

    date_time_to_Arbdate(rate_usage_or_entered->active_dt,
      rate_usage_or_entered->active_time,
      &(rate_usage_or_entered->arb_active_dt));
    dbfcmd(dbproc1," active_dt = %t, ",
      &(rate_usage_or_entered->arb_active_dt));

    date_time_to_Arbdate(rate_usage_or_entered->inactive_dt,
      rate_usage_or_entered->inactive_time,
      &(rate_usage_or_entered->arb_inactive_dt));
    if(Arbdate_is_null(&(rate_usage_or_entered->arb_inactive_dt)))
      dbcmd(dbproc1," inactive_dt is NULL ");
    else
      dbfcmd(dbproc1," inactive_dt = %t ",
        &(rate_usage_or_entered->arb_inactive_dt));

    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }

    dbcmd(dbproc1," delete RATE_USAGE_BANDS_OVERRIDES ");
    dbfcmd(dbproc1," where seqnum = %d ",seqnum);

    if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
    {
      (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
       dbcancel(dbproc1);
      return(FAILURE);
    }
    
    for(i = 0; i < num_of_bands_entered; i++)
    {
      unit_rate = (atof(rate_usage_or_bands_entered[i].unit_rate) + 0.000005) * 100000;
      dbcmd(dbproc1,"insert into RATE_USAGE_BANDS_OVERRIDES(seqnum,rateband,");
      dbcmd(dbproc1,"num_units,unit_rate)");
      dbfcmd(dbproc1,"values(%d,%d,%s,%d)",
      seqnum, i + 1, rate_usage_or_bands_entered[i].num_units,unit_rate);

    
      if(safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES",
			       "update_rate_usage_or_db"))
      {
        (void)rollback_tran(dbproc1, "update_rate_usage_or_db");
         dbcancel(dbproc1);
        return(FAILURE);
      }
    }

   			          /* ************************ */
    (void)commit_tran(dbproc1);   /* ** COMMIT TRANSACTION ** */
				  /* ************************ */

    /* SUCCESS */
    return(SUCCESS);
}
Ejemplo n.º 5
0
/*
************************************************************************
*  insert rate usage information 
************************************************************************
*/
int rate_usage_or_save_db(RATE_USAGE_OVERRIDES_STRUCT *rate_usage_or_entered,
		       RATE_USAGE_BANDS_OVERRIDES_STRUCT *rate_usage_or_bands_entered,
		       int num_of_bands_entered,
		       int next_seqnum)
{
   int    i,ret_code;
   char   fixed_charge_amt[19];
   int    unit_rate, add_fixed_amt;


     /* convert dollars to cents */

     money_str_to_int_str(fixed_charge_amt, 
       rate_usage_or_entered->fixed_charge_amt);
     unit_rate = (atof(rate_usage_or_entered->add_unit_rate) + 0.000005) * 100000;
     add_fixed_amt = (atof(rate_usage_or_entered->add_fixed_amt) + 0.000005) * 100000;
   /************************************************/
   /** Insert into RATE_USAGE_OVERRIDES                 **/
   /************************************************/
     
     dbcancel(dbproc1);
     if(begin_tran(dbproc1,"INSERT_RATE_USAGE_OVERRIDES") == FAILURE)
       return(FAILURE);

     dbcmd(dbproc1," insert into RATE_USAGE_OVERRIDES(seqnum, corridor_plan_id,");
     dbcmd(dbproc1," rate_class,jurisdiction, rate_units_type, ");
     dbcmd(dbproc1," type_id_usg, distance_band_id, ");
     dbcmd(dbproc1," bill_class,element_id,equip_type_code,equip_class_code, ");
     dbcmd(dbproc1," class_of_service_code,");
     dbcmd(dbproc1," units_indicator,provider_class,");
     dbcmd(dbproc1," rate_period, currency_code, fixed_charge_amt, ");
     dbcmd(dbproc1," incremental_bands, ");
     dbcmd(dbproc1," add_unit_rate,add_fixed_amt,active_dt,inactive_dt,");
     dbcmd(dbproc1," create_dt,chg_dt,chg_who)");
     dbcmd(dbproc1," values");
     dbfcmd(dbproc1,"(%d, %d,%d, %d,",
                      next_seqnum,
                      atoi(rate_usage_or_entered->corridor_plan_id),
                      atoi(rate_usage_or_entered->rate_class),
                      atoi(rate_usage_or_entered->jurisdiction));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->rate_units_type));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->type_id_usg));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->distance_band_id));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->bill_class));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->element_id));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->equip_type));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->equip_class));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->equip_class_of_service));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->units_indicator));
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->provider_class));
     dbfcmd(dbproc1,"'%s',",rate_usage_or_entered->rate_period);
     dbfcmd(dbproc1,"%d,",atoi(rate_usage_or_entered->currency_code));
     /* convert to cents */
     dbfcmd(dbproc1,"%s,",fixed_charge_amt);
     dbfcmd(dbproc1,"%s,",rate_usage_or_entered->incremental_bands);
     dbfcmd(dbproc1,"%d,",unit_rate);
     dbfcmd(dbproc1,"%d,",add_fixed_amt);
     date_time_to_Arbdate(rate_usage_or_entered->active_dt,
       rate_usage_or_entered->active_time,
       &(rate_usage_or_entered->arb_active_dt));
     dbfcmd(dbproc1,"%t,",
       &(rate_usage_or_entered->arb_active_dt));

     date_time_to_Arbdate(rate_usage_or_entered->inactive_dt,
       rate_usage_or_entered->inactive_time,
       &(rate_usage_or_entered->arb_inactive_dt));
     if(Arbdate_is_null(&(rate_usage_or_entered->arb_inactive_dt)))
       dbfcmd(dbproc1,"NULL,");
     else
       dbfcmd(dbproc1,"%t,",
         &(rate_usage_or_entered->arb_inactive_dt));

     dbfcmd(dbproc1,"%s,%s,%s)",
       arb_server_getdate(),
       arb_server_getdate(),
       arb_server_username());

     for(i = 0; i < num_of_bands_entered; i++)
     {
       unit_rate = (atof(rate_usage_or_bands_entered[i].unit_rate) + 0.000005) * 100000;
       dbcmd(dbproc1,"insert into RATE_USAGE_BANDS_OVERRIDES(seqnum,rateband,");
       dbcmd(dbproc1,"num_units,unit_rate)");
       dbfcmd(dbproc1,"values(%d,%d,%s,%d)",
	 next_seqnum, i + 1, rate_usage_or_bands_entered[i].num_units,unit_rate);
     }


     if (safe_dbupdate(dbproc1, "RATE_USAGE_OVERRIDES", "rate_usage_or_save_db")) 
     {
	 (void)rollback_tran(dbproc1, "rate_usage_or_save_db");
	 dbcancel(dbproc1);
	 return(FAILURE);
     }

                                   /* ************************ */
     (void)commit_tran(dbproc1);   /* ** COMMIT TRANSACTION ** */
 				   /* ************************ */

   return(SUCCESS);
}