private void SaveButton_Click(object sender, EventArgs e) { try { HPS.Common.EncryptUserPass Encrytion = new HPS.Common.EncryptUserPass(); if (!string.IsNullOrEmpty(serverNameTextBox.Text) && !string.IsNullOrEmpty(userNameTextBox.Text) && !string.IsNullOrEmpty(passwordTextBox.Text) && !string.IsNullOrEmpty(dataBaseNameTextBox.Text)) { string dataTosave = string.Format("{0}&{1}&{2}&{3}&{4}", serverNameTextBox.Text, userNameTextBox.Text, passwordTextBox.Text, dataBaseNameTextBox.Text, CompanyServerIPTextBox.Text); using (Rijndael myRijndael = Rijndael.Create()) { // Encrypt the string to an array of bytes. byte[] encrypted = Encrytion.EncryptStringToBytes(dataTosave, myRijndael.Key, myRijndael.IV); System.IO.FileStream stream = new System.IO.FileStream(String.Format("{0}\\DefaultSetting.xml", Application.StartupPath), System.IO.FileMode.Create, System.IO.FileAccess.Write); stream.Write(encrypted, 0, encrypted.Length); stream.Close(); //Hepsa.Core.Common.MessageBox.InformationMessage("ثبت شد"); this.Close(); } } else { throw new ApplicationException("اطلاعات پایگاه داده خالی است"); } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
private void smsShowSettingButton_Click(object sender, EventArgs e) { try { FileInfo file = new System.IO.FileInfo(String.Format("{0}\\smsDefaultSetting.xml", Application.StartupPath)); if (file.Exists == false) { return; } else { HPS.Common.EncryptUserPass Encrytionclass = new HPS.Common.EncryptUserPass(); byte[] readFile = File.ReadAllBytes(String.Format("{0}\\smsDefaultSetting.xml", Application.StartupPath)); string readFromFile = string.Empty; readFromFile = Encrytionclass.DecryptUserPassword(readFile); string[] slpitedParts = null; slpitedParts = readFromFile.Split('&'); if (!string.IsNullOrEmpty(slpitedParts[0])) { serverNameTextBox.Text = slpitedParts[0]; } if (!string.IsNullOrEmpty(slpitedParts[1])) { userNameTextBox.Text = slpitedParts[1]; } if (!string.IsNullOrEmpty(slpitedParts[2])) { passwordTextBox.Text = slpitedParts[2]; } if (!string.IsNullOrEmpty(slpitedParts[3])) { this.dataBaseNameTextBox.Text = slpitedParts[3]; } if (!string.IsNullOrEmpty(slpitedParts[4])) { this.smsUserNameTextBox.Text = slpitedParts[4]; } if (!string.IsNullOrEmpty(slpitedParts[5])) { this.smsPasswordTextBox.Text = slpitedParts[5]; } if (!string.IsNullOrEmpty(slpitedParts[6])) { this.smsNumberTextBox.Text = slpitedParts[6]; } if (!string.IsNullOrEmpty(slpitedParts[7])) { this.receivesMessageTimeExpiredTextBox.Text = slpitedParts[7]; } //(string)Hepsa.Core.Common.PersentationController.GetEntityValue(ds.Tables["ConnectionString"].Rows[0]["DataBase"], TypeCode.String); } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
private void previouseSettingButton_Click(object sender, EventArgs e) { try { FileInfo file = new System.IO.FileInfo(String.Format("{0}\\DefaultSetting.xml", Application.StartupPath)); if (file.Exists == false) { return; } else { HPS.Common.EncryptUserPass Encrytionclass = new HPS.Common.EncryptUserPass(); byte[] readFile = File.ReadAllBytes(String.Format("{0}\\DefaultSetting.xml", Application.StartupPath)); string readFromFile = string.Empty; readFromFile = Encrytionclass.DecryptUserPassword(readFile); string[] slpitedParts = null; slpitedParts = readFromFile.Split('&'); if (!string.IsNullOrEmpty(slpitedParts[0])) { serverNameTextBox.Text = slpitedParts[0]; } if (!string.IsNullOrEmpty(slpitedParts[1])) { userNameTextBox.Text = slpitedParts[1]; } if (!string.IsNullOrEmpty(slpitedParts[2])) { passwordTextBox.Text = slpitedParts[2]; } if (!string.IsNullOrEmpty(slpitedParts[3])) { this.dataBaseNameTextBox.Text = slpitedParts[3]; } if (!string.IsNullOrEmpty(slpitedParts[4])) { this.CompanyServerIPTextBox.Text = slpitedParts[4]; } } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }