亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

在更新模塊中,如何不需要更新的字段,該如何處理

在更新模塊中,如何不需要更新的字段,該如何處理

正在回答

3 回答

/*
			?*?功能5:更新女神信息
			?*/
			else?if(OPERATION_UPDATE.equals(input.toUpperCase())
					||OPERATION_UPDATE.substring(0,1).equals(input.toUpperCase())
					||OPERATION_UPDATE.equals(previous)){
				previous=OPERATION_UPDATE;
				if(step==1){
					System.out.println("請輸入要更新的女神編號");
				}
				
				if(step==2){
					Integer?id=null;
					//第一個try是防止用戶輸入非數字id
					try?{
						id=Integer.valueOf(input);
						goddess=action.get(id);
						if(goddess==null){
							System.out.println("查詢女信息失敗,請輸入正確的女神id");
							step=1;
						}
						else{
							System.out.println("姓名(如果不更新該字段,請輸入null):");
						}
					}?catch?(Exception?e)?{
						System.out.println("請輸入正確的女神id");
						step=1;
					}
				}
				
				if(step==3){
					if(!input.equals("null")){
						goddess.setUser_name(input);
					}
					System.out.println("年齡:");
				}
				//輸入年齡,提示輸入生日
				if(step==4){
						Integer?age=null;
						try?{
							if(!input.equals("null")){
							age=Integer.valueOf(input);
							goddess.setAge(age);
							}
							System.out.println("生日?,格式:yyyy-MM-dd");
						}?catch?(Exception?e)?{
							System.out.println("請輸入正確的女神年齡:");
							step=3;
						}
				}
				//輸入生日
				if(step==5){
						SimpleDateFormat?sdf=new?SimpleDateFormat("yyyy-MM-dd");
						Date?birthday=null;
						try?{
							if(!input.equals("null")){
							birthday?=?sdf.parse(input);
							goddess.setBirthday(birthday);
							}
							System.out.println("郵箱:");
						}?catch?(ParseException?e)?{
							System.out.println("您輸入的格式有誤,請重新輸入");
							step=4;
						}
				}
				
				if(step==6){
					if(!input.equals("null")){
						goddess.setEmail(input);
					}
					System.out.println("手機號:");
				}
				if(step==7){
					if(!input.equals("null")){
						goddess.setMobile(input);
					}
					try?{
						action.edit(goddess);
						System.out.println("女神信息更新成功");
					}?catch?(Exception?e)?{
						System.out.println("女神信息更新失敗");
					}
					step=1;
					previous=null;
				}
				if(OPERATION_UPDATE.equals(previous)){
					step++;
				}


1 回復 有任何疑惑可以回復我~

/*

* 功能5:更新女神信息

*/

else if(OPERATION_UPDATE.equals(input.toUpperCase())

||OPERATION_UPDATE.substring(0,1).equals(input.toUpperCase())

||OPERATION_UPDATE.equals(previous)){

previous=OPERATION_UPDATE;

if(step==1){

System.out.println("請輸入要更新的女神編號");

}

if(step==2){

Integer id=null;

//第一個try是防止用戶輸入非數字id

try {

id=Integer.valueOf(input);

goddess=action.get(id);

if(goddess==null){

System.out.println("查詢女信息失敗,請輸入正確的女神id");

step=1;

}

else{

System.out.println("姓名(如果不更新該字段,請輸入null):");

}

} catch (Exception e) {

System.out.println("請輸入正確的女神id");

step=1;

}

}

if(step==3){

if(!input.equals("null")){

goddess.setUser_name(input);

}

System.out.println("年齡:");

}

//輸入年齡,提示輸入生日

if(step==4){

Integer age=null;

try {

if(!input.equals("null")){

age=Integer.valueOf(input);

goddess.setAge(age);

}

System.out.println("生日 ,格式:yyyy-MM-dd");

} catch (Exception e) {

System.out.println("請輸入正確的女神年齡:");

step=3;

}

}

//輸入生日

if(step==5){

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

Date birthday=null;

try {

if(!input.equals("null")){

birthday = sdf.parse(input);

goddess.setBirthday(birthday);

}

System.out.println("郵箱:");

} catch (ParseException e) {

System.out.println("您輸入的格式有誤,請重新輸入");

step=4;

}

}

if(step==6){

if(!input.equals("null")){

goddess.setEmail(input);

}

System.out.println("手機號:");

}

if(step==7){

if(!input.equals("null")){

goddess.setMobile(input);

}

try {

action.edit(goddess);

System.out.println("女神信息更新成功");

} catch (Exception e) {

System.out.println("女神信息更新失敗");

}

step=1;

previous=null;

}

if(OPERATION_UPDATE.equals(previous)){

step++;

}


0 回復 有任何疑惑可以回復我~

通過將數據庫中對應id?的數據取出來,賦值給不需要更新的字段

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

在更新模塊中,如何不需要更新的字段,該如何處理

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號