1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
public class CashFlow extends Activity implements OnItemSelectedListener 
{ 

Spinner cash_month_select;
  String[] month = {"January","February","March","April","May","June","July","August","September","October","November","December"};
public void onCreate(Bundle bundle)
  {
    super.onCreate(bundle);
    setContentView(R.layout.cash);

cash_month_select = (Spinner)findViewById(R.id.cash_month_spinner);
    cash_month_select.setAdapter(new MyAdapter(CashFlow.this, R.layout.spinner, month));
    cash_month_select.setOnItemSelectedListener(CashFlow .this);

try 
          {
        sampleDB =  CashFlow.this.openOrCreateDatabase(SAMPLE_DB_NAME, MODE_PRIVATE, null);
        sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " + SAMPLE_CASH_TABLE_NAME1 + " (Month VARCHAR(20),Net_Income_month int(15),Net_Income_YTD int(15));");
        sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " + SAMPLE_CASH_TABLE_NAME2 + " (Label VARCHAR(20),Month_Value int(15),YTD_Value int(15));");
    
        cash_flow_operate_cr = sampleDB.rawQuery("SELECT * FROM " + SAMPLE_CASH_TABLE_NAME1 , null);
        int start_count = cash_flow_operate_cr.getCount();
        if(start_count==0)
          
        {
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('January',-1315754,-7815025);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('February',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('March',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('April',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('May',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('June',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('July',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('August',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('September',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('October',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('November',null,null);");
          sampleDB.execSQL("INSERT INTO " + SAMPLE_CASH_TABLE_NAME1 + " Values ('December',null,null);");
          }
 cash_flow_operate_cr = sampleDB.rawQuery("SELECT * FROM " + SAMPLE_CASH_TABLE_NAME1 , null);
           int operate_Column1 = cash_flow_operate_cr.getColumnIndex("Month");
           int operate_Column2 = cash_flow_operate_cr.getColumnIndex("Net_Income_month");
           int operate_Column3 = cash_flow_operate_cr.getColumnIndex("Net_Income_YTD");
           int cash_flow_operate_columncount=cash_flow_operate_cr.getCount();
           operate_month = new String[cash_flow_operate_columncount];
           operate_net_income_month = new int[cash_flow_operate_columncount];
           operate_net_income_YTD = new int[cash_flow_operate_columncount];
           if (cash_flow_operate_cr.moveToFirst())
            { 
             for (int i = 0; i < cash_flow_operate_columncount; i++)
                {
               operate_month[i] = cash_flow_operate_cr.getString(operate_Column1);
               operate_net_income_month[i] = cash_flow_operate_cr.getInt(operate_Column2);
               operate_net_income_YTD[i] = cash_flow_operate_cr.getInt(operate_Column3);
               Log.i("month & ","value... from data base..."+operate_month[i]+operate_net_income_month[i]+operate_net_income_YTD[i]);
               cash_flow_operate_cr.moveToNext();
                }
            }


 







}
@Override
  public void onItemSelected(AdapterView<?> parent, View v, int position,long id)
  {
    
      spinner_value =  parent.getSelectedItem().toString();
    Log.i("spinner_value", ".."+spinner_value);
    
    
    
    if(parent.getItemAtPosition(position).equals("January"))
    {
      
       Log.i("january values..............","");
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'January' " + " , Net_Income_month = -1315754 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ spinner_value +"';");
     
    }
    else if(parent.getItemAtPosition(position).equals("February"))
    {
     
      Log.i("values upadated for febuary...","");
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'February' " + " , Net_Income_month = 800000 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ spinner_value +"';");
      
      
    }
    else if(parent.getItemAtPosition(position).equals("March"))
    {
      
      Log.i("values upadated for March...","");
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'March' " + " , Net_Income_month = -789452 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ spinner_value +"';");
      
      
    }
    else if(parent.getItemAtPosition(position).equals("April"))
    {
     
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'April' " + " , Net_Income_month = 240000 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ month[spinner_value] +"';");
      
    }
    else if(parent.getItemAtPosition(position).equals("May"))
    {
     
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'May' " + " , Net_Income_month = -526302 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for May...","");
     
    }
    else if(parent.getItemAtPosition(position).equals("June"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'June' " + " , Net_Income_month = -263151 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for June...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("July"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'July' " + " , Net_Income_month = -912028 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for July...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("August"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'August' " + " , Net_Income_month = -1184179 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for August...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("September"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'September' " + " , Net_Income_month = -789452 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for September...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("October"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'October' " + " , Net_Income_month = -1157864 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for October...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("November"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'November' " + " , Net_Income_month = -1026288 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for November...","");
      
    }
    else if(parent.getItemAtPosition(position).equals("December"))
    {
      
      sampleDB.execSQL("UPDATE "+ SAMPLE_CASH_TABLE_NAME1 +" SET Month = 'December' " + " , Net_Income_month = -881555 " + " , Net_Income_YTD = -7815025 " + " WHERE Month= '"+ operate_month[mth] +"';");
      Log.i("values upadated for December...","");
     
    }
    
    
  }

  @Override
  public void onNothingSelected(AdapterView<?> arg0) 
  {
    
    
  }
  }