protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("home.aspx"); } else { string uid = Session["id"].ToString(); Session["id"] = uid; bool check_db = false; SqlDataSource sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); DataView ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count > 0) { check_db = true; } if (check_db) { string uisid = ict_f.Table.Rows[0]["id"].ToString(); string bank_name = bank_name_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_name_detail = bank_name_detail_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_number = bank_number_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_person = bank_person_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); int bank_type = 0, bank_type_detail = 0; bool check_type0_Image = false, check_type1_Image = false, check_type2_Image = false , check_bank_type = false, check_bank_type_detail = false, check_bank_name = false, check_bank_name_detail = false , check_bank_number = false, check_bank_person = false; if (type0_Image.ImageUrl.ToString() != "") { check_type0_Image = true; image_Label.Text = ""; } else { image_Label.Text = "This image not upload."; } if (type1_Image.ImageUrl.ToString() != "") { check_type1_Image = true; image_Label0.Text = ""; } else { image_Label0.Text = "This image not upload."; } if (type2_Image.ImageUrl.ToString() != "") { check_type2_Image = true; image_Label1.Text = ""; } else { image_Label1.Text = "This image not upload."; } //if (bank_type_RadioButtonList.SelectedIndex > -1) //{ // bank_type = bank_type_RadioButtonList.SelectedIndex; // check_bank_type = true; // bank_type_Label.Text = ""; //} //else //{ // bank_type_Label.Text = "Bank type no select."; //} //if (bank_type_detail_RadioButtonList.SelectedIndex > -1) //{ // bank_type_detail = bank_type_detail_RadioButtonList.SelectedIndex; // check_bank_type_detail = true; // bank_type_detail_Label.Text = ""; //} //else //{ // bank_type_detail_Label.Text = "Bank type detail no select."; //} //if (bank_name != "") //{ // check_bank_name = true; // bank_name_Label.Text = ""; //} //else //{ // bank_name_Label.Text = "Bank name have special word or not write."; //} //if (bank_name_detail != "") //{ // check_bank_name_detail = true; // bank_name_detail_Label.Text = ""; //} //else //{ // bank_name_detail_Label.Text = "Bank name detail have special word or not write."; //} //if (bank_number != "") //{ // try // { // int number = Convert.ToInt32(bank_number); // check_bank_number = true; // bank_number_Label.Text = ""; // } // catch (Exception ex) // { // bank_number_Label.Text = "Bank number is not number."; // return; // throw ex; // } //} //else //{ // bank_number_Label.Text = "Bank number have special word or not write."; //} //if (bank_person != "") //{ // check_bank_person = true; // bank_person_Label.Text = ""; //} //else //{ // bank_person_Label.Text = "Bank person have special word or not write."; //} //if (check_type0_Image && check_type1_Image && check_type2_Image && check_bank_person && // check_bank_number && check_bank_name_detail && check_bank_name && check_bank_type_detail && // check_bank_type) if (check_type0_Image && check_type1_Image && check_type2_Image) { //SqlDataSource sql_update = new SqlDataSource(); //sql_update.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; //sql_update.UpdateCommand = "update user_information_store"; //sql_update.UpdateCommand += " set bank_type='" + bank_type + "',bank_type_detail='" + bank_type_detail + "',bank_name='" + bank_name + "'"; //sql_update.UpdateCommand += ",bank_name_detail='" + bank_name_detail + "',bank_number='" + bank_number + "',bank_person='" + bank_person + "'"; //sql_update.UpdateCommand += " where id='" + uisid + "';"; //sql_update.Update(); sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store_important_image"; sql_f.SelectCommand += " where uisid='" + uisid + "';"; sql_f.DataBind(); ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count == 0) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store_important_image(uisid,type,filename)"; sql_insert.InsertCommand += " values('" + uisid + "','0','" + type0_Image.ImageUrl.ToString() + "');"; sql_insert.Insert(); sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store_important_image(uisid,type,filename)"; sql_insert.InsertCommand += " values('" + uisid + "','1','" + type1_Image.ImageUrl.ToString() + "');"; sql_insert.Insert(); sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store_important_image(uisid,type,filename)"; sql_insert.InsertCommand += " values('" + uisid + "','2','" + type2_Image.ImageUrl.ToString() + "');"; sql_insert.Insert(); bank_name_TextBox.Text = ""; bank_name_detail_TextBox.Text = ""; bank_number_TextBox.Text = ""; bank_person_TextBox.Text = ""; type0_Image.ImageUrl = ""; type1_Image.ImageUrl = ""; type2_Image.ImageUrl = ""; bank_type_detail_RadioButtonList.SelectedIndex = -1; bank_type_RadioButtonList.SelectedIndex = -1; result_Label.Text = "Success registered."; Response.Redirect("registered_1_3.aspx"); } } else { result_Label.Text = "登録に失敗しました。"; } } else { result_Label.Text = "登録に失敗しました。"; } } }
protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("main.aspx"); } else { string uid = Session["id"].ToString(); Session["id"] = uid; bool check_db = false; SqlDataSource sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); DataView ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count > 0) { check_db = true; } if (check_db) { string uisid = ict_f.Table.Rows[0]["id"].ToString(); int use_rule = 0, video_rule = 0; if (use_rule_CheckBox.Checked) { use_rule = 1; use_rule_Label.Text = ""; } else { use_rule = 0; use_rule_Label.Text = "Use rule have not select."; } if (use_rule_CheckBox.Checked) { SqlDataSource sql_update = new SqlDataSource(); sql_update.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_update.UpdateCommand = "update user_information_store"; sql_update.UpdateCommand += " set use_rule='" + use_rule + "',video_rule='" + video_rule + "'"; sql_update.UpdateCommand += " where id='" + uisid + "';"; sql_update.Update(); result_Label.Text = "Success registered."; Response.Redirect("main.aspx"); } else { result_Label.Text = "登録に失敗しました。"; } } else { result_Label.Text = "登録に失敗しました。"; } } }
protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("main.aspx"); } else { string uid = Session["id"].ToString(); string real_first_name = real_first_name_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string real_second_name = real_second_name_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string real_spell_first_name = real_spell_first_name_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string real_spell_second_name = real_spell_second_name_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); bool check_Sex_radio = false; string Sex = ""; if (Sex_radio.SelectedIndex > -1) { check_Sex_radio = true; Sex = Sex_radio.SelectedValue; sex_Label.Text = ""; } else { check_Sex_radio = false; Sex = ""; sex_Label.Text = "性別を選択してください。"; } string birth_year = ddlYear.SelectedValue; string birth_mon = ddlMonth.SelectedValue; string birth_day = ddlDay.SelectedValue; string work_state = work_DropDownList.SelectedValue; string postal_code = postal_code_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string country = City_DropDownList.SelectedValue; string city = add_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string chome = add_TextBox1.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string house_number = apartment_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string station_line = train_line_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string station_name = train_station_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string phone_number = phone_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string other_phone_number = other_phone_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string relationship = relationship_DropDownList.SelectedValue; bool check_real_first_name = false, check_real_second_name = false, check_real_spell_first_name = false , check_real_spell_second_name = false, check_postal_code = false , check_city = false, check_chome = false, check_phone_number = false; if (real_first_name != "") { check_real_first_name = true; rfname_Label.Text = ""; } else { check_real_first_name = false; rfname_Label.Text = "姓を入力してください"; } if (real_second_name != "") { check_real_second_name = true; rsname_Label.Text = ""; } else { check_real_second_name = false; rsname_Label.Text = "名を入力してください。"; } if (real_spell_first_name != "") { check_real_spell_first_name = true; rsfname_Label.Text = ""; } else { check_real_spell_first_name = false; rsfname_Label.Text = "姓の読みをカタカナで入力してください。"; } if (real_spell_second_name != "") { check_real_spell_second_name = true; rssname_Label.Text = ""; } else { check_real_spell_second_name = false; rssname_Label.Text = "名の読みをカタカナで入力してください。"; } if (postal_code != "") { check_postal_code = true; poc_Label.Text = ""; } else { check_postal_code = false; poc_Label.Text = "郵便番号をハイフンをつけて入力してください。"; } if (city != "") { check_city = true; city_Label.Text = ""; } else { check_city = false; city_Label.Text = "市区町村を入力してください"; } if (chome != "") { check_chome = true; chome_Label.Text = ""; } else { check_chome = false; chome_Label.Text = "番地を入力してください。"; } if (phone_number != "") { check_phone_number = true; phone_Label.Text = ""; } else { check_phone_number = false; phone_Label.Text = "電話番号を入力してください"; } if (check_Sex_radio && check_real_first_name && check_real_second_name && check_real_spell_first_name && check_real_spell_second_name && check_postal_code && check_city && check_chome && check_phone_number) { bool check_db = true; Query = "select uid from user_information"; Query += " where uid='" + uid + "';"; DataView ict_f = gc.select_cmd(Query); if (ict_f.Count > 0) { check_db = false; } if (check_db) { Query = "insert into user_information(uid,real_first_name,real_second_name,real_spell_first_name,real_spell_second_name"; Query += ",Sex,birthday_year,birthday_month,birthday_day,live_postal_code,country,city,Chome,phone_number,work_state,relationship"; if (house_number != "") { Query += ",house_number"; } if (station_line != "") { Query += ",station_line"; } if (station_name != "") { Query += ",station_name"; } if (other_phone_number != "") { Query += ",other_phone_number"; } Query += ") values('" + uid + "','" + real_first_name + "','" + real_second_name + "','" + real_spell_first_name + "'"; Query += ",'" + real_spell_second_name + "','" + Sex + "','" + birth_year + "','" + birth_mon + "'"; Query += ",'" + birth_day + "','" + postal_code + "','" + country + "','" + city + "'"; Query += ",'" + chome + "','" + phone_number + "','" + work_state + "','" + relationship + "'"; if (house_number != "") { Query += ",'" + house_number + "'"; } if (station_line != "") { Query += ",'" + station_line + "'"; } if (station_name != "") { Query += ",'" + station_name + "'"; } if (other_phone_number != "") { Query += ",'" + other_phone_number + "'"; } Query += ")"; resin = gc.insert_cmd(Query); Session["id"] = uid; real_first_name_TextBox.Text = ""; real_second_name_TextBox.Text = ""; real_spell_first_name_TextBox.Text = ""; real_spell_second_name_TextBox.Text = ""; Sex_radio.SelectedIndex = -1; this.PopulateYear(); this.PopulateMonth(); this.PopulateDay(); work_DropDownList.SelectedIndex = 0; postal_code_TextBox.Text = ""; City_DropDownList.Items.FindByValue("神奈川県").Selected = true; City_DropDownList.Items.FindByText("神奈川県").Selected = true; add_TextBox.Text = ""; add_TextBox1.Text = ""; apartment_TextBox.Text = ""; train_line_TextBox.Text = ""; train_station_TextBox.Text = ""; phone_TextBox.Text = ""; other_phone_TextBox.Text = ""; relationship_DropDownList.SelectedIndex = 0; result_Label.Text = "Success registered."; Response.Redirect("registered_1.aspx"); } else { result_Label.Text = "登録に失敗しました。"; } } else { result_Label.Text = "登録に失敗しました。"; } //Page.ClientScript.RegisterStartupScript(GetType(), Button2.ID, "save();", true); //ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('" + birth_year + "," + birth_mon + "," + birth_day + "')", true); //ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('" + Sex_radio.SelectedIndex + "')", true); //Page.ClientScript.RegisterStartupScript(GetType(), Button2.ID, "save();", true); //Response.Redirect("registered_1.aspx"); } }
protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("home.aspx"); } else { string uid = Session["id"].ToString(); List <int> selected = new List <int>(); foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { selected.Add(1); } else { selected.Add(0); } } foreach (ListItem item in CheckBoxList2.Items) { if (item.Selected) { selected.Add(1); } else { selected.Add(0); } } foreach (ListItem item in CheckBoxList3.Items) { if (item.Selected) { selected.Add(1); } else { selected.Add(0); } } foreach (ListItem item in CheckBoxList4.Items) { if (item.Selected) { selected.Add(1); } else { selected.Add(0); } } if (CheckBox1.Checked) { selected.Add(1); } else { selected.Add(0); } string howmany = howmany_DropDownList.SelectedValue; string age_range_start_year = age_range_start_year_DropDownList.SelectedValue; string age_range_start_month = age_range_start_month_DropDownList.SelectedValue; string age_range_end_year = age_range_end_year_DropDownList.SelectedValue; string age_range_end_month = age_range_end_month_DropDownList.SelectedValue; string baby_rule = baby_rule_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim().Replace(System.Environment.NewLine, "<br/>"); string baby_notice = baby_notice_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim().Replace(System.Environment.NewLine, "<br/>"); int money = 0; try { money = Convert.ToInt32(money_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim()); } catch (Exception ex) { money_Label.Text = "整数を入力してください."; return; throw ex; } bool check_db = true; SqlDataSource sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select uid from user_information_store"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); DataView ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count > 0) { check_db = false; } if (check_db) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store(uid,choice1_1,choice1_2,choice1_3,choice1_4,choice2_1,choice2_2,choice2_3,choice2_4"; sql_insert.InsertCommand += ",choice2_5,choice2_6,choice3_1,choice3_2,choice3_3,choice3_4,choice3_5,howmany"; sql_insert.InsertCommand += ",age_range_start_year,age_range_start_month,age_range_end_year,age_range_end_month,money,CreatedDate"; if (baby_rule != "") { sql_insert.InsertCommand += ",baby_rule"; } if (baby_notice != "") { sql_insert.InsertCommand += ",baby_notice"; } sql_insert.InsertCommand += ") values('" + uid + "','" + selected[0] + "','" + selected[2] + "','" + selected[1] + "'"; sql_insert.InsertCommand += ",'" + selected[3] + "','" + selected[4] + "','" + selected[6] + "','" + selected[8] + "'"; sql_insert.InsertCommand += ",'" + selected[5] + "','" + selected[7] + "','" + selected[9] + "','" + selected[10] + "'"; sql_insert.InsertCommand += ",'" + selected[12] + "','" + selected[13] + "','" + selected[11] + "','" + selected[14] + "'"; sql_insert.InsertCommand += ",'" + howmany + "'"; sql_insert.InsertCommand += ",'" + age_range_start_year + "','" + age_range_start_month + "','" + age_range_end_year + "','" + age_range_end_month + "',N'" + money + "',SWITCHOFFSET(SYSDATETIMEOFFSET(), '+09:00')"; if (baby_rule != "") { sql_insert.InsertCommand += ",N'" + baby_rule + "'"; } if (baby_notice != "") { sql_insert.InsertCommand += ",N'" + baby_notice + "'"; } sql_insert.InsertCommand += ")"; sql_insert.Insert(); Session["id"] = uid; baby_rule_TextBox.Text = ""; baby_notice_TextBox.Text = ""; howmany_DropDownList.SelectedIndex = 0; age_range_start_year_DropDownList.SelectedIndex = 0; age_range_start_month_DropDownList.SelectedIndex = 0; age_range_end_year_DropDownList.SelectedIndex = 0; age_range_end_month_DropDownList.SelectedIndex = 0; foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { item.Selected = false; } } foreach (ListItem item in CheckBoxList2.Items) { if (item.Selected) { item.Selected = false; } } foreach (ListItem item in CheckBoxList3.Items) { if (item.Selected) { item.Selected = false; } } foreach (ListItem item in CheckBoxList4.Items) { if (item.Selected) { item.Selected = false; } } if (CheckBox1.Checked) { CheckBox1.Checked = false; } sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); string uisid = ""; if (ict_f.Count > 0) { uisid = ict_f.Table.Rows[0]["id"].ToString(); SqlDataSource sql_f1 = new SqlDataSource(); sql_f1.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f1.SelectCommand = "select id from user_information_store_week_appointment"; sql_f1.SelectCommand += " where uisid='" + uisid + "';"; sql_f1.DataBind(); DataView ict_f1 = (DataView)sql_f1.Select(DataSourceSelectArguments.Empty); if (ict_f1.Count > 0) { for (int i = 0; i < 7; i++) { CheckBox checked_week = (CheckBox)this.FindControl("week_of_day_CheckBox" + i); checked_week.Checked = false; DropDownList start_hour = (DropDownList)this.FindControl("start_hour_DropDownList" + i); DropDownList start_minute = (DropDownList)this.FindControl("start_minute_DropDownList" + i); DropDownList end_hour = (DropDownList)this.FindControl("end_hour_DropDownList" + i); DropDownList end_minute = (DropDownList)this.FindControl("end_minute_DropDownList" + i); start_hour.SelectedIndex = 0; start_minute.SelectedIndex = 0; end_hour.SelectedIndex = 0; end_minute.SelectedIndex = 0; } result_Label.Text = "登録に失敗しました。"; } else { for (int i = 0; i < 7; i++) { CheckBox checked_week = (CheckBox)this.FindControl("week_of_day_CheckBox" + i); int chc = 0; if (checked_week.Checked) { chc = 1; } DropDownList start_hour = (DropDownList)this.FindControl("start_hour_DropDownList" + i); DropDownList start_minute = (DropDownList)this.FindControl("start_minute_DropDownList" + i); DropDownList end_hour = (DropDownList)this.FindControl("end_hour_DropDownList" + i); DropDownList end_minute = (DropDownList)this.FindControl("end_minute_DropDownList" + i); sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store_week_appointment(uisid,checked,week_of_day,week_of_day_jp,start_hour,start_minute,end_hour,end_minute)"; sql_insert.InsertCommand += " values('" + uisid + "','" + chc + "','" + (i + 1) + "',N'" + checked_week.Text + "'"; sql_insert.InsertCommand += ",'" + start_hour.SelectedValue + "','" + start_minute.SelectedValue + "','" + end_hour.SelectedValue + "','" + end_minute.SelectedValue + "');"; sql_insert.Insert(); } result_Label.Text = "Success registered."; Response.Redirect("registered_1_1.aspx"); } } //result_Label.Text = "Success registered."; //Response.Redirect("registered_1_1.aspx"); } else { result_Label.Text = "登録に失敗しました。"; } } }
protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("home.aspx"); } else { string uid = Session["id"].ToString(); Session["id"] = uid; string bank_number = bank_number_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_person = bank_person_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_second_number = bank_second_number_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string bank_year = ddlYear.SelectedValue.ToString(); string bank_month = ddlMonth.SelectedValue.ToString(); bool check_type0_Image = false, check_type1_Image = false, check_bank_number = false, check_bank_person = false, check_bank_second_number = false; if (type0_Image.ImageUrl.ToString() != "") { check_type0_Image = true; image_Label.Text = ""; } else { image_Label.Text = "未入力"; } if (type1_Image.ImageUrl.ToString() != "") { check_type1_Image = true; image_Label0.Text = ""; } else { image_Label0.Text = "未入力"; } //if (bank_number != "") //{ // try // { // int number = Convert.ToInt32(bank_number); // check_bank_number = true; // bank_number_Label.Text = ""; // } // catch (Exception ex) // { // bank_number_Label.Text = "Bank number is not number."; // return; // throw ex; // } //} //else //{ // bank_number_Label.Text = "未入力"; //} //if (bank_second_number != "") //{ // try // { // int number = Convert.ToInt32(bank_second_number); // check_bank_second_number = true; // bank_second_number_Label.Text = ""; // } // catch (Exception ex) // { // bank_second_number_Label.Text = "Bank number is not number."; // return; // throw ex; // } //} //else //{ // bank_second_number_Label.Text = "未入力"; //} //if (bank_person != "") //{ // check_bank_person = true; // bank_person_Label.Text = ""; //} //else //{ // bank_person_Label.Text = "未入力"; //} //if (check_type0_Image && check_type1_Image && check_bank_person && check_bank_number && check_bank_second_number) if (check_type0_Image && check_type1_Image) { bool check_db = true; SqlDataSource sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select uid from user_information_school"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); DataView ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count > 0) { check_db = false; } if (check_db) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_school(uid,bank_number,bank_year,bank_month,bank_second_number,bank_person)"; sql_insert.InsertCommand += " values('" + uid + "','" + bank_number + "','" + bank_year + "','" + bank_month + "'"; sql_insert.InsertCommand += ",'" + bank_second_number + "','" + bank_person + "');"; sql_insert.Insert(); Session["id"] = uid; sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_school"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); string uischid = ict_f.Table.Rows[0]["id"].ToString(); sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_school_important_image"; sql_f.SelectCommand += " where uischid='" + uischid + "';"; sql_f.DataBind(); ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count == 0) { sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_school_important_image(uischid,type,filename)"; sql_insert.InsertCommand += " values('" + uischid + "','0','" + type0_Image.ImageUrl.ToString() + "');"; sql_insert.Insert(); sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_school_important_image(uischid,type,filename)"; sql_insert.InsertCommand += " values('" + uischid + "','1','" + type1_Image.ImageUrl.ToString() + "');"; sql_insert.Insert(); bank_number_TextBox.Text = ""; bank_person_TextBox.Text = ""; bank_second_number_TextBox.Text = ""; type0_Image.ImageUrl = ""; type1_Image.ImageUrl = ""; result_Label.Text = "Success registered."; Response.Redirect("registered_2_2.aspx"); } else { result_Label.Text = "登録に失敗しました。"; } } else { result_Label.Text = "登録に失敗しました。"; } } else { result_Label.Text = "登録に失敗しました。"; } } }
protected void Button2_Click(object sender, EventArgs e) { if (Session["id"] == null) { ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('Sorry you stay too long!')", true); Response.Redirect("home.aspx"); } else { string uid = Session["id"].ToString(); Session["id"] = uid; bool check_db = false; SqlDataSource sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store"; sql_f.SelectCommand += " where uid='" + uid + "';"; sql_f.DataBind(); DataView ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count > 0) { check_db = true; } if (check_db) { string uisid = ict_f.Table.Rows[0]["id"].ToString(); string title = title_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim(); string myself_content = myself_content_TextBox.Text.Replace("\'", "").Replace("\"", "").Replace("`", "").Trim().Replace(System.Environment.NewLine, "<br/>"); SqlDataSource sql_update = new SqlDataSource(); sql_update.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_update.UpdateCommand = "update user_information_store"; sql_update.UpdateCommand += " set title=N'" + title + "',myself_content=N'" + myself_content + "'"; sql_update.UpdateCommand += " where id='" + uisid + "';"; sql_update.Update(); sql_f = new SqlDataSource(); sql_f.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_f.SelectCommand = "select id from user_information_store_images"; sql_f.SelectCommand += " where uisid='" + uisid + "';"; sql_f.DataBind(); ict_f = (DataView)sql_f.Select(DataSourceSelectArguments.Empty); if (ict_f.Count == 0) { impath = (List <string>)ViewState["myData"]; //ScriptManager.RegisterStartupScript(Button2, Button2.GetType(), "alert", "alert('" + impath.Count + "')", true); for (int i = 0; i < impath.Count; i++) { SqlDataSource sql_insert = new SqlDataSource(); sql_insert.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString; sql_insert.InsertCommand = "insert into user_information_store_images(uisid,filename)"; sql_insert.InsertCommand += " values('" + uisid + "','" + impath[i] + "');"; sql_insert.Insert(); } title_TextBox.Text = ""; myself_content_TextBox.Text = ""; Panel1.Controls.Clear(); impath.Clear(); result_Label.Text = "Success registered."; Response.Redirect("registered_1_2.aspx"); } } else { result_Label.Text = "登録に失敗しました。"; } } }