//-----------------Metodo de ACME------------------------------- private void SaveButton_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(LastNameTextBox.Text)) { DateTime bornDate = BornDateTimePicker.Value; DateTime fecha = DateTime.Now; if (EmployeeManagement.InsertEmployee(NameTextBox.Text, LastNameTextBox.Text, PhoneNumberTextBox.Text, IdTypeComboBox.SelectedItem.ToString(), IdentificationTextBox.Text, bornDate, fecha)) { FrmMain.Instance.ToolStripLabel.Text = "Se agrego el Empleado correctamente."; Clear(); ReloadEmployees(); } else { FrmMain.Instance.ToolStripLabel.Text = "Error! No se pudo agregar el Empleado."; } } else { FrmMain.Instance.ToolStripLabel.Text = "Error! El nombre y apellido son campos obligarios."; } } catch (Exception) { MetroMessageBox.Show(this, $"Ha ocurrido un error al agregar el empleado.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAddEmployee_Click(object sender, EventArgs e) { string name = txtNameEmployee.Text; string lastname = txtLastnameEmployee.Text; string telephone = mtxtTelephone.Text; string cellphone = mtxtCellphone.Text; string idType = cmbIdentificationType.Text; string identif = txtIdentification.Text; string bornDate = datepBornDate.Text; string email = txtEmailEmployee.Text; string nationality = txtNacionality.Text; string residence = txtResidence.Text; string civilStatus = cmbCivilState.Text; string childs = cmbChilds.Text; photo = ImageManagement.ImageToByte(file); string enterStore = cmbEnterStore.Text; PositionModel position = (PositionModel)cmbPosition.SelectedItem; string statusWorking = workingStateComboBox.Text; string startDate = startDateDateTime.Text; string observation = txaObservation.Text; string emergencyName = txtEmergencyName.Text; string emergencyPhone = mtxtEmergencyPhone.Text; try { if (EmployeeManagement.InsertEmployee(name, lastname, idType, identif, residence, bornDate, civilStatus, childs, telephone, cellphone, enterStore, nationality, position.idPosition.ToString(), statusWorking, startDate, observation, photo, emergencyName, emergencyPhone)) { dgvEmployee.DataSource = EmployeeManagement.SelectAllEmployees(); FrmMain.Instance.ToolStripLabel.Text = "Se agrego el trabajador correctamente"; } else { FrmMain.Instance.ToolStripLabel.Text = "No se pudo agregar el trabajador"; } } catch (Exception) { throw; } }