private void createuserbutton_Click(object sender, EventArgs e) { LoginClass loginobject = new LoginClass(dbserver, dbname, dbuser, dbpassword, dbport); carga men = new carga(); men.WindowState = FormWindowState.Normal; men.Show(); loginobject.FillUserBox(userbox); loginobject.CreateSchema("users"); loginobject.CreateUsertabla(); username = ""; this.Hide(); DireccionGestor.setorigen("out"); UserAddForm adduser = new UserAddForm(); adduser.WindowState = FormWindowState.Maximized; adduser.Show(); men.Close(); }
private void picturebutton_Click(object sender, EventArgs e) { carga man = new carga(); man.WindowState = FormWindowState.Normal; man.Show(); string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); OpenFileDialog getfile = new OpenFileDialog(); getfile.InitialDirectory = "C:\\"; getfile.Filter = "Image Files(*.jpg; *.png)|*.jpg; *.png"; getfile.FilterIndex = 1; if (getfile.ShowDialog() == DialogResult.OK) { string begin = getfile.FileName; string sourcePath = Path.GetDirectoryName(begin); string targetPath = System.IO.Path.Combine(path, UserAccessForm.getusername()); picturetextbox.Text = System.IO.Path.GetFileName(getfile.FileName); string sourcefile = getfile.FileName; string destfile = System.IO.Path.Combine(path, picturetextbox.Text); pictureBox.Image = Image.FromFile(getfile.FileName); rutafoto = picturetextbox.Text; if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } if (getfile.CheckFileExists) { } try { System.IO.File.Copy(sourcefile, sourcefile, true); } catch (System.IO.IOException getto) { getto.ToString(); } if (System.IO.Directory.Exists(sourcePath)) { string[] files = System.IO.Directory.GetFiles(sourcePath); // Copy the files and overwrite destination files if they already exist. foreach (string s in files) { // Use static Path methods to extract only the file name from the path. picturetextbox.Text = System.IO.Path.GetFileName(s); destfile = System.IO.Path.Combine(targetPath, picturetextbox.Text); try { System.IO.File.Copy(s, destfile, true); } catch (System.IO.IOException exept) { //MessageBox.Show("TRATE DE SELECCIONAR OTRA FOTO"); //picturetextbox.Text = System.IO.Path.GetFileName(getfile.FileName); exept.ToString(); } } } } man.Close(); }
private void savebuttonstrip_Click(object sender, EventArgs e) { int hour = DateTime.Now.Hour; int min = DateTime.Now.Minute; int sec = DateTime.Now.Second; int day = DateTime.Now.Day; int month = DateTime.Now.Month; int year = DateTime.Now.Year; string fecha = day.ToString() + "/" + month.ToString() + "/" + year.ToString(); string hora = hour.ToString() + ":" + min.ToString() + ":" + sec.ToString(); carga men = new carga(); men.WindowState = FormWindowState.Normal; men.Show(); LoginClass save = new LoginClass(dbserver, dbname, dbuser, dbpassword, dbport); if (UsersShowForm.getstate() == "edit") { if (nameBox.Text == "" || passwordbox.Text == "" || usercombo.Text == "" || askbox1.Text == "" || answerbox1.Text == "" || askbox2.Text == "" || answerbox2.Text == "" || askbox3.Text == "" || answerbox3.Text == "" || askbox4.Text == "" || answerbox4.Text == "" || askbox5.Text == "" || answerbox5.Text == "") { men.Close(); if (nameBox.Text == "") { nameBox.BackColor = Color.Red; } else { nameBox.BackColor = Color.Green; } if (passwordbox.Text == "") { passwordbox.BackColor = Color.Red; } else { passwordbox.BackColor = Color.Green; } if (usercombo.Text == "") { usercombo.BackColor = Color.Red; } else { usercombo.BackColor = Color.Green; } if (askbox1.Text == "") { askbox1.BackColor = Color.Red; } else { askbox1.BackColor = Color.Green; } if (answerbox1.Text == "") { answerbox1.BackColor = Color.Red; } else { answerbox1.BackColor = Color.Green; } if (askbox2.Text == "") { askbox2.BackColor = Color.Red; } else { askbox2.BackColor = Color.Green; } if (answerbox2.Text == "") { answerbox2.BackColor = Color.Red; } else { answerbox2.BackColor = Color.Green; } if (askbox3.Text == "") { askbox3.BackColor = Color.Red; } else { askbox3.BackColor = Color.Green; } if (answerbox3.Text == "") { answerbox3.BackColor = Color.Red; } else { answerbox3.BackColor = Color.Green; } if (askbox4.Text == "") { askbox4.BackColor = Color.Red; } else { askbox4.BackColor = Color.Green; } if (answerbox4.Text == "") { answerbox4.BackColor = Color.Red; } else { answerbox4.BackColor = Color.Green; } if (askbox5.Text == "") { askbox5.BackColor = Color.Red; } else { askbox5.BackColor = Color.Green; } if (answerbox5.Text == "") { answerbox5.BackColor = Color.Red; } else { answerbox5.BackColor = Color.Green; } if (institucionbox.Text == "") { institucionbox.BackColor = Color.Red; } else { institucionbox.BackColor = Color.Green; } if (telefonobox.Text == "") { telefonobox.BackColor = Color.Red; } else { telefonobox.BackColor = Color.Green; } if (emailbox.Text == "") { emailbox.BackColor = Color.Red; } else { emailbox.BackColor = Color.Green; } MessageBox.Show("HAY DATOS IMPORTANTES VACIOS"); } else { string name = nameBox.Text; string password = passwordbox.Text; string usertipo = usercombo.Text; string ask1 = askbox1.Text; string answer1 = answerbox1.Text; string ask2 = askbox2.Text; string answer2 = answerbox2.Text; string ask3 = askbox3.Text; string answer3 = answerbox3.Text; string ask4 = askbox4.Text; string answer4 = answerbox4.Text; string ask5 = askbox5.Text; string answer5 = answerbox5.Text; string foto = picturetextbox.Text; string email = emailbox.Text; string telefono = telefonobox.Text; string institucion = institucionbox.Text; string orden = "UPDATE users_table SET USER_NAME= '" + name + "', USER_PASSWORD='******', USERTIPO='" + usertipo + "', QUESTION1='" + ask1 + "',ANSWER1='" + answer1 + "', QUESTION2='" + ask2 + "',ANSWER2='" + answer2 + "',QUESTION3='" + ask3 + "',ANSWER3='" + answer3 + "',QUESTION4='" + ask4 + "',ANSWER4='" + answer4 + "',QUESTION5='" + ask5 + "',ANSWER5='" + answer5 + "',PICTURE_ROUTE='" + picturetextbox.Text + "' ,INSTITUCION='" + institucion + "',TELEFONO='" + telefono + "',EMAIL='" + email + "' WHERE USER_NAME = '" + UsersShowForm.getdatum()[0] + "' AND USERTIPO = '" + UsersShowForm.getdatum()[1] + "' AND ID = '" + UsersShowForm.getdatum()[2] + "' AND FECHA_CREACION = '" + UsersShowForm.getdatum()[3] + "'; "; save.ordensql(orden); men.Close(); MessageBox.Show("USUARIO " + UsersShowForm.getdatum()[0] + " HA SIDO MODIFICADO"); if (UserAccessForm.getusername() != nameBox.Text) { UserAccessForm add = new UserAccessForm(); add.WindowState = FormWindowState.Maximized; add.Show(); this.Close(); } else { UsersShowForm add = new UsersShowForm(); add.WindowState = FormWindowState.Maximized; add.Show(); this.Close(); } } } else { if (save.UserNoCopied(nameBox.Text) == true) { men.Close(); MessageBox.Show("El usuario " + nameBox.Text + " ya existe"); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else if (save.UserNoCopied(nameBox.Text) == false) { if (passwordbox.Text != passwordsecuritybox.Text) { men.Close(); MessageBox.Show("LAS CONTRASEÑAS NO COINCIDEN"); } else { if (nameBox.Text == "" || passwordbox.Text == "" || passwordsecuritybox.Text == "" || askbox1.Text == "" || askbox2.Text == "" || askbox3.Text == "" || askbox4.Text == "" || askbox5.Text == "" || answerbox1.Text == "" || answerbox2.Text == "" || answerbox3.Text == "" || answerbox4.Text == "" || answerbox5.Text == "" || emailbox.Text == "" || telefonobox.Text == "" || institucionbox.Text == "") { men.Close(); MessageBox.Show("Hay datos importantes vacios, termine el formulario."); } else { if (DireccionGestor.getorigen() == "inicio") { //institucion, telefono, email if (save.CreateNewUser(nameBox.Text, passwordbox.Text, picturetextbox.Text, askbox1.Text, askbox2.Text, askbox3.Text, askbox4.Text, askbox5.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text, usercombo.Text, fecha, hora, institucionbox.Text, telefonobox.Text, emailbox.Text) == true) { men.Close(); MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO EXITOSAMENTE."); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else if (DireccionGestor.getorigen() == "buscador") { men.Close(); MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO."); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); UsersShowForm menu = new UsersShowForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else { men.Close(); MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO."); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } } else if (DireccionGestor.getorigen() == "" || DireccionGestor.getorigen() == null || DireccionGestor.getorigen() == "out") { //institucion,telefono,email if (save.CreateNewUser(nameBox.Text, passwordbox.Text, picturetextbox.Text, askbox1.Text, askbox2.Text, askbox3.Text, askbox4.Text, askbox5.Text, answerbox1.Text, answerbox2.Text, answerbox3.Text, answerbox4.Text, answerbox5.Text, usercombo.Text, fecha, hora, institucionbox.Text, telefonobox.Text, emailbox.Text) == true) { men.Close(); MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " NO PUDO SER CREADO."); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); UserAccessForm menu = new UserAccessForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else { men.Close(); MessageBox.Show("NUEVO USUARIO " + nameBox.Text + " HA SIDO CREADO EXITOSAMENTE."); if (MessageBox.Show("Agregar a otro usuario?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { save = new LoginClass(); UserAccessForm menu = new UserAccessForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { save = new LoginClass(); UserAddForm menu = new UserAddForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } } } } } } save = new LoginClass(); }
private void OKbutton_Click(object sender, EventArgs e) { cuenta = 0; carga ca = new carga(); ca.WindowState = FormWindowState.Normal; ca.Show(); if (DireccionGestor.getorigen() == "inicio") { if (nombrebox.Text == "" || telefonobox.Text == "") { if (nombrebox.Text == "") { nombrebox.BackColor = Color.Red; } else { nombrebox.BackColor = Color.Green; } if (telefonobox.Text == "") { telefonobox.BackColor = Color.Red; } else { telefonobox.BackColor = Color.Green; } MessageBox.Show("HAY CAMPOS CLAVES VACIOS"); } else { if (direccionbox.Text == "") { direccionbox.Text = "NINGUNA"; } if (emailbox.Text == "") { emailbox.Text = "NINGUNA"; } try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString()); MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO"); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { add = new LoginClass(); this.Close(); } else { add = new LoginClass(); addContact menu = new addContact(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } catch (FormatException datethis) { datethis.ToString(); } } } else if (DireccionGestor.getorigen() == "editor") { try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.ordensql("UPDATE " + UserAccessForm.getusername() + "_contacts_table SET NOMBRE='" + nombrebox.Text + "', TELEFONO='" + telefonobox.Text + "', DIRECCION='" + direccionbox.Text + "', EMAIL='" + emailbox.Text + "' WHERE ID='" + ShowContacts.getdataout()[4] + "';"); MessageBox.Show("CONTACTO " + DireccionGestor.getnombrestatic() + " EDITADO"); ShowContacts show = new ShowContacts(); show.WindowState = FormWindowState.Normal; show.Show(); this.Close(); } catch (FormatException datethis) { datethis.ToString(); } catch (IndexOutOfRangeException oper) { oper.ToString(); } } else if (DireccionGestor.getorigen() == "buscador") { if (nombrebox.Text == "" || telefonobox.Text == "") { if (nombrebox.Text == "") { nombrebox.BackColor = Color.Red; } else { nombrebox.BackColor = Color.Green; } if (telefonobox.Text == "") { telefonobox.BackColor = Color.Red; } else { telefonobox.BackColor = Color.Green; } MessageBox.Show("HAY CAMPOS CLAVES VACIOS"); } else { if (direccionbox.Text == "") { direccionbox.Text = "NINGUNA"; } if (emailbox.Text == "") { emailbox.Text = "NINGUNA"; } try { LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.AddContact(nombrebox.Text, telefonobox.Text, direccionbox.Text, emailbox.Text, UserAccessForm.getusername().ToString()); MessageBox.Show("NUEVO CONTACTO " + nombrebox.Text + " AGREGADO"); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { add = new LoginClass(); ShowContacts ad = new ShowContacts(); ad.WindowState = FormWindowState.Normal; ad.Show(); this.Close(); } else { add = new LoginClass(); addContact menu = new addContact(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } catch (FormatException datethis) { datethis.ToString(); } } } ca.Close(); }
private void OKbutton_Click(object sender, EventArgs e) { LoginClass ver; string asign; string orden; string teach; if (asignaturatextbox.Text == "" || comboasignado.Text == "" || descripcionbox.Text == "") { if (asignaturatextbox.Text == "") { asignaturatextbox.BackColor = Color.Red; } else { asignaturatextbox.BackColor = Color.Green; } if (comboasignado.Text == "") { comboasignado.BackColor = Color.Red; } else { comboasignado.BackColor = Color.Green; } if (descripcionbox.Text == "") { descripcionbox.BackColor = Color.Red; } else { descripcionbox.BackColor = Color.Green; } } else if (DireccionGestor.getorigen() == "inicio") { carga pap = new carga(); pap.WindowState = FormWindowState.Normal; pap.Show(); ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); string complete = UserAccessForm.getusername() + "_subject_table"; orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; asign = ver.takedatatable(orden, "ASIGNATURA"); orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; teach = ver.takedatatable(orden, "ASIGNADO"); try { if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text)) { MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text); pap.Close(); } else { ver.AddSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, UserAccessForm.getusername()); pap.Close(); MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA"); ShowSubjects.setchange("modify"); this.Close(); } } catch (NullReferenceException PAP) { PAP.ToString(); pap.Close(); MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA"); ShowSubjects.setchange("modify"); this.Close(); } } else if (DireccionGestor.getorigen() == "editor") { carga pap = new carga(); pap.WindowState = FormWindowState.Normal; pap.Show(); ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); string complete = UserAccessForm.getusername() + "_subject_table"; orden = "SELECT * FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; asign = ver.takedatatable(orden, "ASIGNATURA"); orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; teach = ver.takedatatable(orden, "ASIGNADO"); if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text)) { pap.Close(); MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text); } else { orden = "RENAME TABLE `" + LoginClass.getdata()[1] + "_" + UserAccessForm.getusername() + "_evaluation_student_table` TO `" + asignaturatextbox.Text + "_" + UserAccessForm.getusername() + "_evaluation_student_table`;"; ver.ordensql(orden); orden = "RENAME TABLE `" + LoginClass.getdata()[1] + "_" + UserAccessForm.getusername() + "_calification_student_table` TO `" + asignaturatextbox.Text + "_" + UserAccessForm.getusername() + "_calification_student_table`;"; ver.ordensql(orden); complete = UserAccessForm.getusername() + "_subject_table"; ver.editSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, LoginClass.getdata()[1], LoginClass.getdata()[2], UserAccessForm.getusername()); pap.Close(); MessageBox.Show("ASIGNATURA " + LoginClass.getdata()[1] + " HA SIDO EDITADA"); ShowSubjects.setchange("modify"); this.Close(); } } else if (DireccionGestor.getorigen() == "buscador") { carga pap = new carga(); pap.WindowState = FormWindowState.Normal; pap.Show(); ver = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); string complete = UserAccessForm.getusername() + "_subject_table"; orden = "SELECT ASIGNATURA FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; asign = ver.takedatatable(orden, "ASIGNATURA"); orden = "SELECT ASIGNADO FROM " + complete + " WHERE ASIGNATURA='" + asignaturatextbox.Text + "' and ASIGNADO='" + comboasignado.Text + "';"; teach = ver.takedatatable(orden, "ASIGNADO"); try { if ((asign == asignaturatextbox.Text) && (teach == comboasignado.Text)) { MessageBox.Show("LA ASIGNATURA " + asignaturatextbox.Text + " FUE ASIGNADA A " + comboasignado.Text); pap.Close(); } else { ver.AddSubject(asignaturatextbox.Text, comboasignado.Text, descripcionbox.Text, UserAccessForm.getusername()); MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA"); ShowSubjects.setchange("modify"); this.Close(); } } catch (NullReferenceException PAP) { PAP.ToString(); pap.Close(); MessageBox.Show("ASIGNATURA " + asignaturatextbox.Text + " HA SIDO CREADA"); ShowSubjects.setchange("modify"); this.Close(); } } }
private void savebuttonstrip_Click(object sender, EventArgs e) { carga man = new carga(); if (savebuttonstrip.Text == "GUARDAR") { man.WindowState = FormWindowState.Normal; if (gottendegree.Text == "" || nameEmployeeBox.Text == "" || idBox.Text == "" || telephoneNumberBox.Text == "" || schedule.Text == "" || cargobox.Text == "" || comboNacionalidad.Text == "" || ageBox.Text == "" || mensualitybox.Text == "" || personalReferenceBox.Text == "" || telephoneReferenceBox.Text == "" || relationReferenceBox.Text == "" || AlergyNmaeBox.Text == "" || DolenciaNameBox.Text == "" || nameMedicineBox.Text == "" || MotivoMedicineBox.Text == "") { MessageBox.Show("Hay datos importantes vacios, termine el formulario."); if (gottendegree.Text == "") { gottendegree.BackColor = Color.Red; } else { gottendegree.BackColor = Color.Green; } if (nameEmployeeBox.Text == "") { nameEmployeeBox.BackColor = Color.Red; } else { nameEmployeeBox.BackColor = Color.Green; } if (idBox.Text == "") { idBox.BackColor = Color.Red; } else { idBox.BackColor = Color.Green; } if (telephoneNumberBox.Text == "") { telephoneNumberBox.BackColor = Color.Red; } else { telephoneNumberBox.BackColor = Color.Green; } if (schedule.Text == "") { schedule.BackColor = Color.Red; } else { schedule.BackColor = Color.Green; } if (cargobox.Text == "") { cargobox.BackColor = Color.Red; } else { cargobox.BackColor = Color.Green; } if (comboNacionalidad.Text == "") { comboNacionalidad.BackColor = Color.Red; } else { comboNacionalidad.BackColor = Color.Green; } if (ageBox.Text == "") { ageBox.BackColor = Color.Red; } else { ageBox.BackColor = Color.Green; } if (mensualitybox.Text == "") { mensualitybox.BackColor = Color.Red; } else { mensualitybox.BackColor = Color.Green; } if (personalReferenceBox.Text == "") { personalReferenceBox.BackColor = Color.Red; } else { personalReferenceBox.BackColor = Color.Green; } if (telephoneReferenceBox.Text == "") { telephoneReferenceBox.BackColor = Color.Red; } else { telephoneReferenceBox.BackColor = Color.Green; } if (relationReferenceBox.Text == "") { relationReferenceBox.BackColor = Color.Red; } else { relationReferenceBox.BackColor = Color.Green; } if (AlergyNmaeBox.Text == "") { AlergyNmaeBox.BackColor = Color.Red; } else { AlergyNmaeBox.BackColor = Color.Green; } if (DolenciaNameBox.Text == "") { DolenciaNameBox.BackColor = Color.Red; } else { DolenciaNameBox.BackColor = Color.Green; } if (nameMedicineBox.Text == "") { nameMedicineBox.BackColor = Color.Red; } else { nameMedicineBox.BackColor = Color.Green; } if (MotivoMedicineBox.Text == "") { MotivoMedicineBox.BackColor = Color.Red; } else { MotivoMedicineBox.BackColor = Color.Green; } } else { try { string userDataName = UserAccessForm.getusername() + "_employee_table"; EmployeeClass employee = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); employee.NameNoCopied(nameEmployeeBox.Text, userDataName); int age = int.Parse(ageBox.Text); double mensuality = double.Parse(mensualitybox.Text); DateTime birthdate = Convert.ToDateTime(birthDateBox.Value.Date); DateTime timegetin = Convert.ToDateTime(dategetin.Value.ToShortTimeString()); string access = userDataName; if (mensualitybox.BackColor == Color.Red) { MessageBox.Show("Arregle el campo no valido"); } else { if (employee.NameNoCopied(nameEmployeeBox.Text, userDataName) == true) { man.Close(); MessageBox.Show("El Empleado " + nameEmployeeBox.Text + " ya existe."); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { employee = new EmployeeClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { employee = new EmployeeClass(); EmployeeForm menu = new EmployeeForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else if (employee.NameNoCopied(nameEmployeeBox.Text, userDataName) == false) { if (gottendegree.Text == "" || nameEmployeeBox.Text == "" || idBox.Text == "" || telephoneNumberBox.Text == "" || schedule.Text == "" || cargobox.Text == "" || comboNacionalidad.Text == "" || ageBox.Text == "" || mensualitybox.Text == "" || personalReferenceBox.Text == "" || telephoneReferenceBox.Text == "" || relationReferenceBox.Text == "" || AlergyNmaeBox.Text == "" || DolenciaNameBox.Text == "" || nameMedicineBox.Text == "" || MotivoMedicineBox.Text == "") { MessageBox.Show("Hay datos importantes vacios, termine el formulario."); } else { string date = birthDateBox.Value.Day.ToString() + "/" + birthDateBox.Value.Month.ToString() + "/" + birthDateBox.Value.Year.ToString(); string evento = birthDateBox.Value.Day.ToString() + "/" + birthDateBox.Value.Month.ToString(); string eventoname = "CUMPLEAÑOS DE " + nameEmployeeBox.Text; AgendaClass addevent = new AgendaClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); addevent.saveData(UserAccessForm.getusername(), eventoname, 1, date, "7:20:0", "NO", "NO", "NO", "NO", "NO", "NO", "NO", evento, "SI", ""); LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.AddContact(nameEmployeeBox.Text, telephoneNumberBox.Text, direccionbox.Text, emailcombo.Text, UserAccessForm.getusername().ToString()); if (employee.SaveData(userDataName, dategetin, gottendegree.Text, nameEmployeeBox.Text, idBox.Text, birthDateBox, telephoneNumberBox.Text, schedule.Text, cargobox.Text, comboNacionalidad.Text, age, mensuality, personalReferenceBox.Text, telephoneReferenceBox.Text, relationReferenceBox.Text, AlergyNmaeBox.Text, DolenciaNameBox.Text, nameMedicineBox.Text, MotivoMedicineBox.Text, picturetextbox.Text, monedatipo.Text, sexobox.Text, direccionbox.Text, emailcombo.Text)) { man.Close(); employee.NameNoCopied(nameEmployeeBox.Text, userDataName); employee.OrderID(userDataName); MessageBox.Show("NUEVO EMPLEADO " + nameEmployeeBox.Text + " HA SIDO AGREGADO."); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { employee = new EmployeeClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { employee = new EmployeeClass(); EmployeeForm menu = new EmployeeForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } else { man.Close(); MessageBox.Show("NUEVO EMPLEADO " + nameEmployeeBox.Text + "HA SIDO AGREGADO."); if (MessageBox.Show("Agregar a otro empleado?", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { employee = new EmployeeClass(); DireccionGestor menu = new DireccionGestor(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } else { employee = new EmployeeClass(); EmployeeForm menu = new EmployeeForm(); menu.WindowState = FormWindowState.Normal; menu.Show(); this.Close(); } } } } } } catch (FormatException datethis) { datethis.ToString(); } } } else if (savebuttonstrip.Text == "MODIFICAR") { man.WindowState = FormWindowState.Normal; if (referenciaopcionbox.Text == "NO") { man.Close(); telephoneNumberBox.Text = "NINGUNA"; relationReferenceBox.Text = "NINGUNA"; personalReferenceBox.Text = "NINGUNA"; } try { man.Close(); string userDataName = UserAccessForm.getusername() + "_employee_table"; EmployeeClass save = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); AgendaClass addevent = new AgendaClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); double mensuality = double.Parse(mensualitybox.Text); string nameevent = "CUMPLEAÑOS DE " + nameEmployeeBox.Text; string date = birthDateBox.Value.Day.ToString() + "/" + birthDateBox.Value.Month.ToString() + "/" + birthDateBox.Value.Year.ToString(); string momentdate = birthDateBox.Value.Day.ToString() + "/" + birthDateBox.Value.Month.ToString(); save.ModifyData(DireccionGestor.getnombrestatic(), trabajando.Text, userDataName, dategetin, salidapicker, gottendegree.Text, nameEmployeeBox.Text, idBox.Text, birthDateBox, telephoneNumberBox.Text, schedule.Text, cargobox.Text, comboNacionalidad.Text, int.Parse(ageBox.Text), mensuality, personalReferenceBox.Text, telephoneNumberBox.Text, relationReferenceBox.Text, AlergyNmaeBox.Text, DolenciaNameBox.Text, nameMedicineBox.Text, MotivoMedicineBox.Text, picturetextbox.Text, monedatipo.Text, sexobox.Text, direccionbox.Text, emailcombo.Text, EmployeeClass.getids()); addevent.modifydata(UserAccessForm.getusername(), DireccionGestor.getnombrestatic(), nameevent, 1, date, "7:20:0", "NO", "NO", "NO", "NO", "NO", "NO", "NO", momentdate, "SI"); LoginClass add = new LoginClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); add.editContact(nameEmployeeBox.Text, telephoneNumberBox.Text, direccionbox.Text, emailcombo.Text, DireccionGestor.getnombrestatic(), UserAccessForm.getusername().ToString()); MessageBox.Show("EL EMPLEADO " + nameEmployeeBox.Text + " HA SIDO MODIFICADO"); EmployeeClass studentobject = new EmployeeClass(UserAccessForm.getdbserver(), UserAccessForm.getdbname(), UserAccessForm.getdbuser(), UserAccessForm.getdbpassword(), UserAccessForm.getdbport()); EmployeeFormSearch buscar = new EmployeeFormSearch(); buscar.WindowState = FormWindowState.Maximized; buscar.Show(); this.Close(); } catch (FormatException datethis) { datethis.ToString(); } } }