private void button11_Click(object sender, EventArgs e) { //Recibe e imprime la informacion requerida por el usuario int Mul; int Fac; int Fi; switch (operador) { case "*": { b = int.Parse(Textcuadro.Text); Mul = obj.multiplicacion((a), (b)); Textcuadro.Text = "La multiplicación de los numeros ingresados es: " + Mul.ToString(); } break; case "!": { Fac = obj2.Factorial((a)); Textcuadro.Text = "El factorial del número ingresado es: " + Fac.ToString(); } break; case "Fi": { Fi = obj3.Fibonacci((a)); Textcuadro.Text = Fi.ToString(); Textcuadro.Text = "El número que se encuentra en la posición " + a + " de la serie de fibonacci es: " + Fi.ToString(); } break; } }
//Use this function when you want to login into an existing account. public void AccountLogin() { //First it will check if the inputfields are empty, if they are empty it will immidiatly stop the function. if (loginUsername.text == "" || loginPassword.text == "") { RespondText.text = "<color=red>You got to put something in the inputfield, otherwise it wont work.</color>"; StartCoroutine(RemoveText(3)); return; } else { SearchNewSaveFiles(); //checks if files exist in the current directory it's checking. if (saveInfo.Length > 0) { //foreach file found it will run the code below. foreach (FileInfo Fi in saveInfo) { //it will load the current file the foreach has taken. json = File.ReadAllText(Fi.ToString()); //it will get the information saved in the file and put the information in the dictionary and a string. DataInfo = JsonConvert.DeserializeObject <SaveGameDataInfo>(json); //the dictionary accountHolder = DataInfo.Accounts; //the string LoadFileName = DataInfo.saveFileName; //First it will check if the current information taken from the file equals the information from the inputfields. //if it is true it will load the data from that account and end the loop. if (accountHolder.ContainsKey(loginUsername.text) && accountHolder.ContainsValue(loginPassword.text)) { RespondText.text = "<color=blue>Account information correct.</color>"; Data.LoadData(LoadFileName); StartCoroutine(RemoveText(3)); Data.SaveUsername(); ResetValues(); SceneManager.LoadScene("Level 1"); return; } //if the information doesn't exist in the files it will give an error message that the password or username is incorrect. else if (!accountHolder.ContainsKey(loginUsername.text) || !accountHolder.ContainsValue(loginPassword.text)) { RespondText.text = "<color=red>Username or password is not correct.</color>"; StartCoroutine(RemoveText(3)); } accountHolder.Clear(); } ResetValues(); } //if there are no files in the directory it will give an error that there are no files found. else { RespondText.text = "<color=red>No save files found. Please register your account first.</color>"; ResetValues(); StartCoroutine(RemoveText(3)); } } }
//Use this function when you want to register your account. public void RegisterAccount() { //First it will check if the inputfields are empty, if they are empty it will immidiatly stop the function. if (registerUsername.text == "" || registerPassword.text == "" || SaveFileName.text == "") { RespondText.text = "<color=red>Username, password or save file name has not been filled in.</color>"; StartCoroutine(RemoveText(3)); return; } else { SearchNewSaveFiles(); //checks if files exist in the current directory it's checking. if (saveInfo.Length > 0) { //foreach file found it will run the code below. foreach (FileInfo Fi in saveInfo) { //it will load the current file the foreach has taken. json = File.ReadAllText(Fi.ToString()); //it will get the information saved in the file and put the information in the dictionary and a string. DataInfo = JsonConvert.DeserializeObject <SaveGameDataInfo>(json); //the dictionary accountHolder = DataInfo.Accounts; //the string LoadFileName = DataInfo.saveFileName; //checks if the save file name of the username used for the account already exists, if it does it will stop the loop. if (accountHolder.ContainsKey(registerUsername.text) || LoadFileName == DataInfo.saveFileName) { RespondText.text = "<color=red> account already exists.</color>"; StartCoroutine(RemoveText(3)); return; } //if that isn't the case it will register the account and stop the loop. else { accountHolder.Add(registerUsername.text, registerPassword.text); RespondText.text = "<color=blue>Account has been registered.</color>"; Data.SaveData(); StartCoroutine(RemoveText(3)); return; } } ResetValues(); } //if there are no files in the directory it will run the code below. else { accountHolder.Add(registerUsername.text, registerPassword.text); RespondText.text = "<color=blue>Account has been registered.</color>"; Data.SaveData(); ResetValues(); StartCoroutine(RemoveText(3)); } accountHolder.Clear(); } }
private void btnadjuntar_Click(object sender, EventArgs e) { GenerarAdjunto(); gbcabecera.Enabled = false; gbmensaje.Enabled = false; gbopciones.Enabled = false; dgvadjuntos.SendToBack(); OpenFileDialog BuscarArchivo = new OpenFileDialog(); BuscarArchivo.Filter = "Archivos |*.*"; //Aquí incluiremos los filtros que queramos. BuscarArchivo.FileName = ""; BuscarArchivo.Title = "Titulo del Dialogo"; if (tipo == 1) { BuscarArchivo.InitialDirectory = @"C:\Ordenes de Compra"; } else if (tipo == 2) { BuscarArchivo.InitialDirectory = @"C:\Cotizaciones"; } //BuscarArchivo.InitialDirectory = @"C:\Ordenes de Compra"; BuscarArchivo.Multiselect = true; if (BuscarArchivo.ShowDialog() == DialogResult.OK) { DataTable Dt = new DataTable(); Int32 idfile = 1; Dt.Columns.Add(new DataColumn("Id", typeof(Int32))); Dt.Columns.Add(new DataColumn("Archivo", typeof(String))); DataTable Dt2 = (DataTable)dgvadjuntos.DataSource; foreach (String Fi in BuscarArchivo.FileNames) { Dt.Rows.Add(idfile, Fi.ToString()); } foreach (String Fi in BuscarArchivo.SafeFileNames) { link_adjunto1.Text += Fi + " "; link_adjunto1.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline; } if (Dt2 == null) { dgvadjuntos.DataSource = Dt; } else if (Dt.Rows != null) { Dt2.Merge(Dt); dgvadjuntos.DataSource = Dt2; } } gbcabecera.Enabled = true; gbmensaje.Enabled = true; gbopciones.Enabled = true; //gbGestionEnvio.Enabled = true; this.Cursor = Cursors.Default; }