protected void Button1_Click(object sender, EventArgs e) { string Profile_ID, tourid, stayid, phid, emid, primaryprofileid; string fname, lname, add1, phone1, email1, resort, checkin, checkout, VP_Id; string office = "IVO"; string[] ar = new string[10]; int i = 0, j; string kk; int year = DateTime.Now.Year; SqlDataReader reader = Queries2.getvpval(); while (reader.Read()) { ar[i] = reader.GetString(0); i++; } for (j = 0; j < i; j++) { int cnt = Queries2.checkifVPexist(ar[j]); if (cnt == 0) { Profile_ID = Queries.GetProfileID(office); // int profile = Queries.InsertProfile(Profile_ID, DateTime.Now, "", "", "", "", "", "", "", "", "", "", "", "", "", "", office, "", "", "", "", "", "", "",ar[j]); primaryprofileid = Queries.GetPrimaryProfileID(office); tourid = Queries.GetTourDetailsID(office); stayid = Queries.GetStayDetailsID(office); phid = Queries.GetPhoneID(office); emid = Queries.GetEmailID(office); //int adddetail = Queries2.InsertDetailsVP(tourid, stayid, phid, emid,ar[j]); DataSet ds1 = Queries2.LoadVPDetails(ar[j]); VP_Id = ds1.Tables[0].Rows[0]["VP_Id"].ToString(); fname = ds1.Tables[0].Rows[0]["VP_First_Name"].ToString(); lname = ds1.Tables[0].Rows[0]["VP_Last_Name"].ToString(); add1 = ds1.Tables[0].Rows[0]["VP_Address1"].ToString(); phone1 = ds1.Tables[0].Rows[0]["VP_Phone"].ToString(); email1 = ds1.Tables[0].Rows[0]["VP_Email"].ToString(); resort = ds1.Tables[0].Rows[0]["VP_Resort"].ToString(); checkin = ds1.Tables[0].Rows[0]["VP_Arival_Date"].ToString(); checkout = ds1.Tables[0].Rows[0]["VP_Departure_Date"].ToString(); int primary = Queries.InsertPrimaryProfile(primaryprofileid, "", fname, lname, "", "", "", Profile_ID, "", "", ""); int tourdetails = Queries2.InsertTourDetailsVP(tourid, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", VP_Id, Profile_ID); //int staydetails = Queries.InsertProfileStay(stayid, resort, "", checkin, checkout, Profile_ID, tourid); int staydetails = Queries.InsertProfileStay(stayid, resort, "", checkin, checkout, Profile_ID); int phone = Queries.InsertPhone(phid, Profile_ID, "", phone1, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); int email = Queries.InsertEmail(emid, Profile_ID, email1, "", "", "", "", "", "", "", "", "", "", ""); int update = Queries.UpdateProfileValue(office, year); int updatep = Queries.UpdatePrimaryValue(office, year); //int updateadd = Queries.UpdateAddressValue(office, year); int updatestay = Queries.UpdateStayValue(office, year); int updatetour = Queries.UpdateTourValue(office, year); int updatephone = Queries.UpdatePhoneValue(office, year); int updateemail = Queries.UpdateEmailValue(office, year); } else { DataSet ds1 = Queries2.LoadVPDetails(ar[j]); VP_Id = ds1.Tables[0].Rows[0]["VP_Id"].ToString(); fname = ds1.Tables[0].Rows[0]["VP_First_Name"].ToString(); lname = ds1.Tables[0].Rows[0]["VP_Last_Name"].ToString(); add1 = ds1.Tables[0].Rows[0]["VP_Address1"].ToString(); phone1 = ds1.Tables[0].Rows[0]["VP_Phone"].ToString(); email1 = ds1.Tables[0].Rows[0]["VP_Email"].ToString(); resort = ds1.Tables[0].Rows[0]["VP_Resort"].ToString(); checkin = ds1.Tables[0].Rows[0]["VP_Arival_Date"].ToString(); checkout = ds1.Tables[0].Rows[0]["VP_Departure_Date"].ToString(); string profil_id = Queries2.getprofileidVP(VP_Id); tourid = Queries.GetTourDetailsID(office); stayid = Queries.GetStayDetailsID(office); int tourdetails = Queries2.InsertTourDetailsVP(tourid, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", VP_Id, profil_id); //int staydetails = Queries.InsertProfileStay(stayid, resort, "", checkin, checkout, profil_id, tourid); int updatestay = Queries.UpdateStayValue(office, year); int updatetour = Queries.UpdateTourValue(office, year); } } }