private void FormServar_Shown(object sender, EventArgs e) { if (File.Exists(Application.StartupPath + "\\logserver.txt")) { loginserver = File.ReadAllLines(Application.StartupPath + "\\logserver.txt"); if (loginserver.Length > 0) { if (loginserver[0].IndexOf('(') > 0) { ch_db_in.Checked = true; tx_sql.Text = loginserver[0].ToString().Trim(); tx_sql.Focus(); } else { ch_db_out.Checked = true; tx_sql.Text = loginserver[0].ToString().Trim(); tx_sql.Focus(); } radioButton1.Checked = Boolean.Parse(loginserver[1]); radioButton2.Checked = Boolean.Parse(loginserver[2]); txtUserName.Text = EncryptionClass.Decrypt(loginserver[3], "nanoahmedmohammmadnaelzadf18"); txtPassword.Text = EncryptionClass.Decrypt(loginserver[4], "nanoahmedmohammmadnaelzadf18"); } } //ch_db_in.Checked =true; //tx_sql.Focus(); }
private void FormLogin_Shown(object sender, EventArgs e) { if (File.Exists(Application.StartupPath + "\\loginList.txt")) { loginserver = File.ReadAllLines(Application.StartupPath + "\\loginList.txt"); if (loginserver.Length > 0) { try { txtUserName.Text = EncryptionClass.Decrypt(loginserver[0], "nanoahmedmohammmadnaelzadf18"); txtPassword.Text = EncryptionClass.Decrypt(loginserver[1], "nanoahmedmohammmadnaelzadf18"); txtbranch.Text = loginserver[2].ToString().Trim(); checkBox1.Checked = Boolean.Parse(loginserver[3]); }catch { } } } }
public string instailserual() { // string con_ss = File.ReadAllText(Application.StartupPath + "\\conn.txt"); string sql; SqlCommand cm; sql = "select * from Serial_Table"; SqlDataReader dr; try { Declaration dec; dec = new Declaration(); // = new Declaration(); if (dec.Activity(getMACAdress()) == "No") { DialogResult ds = MessageBox.Show("معذرة هذا الجهاز غير مصرح له بتشغيل النظام يرجى التواصل مع مدير النظام" + "/n" + EncryptionClass.Encrypt("nanoahmedmohammmadnaelzadf18", getMACAdress() + "t3xzq162") + "\n" + "هل تريد انشاء ملف طلب تصريح?", "الامان والحماية", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (ds == DialogResult.Yes) { string filename = "Save Here"; SaveFileDialog sf = new SaveFileDialog(); sf.FileName = filename; if (sf.ShowDialog() == DialogResult.OK) { string savePath = Path.GetDirectoryName(sf.FileName); FileStream f = new FileStream(savePath + "\\Declaration.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); // StreamWriter stw = new StreamWriter(f); byte[] da = new byte[255]; da = ASCIIEncoding.Unicode.GetBytes(EncryptionClass.Encrypt("nanoahmedmohammmadnaelzadf18", getMACAdress() + "t3xzq162") + ":" + getMACAdress()); f.Write(da, 0, da.Length); f.Close(); } } return(""); } day = int.Parse(dec.day); // con = new SqlConnection(" Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename =" + con_db + "; Integrated Security = True; Connect Timeout = 30;"); DBConnection db = new DBConnection(); conn = db.masterConn(); cm = new SqlCommand(sql, conn); ///////////////////////////////////////////// // Connect = new SqlConnection(connStr); try { if (conn.State == ConnectionState.Closed) { conn.Open(); } dr = cm.ExecuteReader(); if (dr.Read()) { key_serial = getMACAdress(); // instail = EncryptionClass.Decrypt (dr["Install"].ToString(), "t3xzq162"); instail = dec.dateinstail; use = EncryptionClass.Decrypt(dr["use_date"].ToString(), "t3xzq162"); dr.Close(); conn.Close(); chek = true; return(key_serial); } else {//"8/3/2019" key_serial = getMACAdress(); dr.Close(); IsConstiant date_conv = new IsConstiant(); // string onlyDate = date_conv.ConvertDateCalendar(DateTime.Now, "en-US"); string onlyDate = dec.dateinstail;//date_conv.ConvertDateCalendar(DateTime.Now, "en-US"); //MessageBox.Show(onlyDate); cm = new SqlCommand("insert into Serial_Table values('" + key_serial + "','','" + EncryptionClass.Encrypt(onlyDate, "t3xzq162") + "','" + EncryptionClass.Encrypt(onlyDate, "t3xzq162") + "')", conn); cm.ExecuteNonQuery(); conn.Close(); chek = false; instail = onlyDate; use = onlyDate; //MessageBox.Show(onlyDate); return(key_serial); } } catch { // FormConnet ff = new FormConnet("data"); //ff.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("معذرة هذا الجهاز غير مصرح له بتشغيل النظام يرجى التواصل مع مدير النظام" + "/n" + EncryptionClass.Encrypt("nanoahmedmohammmadnaelzadf18", getMACAdress() + "t3xzq162") + "/n" + ex.Message, "Product key", MessageBoxButtons.OK, MessageBoxIcon.Error); //if (ds == DialogResult.Yes) //{ } /////////////////////////////////////// conn.Close(); return(""); }