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(); }
// Thread thshow; private void btnLogin_Click(object sender, EventArgs e) { ////////////////////////////////// DBConnection db = new DBConnection();//dbconnction is class name //thshow = new Thread(showdow); //thshow.Start(); conn = db.masterConn(); if (btnLogin.Enabled == true) { validateUser(); } else { return; } if (File.Exists(Application.StartupPath + "\\loginList.txt")) { if (checkBox1.Checked) { File.WriteAllText(Application.StartupPath + "\\loginList.txt", EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt(txtPassword.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + txtbranch.Text + " \n" + Convert.ToString(checkBox1.Checked)); } else { File.WriteAllText(Application.StartupPath + "\\loginList.txt", EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt("", "nanoahmedmohammmadnaelzadf18") + " \n" + txtbranch.Text + " \n" + Convert.ToString(checkBox1.Checked)); } } else { try { File.Create(Application.StartupPath + "\\loginList.txt"); if (checkBox1.Checked) { File.WriteAllText(Application.StartupPath + "\\loginList.txt", EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt(txtPassword.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + txtbranch.Text + " \n" + Convert.ToString(checkBox1.Checked)); } else { File.WriteAllText(Application.StartupPath + "\\loginList.txt", EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt("", "nanoahmedmohammmadnaelzadf18") + " \n" + txtbranch.Text + " \n" + Convert.ToString(checkBox1.Checked)); } } catch { } } /////////////////////////////////////////////////////////// //f6.Close(); //thshow.Abort(); }
void upd_use(string use) { try { SqlCommand cmd; string sql = "update Serial_Table set use_date ='" + EncryptionClass.Encrypt(use.ToString(), "t3xzq162") + "'"; conn.Close(); conn.Open(); cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); // MessageBox.Show(use); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public string building() { string s = instailserual(); if (s == "") { return(s); } string keyy = EncryptionClass.Encrypt("nanoahmedmohammmadnaelzadf18", s + "t3xzq162"); // string keyy = EncryptionClass.Decrypt("8uQr0vvruTvMp5XA34FrVfb6jh1qV4aPOrHIST9F8vQ =" , "nanoahmedmohammmadnaelzadf18"); //8uQr0vvruTvMp5XA34FrVfb6jh1qV4aPOrHIST9F8vQ= // MessageBox.Show(keyy); return(keyy); }
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(""); }
private void btnLogin_Click(object sender, EventArgs e) { if (File.Exists(Application.StartupPath + "\\logserver.txt")) { File.WriteAllText(Application.StartupPath + "\\logserver.txt", tx_sql.Text.ToString().Trim() + " \n" + radioButton1.Checked.ToString() + " \n" + radioButton2.Checked.ToString() + " \n" + EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt(txtPassword.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + cmYear.Text); } else { try { File.Create(Application.StartupPath + "\\logserver.txt"); File.WriteAllText(Application.StartupPath + "\\logserver.txt", tx_sql.Text.ToString().Trim() + " \n" + radioButton1.Checked.ToString() + " \n" + radioButton2.Checked.ToString() + " \n" + EncryptionClass.Encrypt(txtUserName.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + EncryptionClass.Encrypt(txtPassword.Text, "nanoahmedmohammmadnaelzadf18") + " \n" + cmYear.Text); } catch { } } /////////////////////////////////////////////////////////// string[] namedata; Boolean isinsert = false; if (File.Exists(Application.StartupPath + "\\dataname.txt")) { namedata = File.ReadAllLines(Application.StartupPath + "\\dataname.txt"); if (namedata != null) { for (int i = 0; i < namedata.Length; i++) { if (cmYear.Text == namedata[i]) { isinsert = true; } } ////////////////////////////////////// } if (isinsert == false) { namedata = new string[1]; namedata[0] = cmYear.Text; File.AppendAllLines(Application.StartupPath + "\\dataname.txt", namedata); } } iscontinue = true; FormLogin.yir = cmYear.Text; FormLogin.path_databas = textBox1.Text; FormLogin.connfordata_tayp = connserver + "; database="; this.Close(); }