コード例 #1
0
        private void frm_Login_Load(object sender, EventArgs e)
        {
            //Read the connection string from the registry S118
            string      registryConnectionString = "";
            RegistryKey ConnectionString         = Registry.CurrentUser.CreateSubKey("SOFTWARE\\AutomationConnection");

            registryConnectionString = ConnectionString.GetValue("ConnectionForAutomation").ToString();

            try
            {
                if (registryConnectionString == "")
                {
                    MessageBox.Show("The connection to the server is not established, please check the connection parameters with the server.");
                    frm_setServerParameters frm_ssparam = new frm_setServerParameters();
                    frm_ssparam.ShowDialog();

                    btn_enter.Enabled = false;
                }
                else
                {
                    PublicVariable.MainConnectionString = CryptionAlgorithm.DecryptTextUsingUTF8(registryConnectionString);
                }
            }
            catch
            {
                btn_enter.Enabled = false;
                MessageBox.Show("No connection to the server");
            }



            // show date
            System.Globalization.PersianCalendar pc = new System.Globalization.PersianCalendar();
            PublicVariable.TodayDate = string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime((pc.GetYear(DateTime.Now) + "/" + pc.GetMonth(DateTime.Now) + "/" + pc.GetDayOfMonth(DateTime.Now))));
            lbl_date.Text            = PublicVariable.TodayDate;

            // show ip
            string      computerName = System.Environment.MachineName;
            string      IP           = "";
            IPHostEntry ipe          = Dns.GetHostByName(computerName);

            IPAddress[] IpAddress = ipe.AddressList;
            lbl_IP.Text = IpAddress[0].ToString();

            //show time
            timer1_Tick(sender, e);
        }
コード例 #2
0
ファイル: frmLogin.cs プロジェクト: ghorbani77/Accounting
        private void frmLogin_Load(object sender, EventArgs e)
        {
            ///خواندن رشته اتصال از رجیستری
            string      RegisteryConnectionString = "";
            RegistryKey ConnectionString          = Registry.CurrentUser.CreateSubKey("SOFTWARE\\AutomationConnection");

            RegisteryConnectionString = ConnectionString.GetValue("ConnectionForAutomation").ToString();

            try
            {
                if (RegisteryConnectionString == "")
                {
                    MessageBox.Show("ارتباط با سرور برقرار نیست");

                    btn_enter.Enabled = false;
                }
                else
                {
                    PublicVariable.MainConnectionString = CryptionAlgorithm.DecryptTextUsingUTF8(RegisteryConnectionString);
                }
            }
            catch
            {
                btn_enter.Enabled = false;
                MessageBox.Show("ارتباط با سرور برقرار نیست");
            }

            //Show Date
            System.Globalization.PersianCalendar PC = new System.Globalization.PersianCalendar();
            lbl_date.Text            = string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime((PC.GetYear(DateTime.Now) + "/" + PC.GetMonth(DateTime.Now) + "/" + PC.GetDayOfMonth(DateTime.Now))));
            PublicVariable.TodayDate = lbl_date.Text.Trim();


            //Show IP
            string ComputerName = System.Environment.MachineName;

            lblComputername.Text = ComputerName.ToString();
            // string IP = "";
            IPHostEntry ipe = Dns.GetHostByName(ComputerName);

            IPAddress[] IpAdrress = ipe.AddressList;
            lbl_IP.Text = IpAdrress[0].ToString();
            //Show Time

            timer1_Tick(sender, e);
        }