public static string Decrypt(string textToEncrypt)
    {
        string temp;

         #if UNITY_WINRT && !UNITY_EDITOR
        temp = LegacySystem.IO.Decrypt(textToEncrypt)
        #else
        temp = SecurityClass.Decrypt(textToEncrypt);
        #endif
               return(temp);
    }
Exemple #2
0
 private void CashRecord()
 {
     using (var dbContext = new UnitOfWork())
     {
         var user = dbContext.UserRepository.GetById(UserId);
         txtUserName.Text = SecurityClass.Decrypt(user.UserName);
         txtFullName.Text = user.FullName;
         txtTell.Text     = user.Tell;
         txtMobile.Text   = user.Mobile;
         txtAddress.Text  = user.Address;
     }
 }
Exemple #3
0
        private void LoginPage_Load(object sender, EventArgs e)
        {
            var isRemember = Settings.Default.IsRemember;

            if (isRemember != "true")
            {
                chkRemember.Checked = false;
            }
            else
            {
                var userName = SecurityClass.Decrypt(Settings.Default.UserName);
                var password = Settings.Default.Password;

                txtUsername.Text    = userName;
                txtPassword.Text    = SecurityClass.Decrypt(password);
                chkRemember.Checked = true;
            }
        }
Exemple #4
0
        private void log_Load(object sender, EventArgs e)
        {
            try
            {
                var SkinPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                SkinPath = SkinPath + @"\SkinName.txt";
                if (File.Exists(SkinPath))
                {
                    string name = File.ReadAllText(SkinPath);
                    UserLookAndFeel.Default.SkinName = name;
                    skinname = name;
                    changeColor(name);
                }
            }
            catch
            { }


            ExistDataBase = CheckDatabase("Project_DB");
            var CoonctionPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var Coonction     = CoonctionPath + "\\POSConnection.txt";

            if (File.Exists(Coonction))
            {
                StreamReader SR = new StreamReader(Coonction);

                string[] Setting = SR.ReadToEnd().Split(new string[] { "#" }, StringSplitOptions.None);

                if (!string.IsNullOrEmpty(Setting[0]) && !string.IsNullOrEmpty(Setting[1]) && !string.IsNullOrEmpty(Setting[2]))
                {
                    DataBaseConnection.ISLocal    = false;
                    DataBaseConnection.ServerName = Setting[0];
                    DataBaseConnection.UserName   = Setting[1];
                    DataBaseConnection.Password   = Setting[2];
                    ExistDataBase = true;
                }
                else
                {
                    DataBaseConnection.ISLocal = true;
                }
                SR.Close();
            }
            else
            {
                DataBaseConnection.ISLocal = true;
            }

            bool servicesRun = false;

            scServices = ServiceController.GetServices();

            foreach (ServiceController scTemp in scServices)
            {
                if (scTemp.ServiceName == "MSSQLSERVER" || scTemp.ServiceName == "SQLEXPRESS")
                {
                    if (scTemp.ServiceName == "MSSQLSERVER")
                    {
                        sc = new ServiceController("MSSQLSERVER");
                    }
                    else if (scTemp.ServiceName == "SQLEXPRESS")
                    {
                        sc = new ServiceController("SQLEXPRESS");
                    }
                    if (sc.Status == ServiceControllerStatus.Stopped)
                    {
                        try
                        {
                            sc.Start();
                            while (sc.Status == ServiceControllerStatus.Stopped)
                            {
                                Thread.Sleep(1000);
                                sc.Refresh();
                            }
                        }
                        catch (Exception E)
                        {
                            XtraMessageBox.Show(E.Message + "هناك مشكلة فى الاتصال بقاعدة البيانات يرجى التواصل مع المطور");
                            Application.Exit();
                        }
                    }
                    else if (sc.Status == ServiceControllerStatus.Running)
                    {
                        servicesRun = true;
                        break;
                    }
                }
            }

            if (servicesRun == true)
            {
                Process[] pname = Process.GetProcessesByName("POSProject");
                if (pname.Length > 1)
                {
                    XtraMessageBox.Show("فى نسخة تانى مفتوحة من البرنامج لو مش عارف تقفلها رستر الجهاز ");

                    foreach (Process item in Process.GetProcessesByName("ITI_Project"))
                    {
                        item.Kill();
                    }
                }
                else
                {
                    Count = 0;
                    try
                    {
                        DateTime StartDate = DateTime.Now.Date;
                        String[] Dates     = new string[2];


                        if (ExistDataBase)
                        {
                            try
                            {
                                Company_Info_Table ob = BussinesObj.SelectCompanyInfo();


                                PictPath = ob.Company_Logo;
                                if (File.Exists(PictPath))
                                {
                                    pictureEdit1.Image = Image.FromFile(PictPath);
                                }
                                else
                                {
                                    pictureEdit1.Image = ITI_Project.Properties.Resources.cashier;
                                }
                            }
                            catch (Exception E)
                            {
                            }


                            var    roamingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                            var    filePath         = roamingDirectory + "\\POSProject.txt";
                            byte[] ascii            = Encoding.ASCII.GetBytes(BIOSserNo);
                            byte[] ascii2           = Encoding.ASCII.GetBytes(BoardProductId);

                            foreach (Byte b in ascii)
                            {
                                TotalACAddress = TotalACAddress + int.Parse(b.ToString());
                            }
                            foreach (Byte b in ascii2)
                            {
                                TotalBoardProductId = TotalBoardProductId + int.Parse(b.ToString());
                            }



                            var TrialLicence     = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                            var TrialLicencePath = TrialLicence + "\\Trial2.txt";


                            if (File.Exists(TrialLicencePath))
                            {
                                simpleButton2.Enabled = false;
                                this.Height           = 518;

                                StreamReader SR         = new StreamReader(TrialLicencePath);
                                String       DataResult = SR.ReadToEnd();
                                try
                                {
                                    DateTime Date   = DateTime.Parse(SecurityClass.Decrypt(DataResult, "PosSystemEncraptionKey"));
                                    int      result = DateTime.Compare(Date, DateTime.Now);

                                    if (result <= 0)
                                    {
                                        txtusername.Enabled   = true;
                                        txtpassword.Enabled   = true;
                                        simpleButton1.Enabled = true;
                                        checkEdit1.Enabled    = true;
                                    }
                                    else
                                    {
                                        txtusername.Enabled   = false;
                                        txtpassword.Enabled   = false;
                                        simpleButton1.Enabled = false;
                                        checkEdit1.Enabled    = false;
                                    }
                                }
                                catch { }
                            }
                            else
                            {
                                simpleButton2.Enabled = true;
                                this.Height           = 600;
                            }
                        }

                        else
                        {
                            /// attach database
                            ///

                            try
                            {
                                string FileName = Path.Combine(Path.GetFullPath(@"DataBase\"));

                                SqlConnection conn = new SqlConnection("Server=.;Data Source=;Integrated Security=SSPI");
                                SqlCommand    cmd  = new SqlCommand("", conn);


                                cmd.CommandText = "CREATE DATABASE Project_DB ON " +
                                                  "( FILENAME =  '" + FileName + "Project_DB.mdf' )," +
                                                  "( FILENAME ='" + FileName + "Project_DB_log.ldf')" +
                                                  "FOR ATTACH";

                                conn.Open();
                                cmd.ExecuteNonQuery();
                                cmd.Dispose();
                                conn.Close();
                                if (XtraMessageBox.Show(" تم تهيئة قواعد البيانات الخاصة بالنظام يرجى تشغيل النظام مرة اخرى") == DialogResult.OK)
                                {
                                    this.Close();
                                }
                            }
                            catch (Exception E)
                            {
                                if (E.Message.Contains("DataBase\\Project_DB.mdf\" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.\r\nCould not open File Control Bank (FCB) for invalid file ID 2 in database 'Project_DB'. Verify the file location. Execute DBCC CHECKDB.\r\nCould not open new database 'Project_DB'. CREATE DATABASE is aborted."))
                                {
                                    XtraMessageBox.Show("ملف قواعد البيانات مضغوط يرجا فك الضغط والمحاولة لاحقا");
                                    Application.Exit();
                                }
                                else
                                {
                                    // XtraMessageBox.Show(E.Message);\
                                }
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        if (E.Message == "Object reference not set to an instance of an object.")
                        {
                        }
                        else if (E.Message == "Salt is not at least eight bytes.")
                        {
                        }
                        else
                        {
                            //  XtraMessageBox.Show(E.Message);
                        }
                    }
                }
            }
        }