public static int insertActivity(ShiduchActivity Activity) { SqlParameter[] prms = new SqlParameter[10]; string sqlAct, sql; sqlAct = "insert into ShiduchActivity values(" + BuildSql.InsertSql(out prms[0], Activity.Date) + BuildSql.InsertSql(out prms[1], Activity.UserId) + BuildSql.InsertSql(out prms[2], Activity.PeopleId) + BuildSql.InsertSql(out prms[3], Activity.Action) + BuildSql.InsertSql(out prms[4], Activity.IdSideB) + BuildSql.InsertSql(out prms[5], Activity.Status) + BuildSql.InsertSql(out prms[6], Activity.NotesSummary) + BuildSql.InsertSql(out prms[8], Activity.HideDelete, true) + ");"; prms[7] = new SqlParameter("@D", SqlDbType.Int); prms[7].Direction = ParameterDirection.Output; sql = "BEGIN TRANSACTION " + sqlAct + "SELECT @D = scope_identity();" + "COMMIT"; DBFunction.Execute(sql, prms); int ID = 0; if (prms[7].Value != DBNull.Value) { ID = Convert.ToInt32(prms[7].Value); } return(ID); }
public static void InserListHistory(List <HistoryChangeDetails> h) { int n = h.Count * 7 + 1, i = 0; SqlParameter[] prms = new SqlParameter[n]; string sqlHistory = "", sql; foreach (HistoryChangeDetails item in h) { sqlHistory += "INSERT INTO HistoryChangeDetails VALUES(" + BuildSql.InsertSql(out prms[i++], item.Date) + BuildSql.InsertSql(out prms[i++], item.IdUser) + BuildSql.InsertSql(out prms[i++], item.IdPeople) + BuildSql.InsertSql(out prms[i++], item.NameUser) + BuildSql.InsertSql(out prms[i++], item.FieldName) + BuildSql.InsertSql(out prms[i++], item.CurrentValue) + BuildSql.InsertSql(out prms[i++], item.NewValue, true) + "); "; } sql = "BEGIN TRANSACTION " + sqlHistory + "COMMIT"; DBFunction.Execute(sql, prms); }
public static void InsertReminder(ShiduchActivity Activity) { SqlParameter[] prms = new SqlParameter[10]; string sqlAct, sql; sqlAct = "insert into ReminderActivity values(" + BuildSql.InsertSql(out prms[0], Activity.Id) + BuildSql.InsertSql(out prms[1], Activity.reminder.IdUser) + BuildSql.InsertSql(out prms[2], Activity.reminder.Date) + BuildSql.InsertSql(out prms[3], false, true) + ");"; sql = "BEGIN TRANSACTION " + sqlAct + "COMMIT"; DBFunction.Execute(sql, prms); }
public static bool InsertNewNotes(NotesOfPeople note) { SqlParameter[] prms = new SqlParameter[10]; string sqlnotes, sql; sqlnotes = "INSERT INTO NotesOfPeople VALUES(" + BuildSql.InsertSql(out prms[0], GLOBALVARS.MyUser.ID) + BuildSql.InsertSql(out prms[1], GLOBALVARS.MyUser.Name) + BuildSql.InsertSql(out prms[2], note.PeopleId) + BuildSql.InsertSql(out prms[3], note.NoteText) + BuildSql.InsertSql(out prms[4], DateTime.Now, true) + ");"; sql = "BEGIN TRANSACTION " + sqlnotes + "COMMIT"; return(DBFunction.Execute(sql, prms)); }
public void InserHistory() { SqlParameter[] prms = new SqlParameter[10]; string sqlHistory, sql; sqlHistory = "INSERT INTO HistoryChangeDetails VALUES(" + BuildSql.InsertSql(out prms[1], this.Date) + BuildSql.InsertSql(out prms[2], this.IdUser) + BuildSql.InsertSql(out prms[3], this.IdPeople) + BuildSql.InsertSql(out prms[4], this.NameUser) + BuildSql.InsertSql(out prms[5], this.FieldName) + BuildSql.InsertSql(out prms[6], this.CurrentValue) + BuildSql.InsertSql(out prms[7], this.NewValue, true) + ");"; sql = "BEGIN TRANSACTION " + sqlHistory + "COMMIT"; DBFunction.Execute(sql, prms); }
private void Add() { int level = 0; if (DBFunction.CheckExist(txtusername.Text, "USERS", "username")) { MessageBox.Show("המשתמש קיים כבר במערכת", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (GLOBALVARS.MyUser.Control == User.TypeControl.Admin) { level = txttype.SelectedIndex; } string sector = SetSector(); SqlParameter[] prms = new SqlParameter[10]; string pass = User.SetPassword(txtpassword.Text); string sql = "insert into users(username,password,control,email,dateadded,name,tel,TempPersonal,TempGeneral,Sector) values(" + BuildSql.InsertSql(out prms[0], txtusername.Text) + BuildSql.InsertSql(out prms[1], pass) + BuildSql.InsertSql(out prms[2], level) + BuildSql.InsertSql(out prms[3], txtmail.Text) + BuildSql.InsertSql(out prms[4], DateTime.Now) + BuildSql.InsertSql(out prms[5], txtname.Text) + BuildSql.InsertSql(out prms[6], txttel.Text) + BuildSql.InsertSql(out prms[7], txtTempPersonal.SelectedIndex) + BuildSql.InsertSql(out prms[8], txtTempGeneral.SelectedIndex) + BuildSql.InsertSql(out prms[9], sector, true) + ");"; if (DBFunction.Execute(sql, prms)) { MessageBox.Show("נוסף בהצלחה", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("אירעה שגיאה", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool InsretNew(People people, out int ID) { int n = people.Note.Count * 5; SqlParameter[] prms = new SqlParameter[92 + n]; string sql, sqlpeoples, sqldetails, sqlregister, sqlNotes = ""; sqlpeoples = "INSERT INTO Peoples VALUES(" + BuildSql.InsertSql(out prms[0], people.FirstName) + BuildSql.InsertSql(out prms[1], people.Lasname) + BuildSql.InsertSql(out prms[2], people.Sexs) + BuildSql.InsertSql(out prms[3], people.Age) + BuildSql.InsertSql(out prms[4], people.Tall) + BuildSql.InsertSql(out prms[5], people.Weight) + BuildSql.InsertSql(out prms[6], people.FaceColor) + BuildSql.InsertSql(out prms[7], people.Looks) + BuildSql.InsertSql(out prms[8], people.Beard) + BuildSql.InsertSql(out prms[9], people.City) + BuildSql.InsertSql(out prms[10], people.Zerem) + BuildSql.InsertSql(out prms[11], people.Eda) + BuildSql.InsertSql(out prms[12], people.FutureLearn) + BuildSql.InsertSql(out prms[13], people.Background) + BuildSql.InsertSql(out prms[14], people.DadWork) + BuildSql.InsertSql(out prms[15], people.CoverHead) + BuildSql.InsertSql(out prms[16], people.GorTorN) + BuildSql.InsertSql(out prms[17], people.TneedE) + BuildSql.InsertSql(out prms[18], people.StakeM) + BuildSql.InsertSql(out prms[19], people.OpenHead) + BuildSql.InsertSql(out prms[20], people.Status) + people.Show + "," + BuildSql.InsertSql(out prms[21], people.LearnStaus) + BuildSql.InsertSql(out prms[22], people.Tz) + BuildSql.InsertSql(out prms[23], people.KindChasidut) + BuildSql.InsertSql(out prms[24], people.ShiducNum) + BuildSql.InsertSql(out prms[25], people.HealthStatus) + BuildSql.InsertSql(out prms[26], people.HealthDetails) + BuildSql.InsertSql(out prms[27], people.ZeremMom) + BuildSql.InsertSql(out prms[28], people.BirthDayHebrew) + BuildSql.InsertSql(out prms[29], people.DeleteReason) + BuildSql.InsertSql(out prms[30], people.Temp) + BuildSql.InsertSql(out prms[31], people.Chadchan, true) + ");"; sqldetails = "INSERT INTO PeopleDetails VALUES(" + BuildSql.InsertSql(out prms[32], people.Details.Street) + BuildSql.InsertSql(out prms[33], people.Details.Schools) + BuildSql.InsertSql(out prms[34], people.Details.Tel1) + BuildSql.InsertSql(out prms[35], people.Details.Tel2) + BuildSql.InsertSql(out prms[36], people.Details.WhoAmI) + BuildSql.InsertSql(out prms[37], people.Details.WhoIWant) + BuildSql.InsertSql(out prms[39], people.Details.DadName) + BuildSql.InsertSql(out prms[40], people.Details.MomName) + BuildSql.InsertSql(out prms[41], people.Details.ChildrenCount) + BuildSql.InsertSql(out prms[42], people.Details.SiblingsSchools) + BuildSql.InsertSql(out prms[43], people.Details.MomLname) + BuildSql.InsertSql(out prms[44], people.Details.MomWork) + BuildSql.InsertSql(out prms[45], people.Details.MoneyGives) + BuildSql.InsertSql(out prms[46], people.Details.MoneyRequired) + BuildSql.InsertSql(out prms[47], people.Details.MoneyNotesFlex) + BuildSql.InsertSql(out prms[48], people.Details.HomeRav) + BuildSql.InsertSql(out prms[49], people.Details.MechutanimNames) + "@DataID," + BuildSql.InsertSql(out prms[50], people.Details.ZevetInfo) + BuildSql.InsertSql(out prms[51], people.Details.FriendsInfo) + BuildSql.InsertSql(out prms[54], people.Details.Notes) + BuildSql.InsertSql(out prms[55], people.Details.OwnChildrenCount) + BuildSql.InsertSql(out prms[56], people.WorkPlace) + BuildSql.InsertSql(out prms[57], people.Details.MoneyToShadchan) + BuildSql.InsertSql(out prms[58], people.Details.YesivaKorHighSchool) + BuildSql.InsertSql(out prms[59], people.Details.YeshivaGorSeminary) + BuildSql.InsertSql(out prms[60], people.Details.KibutzorMaslul) + BuildSql.InsertSql(out prms[61], people.Details.Licence) + BuildSql.InsertSql(out prms[62], people.Details.Smoker) + BuildSql.InsertSql(out prms[63], people.Details.EdaExpectation) + BuildSql.InsertSql(out prms[64], people.Details.AgeExpectation) + BuildSql.InsertSql(out prms[65], people.Details.DadYeshiva) + BuildSql.InsertSql(out prms[66], people.Details.MomSeminary) + BuildSql.InsertSql(out prms[69], people.Details.StatusParents) + BuildSql.InsertSql(out prms[70], people.Details.CommunityTo) + BuildSql.InsertSql(out prms[71], people.Details.ParentHealth) + BuildSql.InsertSql(out prms[72], people.Details.ParentHealthDetails) + BuildSql.InsertSql(out prms[73], people.Details.LocationChild) + BuildSql.InsertSql(out prms[74], people.Details.NumMarriedSibilings) + BuildSql.InsertSql(out prms[75], people.Details.ContactShiduch) + BuildSql.InsertSql(out prms[76], people.Details.ContactPhone) + BuildSql.InsertSql(out prms[77], people.Details.FamilyAbout) + BuildSql.InsertSql(out prms[78], people.Details.Telephone) + BuildSql.InsertSql(out prms[79], people.Details.PhoneOfBachur) + BuildSql.InsertSql(out prms[80], people.Details.PhoneKosherLevel) + BuildSql.InsertSql(out prms[81], people.Details.Mail, true) + ");"; sqlregister = "INSERT INTO RegisterInfo VALUES(" + BuildSql.InsertSql(out prms[82], DateTime.Now) + "@DataID" + "," + GLOBALVARS.MyUser.ID + "," + BuildSql.InsertSql(out prms[83], GLOBALVARS.MyUser.Name) + BuildSql.InsertSql(out prms[84], DateTime.Now, true) + ");"; int iPrm = 90; foreach (var item in people.Note) { sqlNotes += "INSERT INTO NotesOfPeople VALUES(" + BuildSql.InsertSql(out prms[iPrm++], GLOBALVARS.MyUser.ID) + BuildSql.InsertSql(out prms[iPrm++], GLOBALVARS.MyUser.Name) + "@DataID" + "," + BuildSql.InsertSql(out prms[iPrm++], item.NoteText) + BuildSql.InsertSql(out prms[iPrm++], DateTime.Now, true) + "); "; } prms[85] = new SqlParameter("@D", SqlDbType.Int); prms[85].Direction = ParameterDirection.Output; sql = "BEGIN TRANSACTION " + "DECLARE @DataID int;" + sqlpeoples + "SELECT @DataID = scope_identity();" + "SELECT @D = scope_identity();" + sqldetails + sqlregister + sqlNotes + "COMMIT"; int length = sql.Length; // return DBFunction.Execute(sql, prms); bool f = DBFunction.Execute(sql, prms); ID = 0; if (prms[85].Value != DBNull.Value) { ID = Convert.ToInt32(prms[85].Value); } ShiduchActivity Activity = new ShiduchActivity(); Activity.Date = DateTime.Now; Activity.UserId = GLOBALVARS.MyUser.ID; Activity.PeopleId = ID; Activity.Action = (int)ShiduchActivity.ActionType.reception; ShiduchActivity.insertActivity(Activity); return(f); }