private void DeleteButton_Click(object sender, EventArgs e) { try { if (ConectioncomboBox.Enabled) { int id = int.Parse(ConectioncomboBox.SelectedValue.ToString()); if (id > 0) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", "¿Desea eliminar la conexión?", MessageBoxIcon.Question); if (alr.ShowDialog() == DialogResult.Yes) { if (readerConnectionBLL.Delete(id) > 0) { alr = new Alerts.cFAT100010("Información", "Se ha eliminado correctamente", MessageBoxIcon.Information); } else { alr = new Alerts.cFAT100010("Información", "No se ha eliminado la conexión", MessageBoxIcon.Error); } LoadData(); } } } }catch (Exception ex) { MessageBox.Show(String.Format("DeleteButton_Click: {0}", ex.Message), "Información", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private int FormValidate() { try { if (string.IsNullOrEmpty(UserNameTextBox.Text)) { Alerts.cFAT100010 frmAlert = new Alerts.cFAT100010("Información", "Ingrese su Usuario", MessageBoxIcon.Information); frmAlert.ShowDialog(); return(0); } if (string.IsNullOrEmpty(PasswordTextBox.Text)) { Alerts.cFAT100010 frmAlert = new Alerts.cFAT100010("Información", "Ingrese su Contraseña", MessageBoxIcon.Information); frmAlert.ShowDialog(); return(0); } return(1); }catch (Exception ex) { MessageBox.Show(String.Format("formValidate: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(0); } }
static void Main(string[] args) { try { if (System.IO.File.Exists(FILENAME)) { ArgumentSystem.Arguments arguments = new ArgumentSystem.Arguments(); if (args.Length == 0) { if (arguments.ValidLicense()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new cMRT100010()); } } else { arguments.Verification(args); } } else { Alerts.cFAT100010 alrt = new Alerts.cFAT100010("Información", "No se ha encontrado la conexión a la Base de datos", MessageBoxIcon.Error); alrt.ShowDialog(); //ArgumentSystem.Applications execApp = new ArgumentSystem.Applications(); //execApp.execute("Connection.exe", "SERVER"); } }catch (Exception ex) { MessageBox.Show(String.Format("Main: {0}", ex), "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void SaveButton_Click(object sender, EventArgs e) { try { if (FormValidate()) { readerConnectionML.idReader = int.Parse(ModelComboBox.SelectedValue.ToString()); readerConnectionML.ip = IPtextBox.Text; readerConnectionML.name = NameConectiontextBox.Text; readerConnectionML.port = PortTextBox.Text; readerConnectionML.isDefault = DefaultCheckBox.Checked; if (readerConnectionBLL.save(readerConnectionML) > 0) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", " La información se ha guardado correctamente", MessageBoxIcon.Information); alr.ShowDialog(); EnabledControls(false); } else { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", " La información no se ha guardado correctamente", MessageBoxIcon.Error); alr.ShowDialog(); } CancelButton.Visible = false; AddButton.Enabled = true; LoadData(); } }catch (Exception ex) { MessageBox.Show(string.Format("SaveButton_Click: {0}", ex.Message), "Información", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void login() { try { if (FormValidate() > 0) { BussinesLayer.UsersBLL UserBLL = new BussinesLayer.UsersBLL(); ModelLayer.UsersML UsersML = new ModelLayer.UsersML() { UserName = UserNameTextBox.Text, Password = PasswordTextBox.Text }; UsersML = UserBLL.IsUser(UsersML); if (UsersML != null && UsersML.Id > 0) { BussinesLayer.RoleBLL roleBLL = new BussinesLayer.RoleBLL(); ModelLayer.RoleML roleML = roleBLL.GetIdEntity(UsersML.Rol); if (roleML == null) { throw new Exception("No se encontro el rol del usuario"); } if (roleML.Name.ToUpper() == "ADMIN") { //_frm = new cMRT100010(); BussinesLayer.GlobalBLL.userML = UsersML; //cMRT100010 frm = new cMRT100010(); //this.Hide(); //frm.Show(); this.Hide(); } else { Alerts.cFAT100010 frmAlert = new Alerts.cFAT100010("Información", "No cuenta con los privilegios suficientes", MessageBoxIcon.Error); frmAlert.ShowDialog(); //_frm = new Forms.CFRT140010(); //Abre el formulario de registro //Forms.CFRT140010 frm = new Forms.CFRT140010(); //this.Hide(); //frm.Show(); } } else { Alerts.cFAT100010 frmAlert = new Alerts.cFAT100010("Información", "El Usuario/contraseña no es valido", MessageBoxIcon.Error); frmAlert.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(String.Format("login: {0}", ex), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cFMSE110010_Load(object sender, EventArgs e) { try { companyBLL = new CompanyBLL(); companyML = companyBLL.GetEntity(); if (companyML != null) { RFCTextBox.Text = companyML.Rfc; RazonSocialTextBox.Text = companyML.BusinessName; CalleTextBox.Text = companyML.Street; MunicipioTextBox.Text = companyML.Municipality; PaisTextBox.Text = companyML.Country; CorreoTextBox.Text = companyML.Email; EstadoTextBox.Text = companyML.State; CodigoPostalTextBox.Text = companyML.PostalCode; TelefonoTextBox.Text = companyML.Telephone; textBoxNumberUsers.Text = companyML.NumberUserEmploye; if (!string.IsNullOrEmpty(companyML.Image)) { PathFileNameTextBox.Text = string.Format("{0}\\{1}", System.IO.Path.GetFullPath(GlobalBLL.DirectoryFiles), companyML.Image); if (System.IO.File.Exists(PathFileNameTextBox.Text)) { LogoPictureBox.BackgroundImage = new Bitmap(PathFileNameTextBox.Text); } else { throw new Exception("No se encontró la imagen"); } } } else { companyML = new CompanyML(); } LoadUser(); if (!System.IO.Directory.Exists(GlobalBLL.DirectoryFiles)) { System.IO.Directory.CreateDirectory(GlobalBLL.DirectoryFiles); } } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("EROR", string.Format("cFMSE110010_Load: {0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); } }
public bool FormValidateEnterprise() { try { bool Valid = true; if (string.IsNullOrEmpty(RFCTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar el RFC"); } else if (string.IsNullOrEmpty(RazonSocialTextBox.Text)) { Valid = false; throw new Exception("Debe ingresar la razón social"); } else if (string.IsNullOrEmpty(CalleTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar la calle"); } else if (string.IsNullOrEmpty(MunicipioTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar el Municipio"); } else if (string.IsNullOrEmpty(RFCTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar el estado"); } else if (string.IsNullOrEmpty(TelefonoTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar el Teléfono"); } else if (string.IsNullOrEmpty(CorreoTextBox.Text)) { Valid = false; throw new Exception("Debe ingesar el Correo Electrónico"); } return(Valid); } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("ERROR", string.Format("{0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); return(false); } }
private bool FormValidate() { Alerts.cFAT100010 alr; if (string.IsNullOrEmpty(NameConectiontextBox.Text)) { alr = new Alerts.cFAT100010("Información", "Debe ingresar el nombre de la conexíon", MessageBoxIcon.Error); alr.ShowDialog(); return(false); } else if (string.IsNullOrEmpty(IPtextBox.Text)) { alr = new Alerts.cFAT100010("Información", "Debe ingresar la dirección IP", MessageBoxIcon.Error); alr.ShowDialog(); return(false); } else if (string.IsNullOrEmpty(PortTextBox.Text)) { alr = new Alerts.cFAT100010("Información", "Debe ingresar el puerto de la conexión", MessageBoxIcon.Error); alr.ShowDialog(); return(false); } return(true); }
public bool FormValidateUser() { try { bool Valid = true; if (string.IsNullOrEmpty(NameTextBox.Text)) { Valid = false; throw new Exception("Ingrese el Nombre del Usuario"); } else if (string.IsNullOrEmpty(LastNameTextBox.Text)) { Valid = false; throw new Exception("Ingrese el apellido"); } else if (string.IsNullOrEmpty(UserNameTextBox.Text)) { Valid = false; throw new Exception("Ingrese un Nombre de Usuario Valido"); } else if (string.IsNullOrEmpty(PasswordTextBox.Text)) { Valid = false; throw new Exception("Ingrese la contraseña"); } return(Valid); } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("ERROR", string.Format("{0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); return(false); } }
private void ExportExcelButton_Click(object sender, EventArgs e) { try { if (data != null && data.Rows.Count > 0) { SaveFileDialog fichero = new SaveFileDialog(); fichero.Filter = "Excel (*.xls)|*.xls"; if (fichero.ShowDialog() == DialogResult.OK) { //Creating DataTable. DataTable dt = new DataTable(); //Adding the Columns. foreach (DataGridViewColumn column in data.Columns) { dt.Columns.Add(column.HeaderText, column.ValueType); } //Adding the Rows. foreach (DataGridViewRow row in data.Rows) { dt.Rows.Add(); foreach (DataGridViewCell cell in row.Cells) { Console.WriteLine(cell.ValueType); if (string.IsNullOrEmpty(cell.Value.ToString())) { if (cell.ValueType == typeof(Int32)) { cell.Value = 0; } if (cell.ValueType == typeof(Decimal)) { cell.Value = 0; } if (cell.ValueType == typeof(Double)) { cell.Value = 0; } if (cell.ValueType == typeof(String)) { cell.Value = string.Empty; } if (cell.ValueType == typeof(Boolean)) { cell.Value = false; } if (cell.ValueType == typeof(DateTime)) { cell.Value = string.Empty; } } dt.Rows[dt.Rows.Count - 1][cell.ColumnIndex] = cell.Value.ToString(); } } //Exporting to Excel. //string folderPath = "C:\\Excel\\"; //if (!Directory.Exists(folderPath)) //{ // Directory.CreateDirectory(folderPath); //} using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, Title); ////Set the color of Header Row. ////A resembles First Column while C resembles Third column. //wb.Worksheet(1).Cells("A1:C1").Style.Fill.BackgroundColor = XLColor.DarkGreen; //for (int i = 1; i <= dt.Rows.Count; i++) //{ // //A resembles First Column while C resembles Third column. // //Header row is at Position 1 and hence First row starts from Index 2. // string cellRange = string.Format("A{0}:C{0}", i + 1); // if (i % 2 != 0) // { // wb.Worksheet(1).Cells(cellRange).Style.Fill.BackgroundColor = XLColor.GreenYellow; // } // else // { // wb.Worksheet(1).Cells(cellRange).Style.Fill.BackgroundColor = XLColor.Yellow; // } //} //Adjust widths of Columns. wb.Worksheet(1).Columns().AdjustToContents(); //Save the Excel file. wb.SaveAs(fichero.FileName); if (File.Exists(fichero.FileName)) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", "Exportación Exitosa", MessageBoxIcon.Information); alr.ShowDialog(); } else { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Error", "Exportación Fallida", MessageBoxIcon.Error); alr.ShowDialog(); } } } //SaveFileDialog fichero = new SaveFileDialog(); //fichero.Filter = "Excel (*.xls)|*.xls"; //if (fichero.ShowDialog() == DialogResult.OK) //{ // Microsoft.Office.Interop.Excel.Application aplicacion; // Microsoft.Office.Interop.Excel.Workbook libros_trabajo; // Microsoft.Office.Interop.Excel.Worksheet hoja_trabajo; // aplicacion = new Microsoft.Office.Interop.Excel.Application(); // libros_trabajo = aplicacion.Workbooks.Add(); // hoja_trabajo = // (Microsoft.Office.Interop.Excel.Worksheet)libros_trabajo.Worksheets.get_Item(1); // //Recorremos el DataGridView rellenando la hoja de trabajo // for (int i = 0; i < grd.Rows.Count - 1; i++) // { // for (int j = 0; j < grd.Columns.Count; j++) // { // hoja_trabajo.Cells[i + 1, j + 1] = grd.Rows[i].Cells[j].Value.ToString(); // } // } // libros_trabajo.SaveAs(fichero.FileName, // Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal); // libros_trabajo.Close(true); // aplicacion.Quit(); //} } } catch (Exception ex) { throw new Exception(string.Format("ExportExcelButton_Click: {0}", ex.Message)); } }
/// <summary> /// Argumentos PARA ACCESO RAPIDO /// 1.- USUARIO /// 2.- PASSWORD /// 3.- PANTALLA /// </summary> /// <param name="arguments"></param> public void Verification(String [] ArgumentsList) { try { if (ArgumentsList.Length > 2 && VerificationUser(ArgumentsList[0], ArgumentsList[1]) == true) { if (ValidLicense()) { switch (ArgumentsList[2]) { case "FMCX": //Application.Run(new cFMCX000010()); break; case "RTEM": Application.Run(new RegistryTime.Forms.CFRT140010()); break; case "RTLG": Application.Run(new RegistryTime.Forms.cFRT150010()); break; case "RTAL": Application.Run(new Alerts.cFAT100010("Informacion", "Texto descripcion", MessageBoxIcon.Information)); break; case "test": Application.Run(new cMRT1000101()); break; case "FCGL": Application.Run(new Forms.Migrate.cFMCG100010()); break; //case "CHECK": // if (Convert.ToInt32(ArgumentsList[3].ToString()) == 0) // { // ProcessMigrate(Convert.ToInt32(ArgumentsList[4].ToString())); // } // if (Convert.ToInt32(ArgumentsList[3].ToString()) == 1) // { // if (ArgumentsList.Length > 3 && Convert.ToDateTime(ArgumentsList[4].ToString()) > Convert.ToDateTime(ArgumentsList[3].ToString())) // ProcessMigrate(Convert.ToDateTime(ArgumentsList[3]), Convert.ToDateTime(ArgumentsList[4]), Convert.ToInt32(ArgumentsList[5])); // } // break; case "FCRP": Application.Run(new Forms.Reports.cFMRP100010()); break; case "RP12": Application.Run(new Forms.Reports.cFMRP140010()); break; case "MIGRATE": //if (ArgumentsList.Length > 3 && Convert.ToDateTime(ArgumentsList[4].ToString()) > Convert.ToDateTime(ArgumentsList[3].ToString())) //{ // Forms.Migrate.cFMMI100010 frm = new Forms.Migrate.cFMMI100010(Convert.ToDateTime(ArgumentsList[3]), Convert.ToDateTime(ArgumentsList[4]), Convert.ToInt32(ArgumentsList[5])); // Application.Run(frm); //} if (Convert.ToInt32(ArgumentsList[3].ToString()) == 0) { //ProcessMigrate(Convert.ToInt32(ArgumentsList[4].ToString())); Forms.Migrate.cFMMI100010 frm = new Forms.Migrate.cFMMI100010(); Application.Run(frm); frm.Dispose(); } if (Convert.ToInt32(ArgumentsList[3].ToString()) == 1) { if (ArgumentsList.Length > 3 && Convert.ToDateTime(ArgumentsList[4].ToString()) > Convert.ToDateTime(ArgumentsList[3].ToString())) { ProcessMigrate(Convert.ToDateTime(ArgumentsList[3]), Convert.ToDateTime(ArgumentsList[5]), Convert.ToInt32(ArgumentsList[4])); } } break; case "TEST": Application.Run(new cMRT1000101()); break; default: MessageBox.Show("Error"); break; } } } else { Alerts.cFAT100010 Alert = new Alerts.cFAT100010("Error", "El USUARIO O CONTRASEÑA SON INCORRECTOS", MessageBoxIcon.Error); Alert.ShowDialog(); } }catch (Exception ex) { throw new Exception(String.Format("{0}.Verification: {1}", core, ex.Message)); } }
private void MigrateBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Migración", "Proceso completo", MessageBoxIcon.Information); alr.ShowDialog(); //this.Invoke(new Action(() => { false; } )); }
private void buttonNuevo_Click(object sender, EventArgs e) { try { if (FormValidateEnterprise()) { string lastImage = companyML.Image; if (!string.IsNullOrEmpty(PathFileNameTextBox.Text) && !System.IO.File.Exists(PathFileNameTextBox.Text)) { throw new Exception("La imagen seleccionada no existe"); } companyML.Rfc = RFCTextBox.Text; companyML.BusinessName = RazonSocialTextBox.Text; companyML.Street = CalleTextBox.Text; companyML.Municipality = MunicipioTextBox.Text; companyML.Country = PaisTextBox.Text; companyML.Email = CorreoTextBox.Text; companyML.State = EstadoTextBox.Text; companyML.PostalCode = CodigoPostalTextBox.Text; companyML.Telephone = TelefonoTextBox.Text; companyML.NumberUserEmploye = textBoxNumberUsers.Text; companyML.Image = System.IO.Path.GetFileName(PathFileNameTextBox.Text); if (companyBLL.Save(companyML) > 0) { GlobalBLL.companyML = companyML; if (!string.IsNullOrEmpty(PathFileNameTextBox.Text)) { if (!System.IO.Directory.Exists(GlobalBLL.DirectoryFiles)) { System.IO.Directory.CreateDirectory(GlobalBLL.DirectoryFiles); } string lastPathFile = string.Format("{0}/{1}", GlobalBLL.DirectoryFiles, lastImage); if (System.IO.Path.GetFullPath(lastPathFile) != PathFileNameTextBox.Text) { try { System.IO.File.Delete(lastPathFile); } catch { } finally { System.IO.File.Copy(PathFileNameTextBox.Text, string.Format("{0}/{1}", GlobalBLL.DirectoryFiles, System.IO.Path.GetFileName(PathFileNameTextBox.Text))); } } } Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", "Guardado correctamente", MessageBoxIcon.Information); alr.ShowDialog(); } else { Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", "No se ha guardado los cambios", MessageBoxIcon.Error); alr.ShowDialog(); } } } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("EROR", string.Format("buttonNuevo_Click: {0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); } }
private void SaveUserButton_Click(object sender, EventArgs e) { try { if (FormValidateUser()) { BussinesLayer.UsersBLL usersBLL = new UsersBLL(); if (usersBLL.UserExist(UserNameTextBox.Text, GlobalBLL.userML.Id) <= 0) { string lastImage = GlobalBLL.userML.Image; if (!string.IsNullOrEmpty(PathFileProfileTextBox.Text) && !System.IO.File.Exists(PathFileProfileTextBox.Text)) { throw new Exception("La imagen seleccionada no existe"); } if (employeeML != null) { employeeML.Name = NameTextBox.Text; employeeML.LastName = LastNameTextBox.Text; employeeBLL.Save(employeeML); } GlobalBLL.userML.UserName = PasswordTextBox.Text; GlobalBLL.userML.Password = PasswordTextBox.Text; GlobalBLL.userML.Image = System.IO.Path.GetFileName(PathFileProfileTextBox.Text); if (usersBLL.Save(GlobalBLL.userML) > 0) { if (!string.IsNullOrEmpty(PathFileProfileTextBox.Text)) { if (!System.IO.Directory.Exists(GlobalBLL.DirectoryFiles)) { System.IO.Directory.CreateDirectory(GlobalBLL.DirectoryFiles); } string lastPathFile = string.Format("{0}/{1}", GlobalBLL.DirectoryFiles, lastImage); if (System.IO.Path.GetFullPath(lastPathFile) != PathFileProfileTextBox.Text) { System.IO.File.Delete(lastPathFile); System.IO.File.Copy(PathFileProfileTextBox.Text, string.Format("{0}/{1}", GlobalBLL.DirectoryFiles, System.IO.Path.GetFileName(PathFileProfileTextBox.Text))); } } Alerts.cFAT100010 alr = new Alerts.cFAT100010("Información", "Guardado correctamente", MessageBoxIcon.Information); alr.ShowDialog(); } } else { Alerts.cFAT100010 alr = new Alerts.cFAT100010("ERROR", "El nombre de usuario se encuentra en uso.", MessageBoxIcon.Error); alr.ShowDialog(); } } if (textBoxNumberUsers.Text != String.Empty && Convert.ToInt32(textBoxNumberUsers.Text) > 0) { } } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("ERROR", string.Format("cFMSE110010_Load: {0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); } }