public static int Company() { int CompanyID = 0; if (GetUserLogInfo.GetMacAddress() == "408D5C3D4380") { CompanyID = 100; // Kamrul-PC } else if (GetUserLogInfo.GetMacAddress() == "408D5C3D42D4") { CompanyID = 101; // Kamrul-PC } else if (GetUserLogInfo.GetMacAddress() == "1C1B0DA84A7E") { CompanyID = 102; // China-PC } else { CompanyID = 420; // Un authorized pc } // int CompanyID = 5; // SERVER // int CompanyID = 29; // Front/Sales PC // int CompanyID = 14; // VAT PC // int CompanyID = 23; // Spears Parts // int CompanyID = 61; // return(CompanyID); }
private void Log_IN() { DateTime now = DateTime.Now; string date = now.ToString("yyyyMMdd"); int today = Convert.ToInt32(date); int start_date = 20170516; int last_date = 20170530; if (start_date > today || last_date < today) { Trial tri = new Trial(); tri.Show(); Hide(); } else { try { string userName = textBoxUserName.Text; userName = userName.Replace("'", "Sonali"); userName = userName.Replace("\"", "Sonali"); userName = userName.Replace("or", "Sonali"); userName = userName.Replace("OR", "Sonali"); userName = userName.Replace("-", "Sonali"); userName = userName.Replace("--", "Sonali"); userName = userName.Replace("=", "Sonali"); userName = userName.Replace("==", "Sonali"); userName = userName.Replace("===", "Sonali"); userName = userName.Replace(" ", "Sonali"); userName = userName.Replace(" ", "Sonali"); userName = userName.Replace(" ", "Sonali"); userName = userName.Replace("*", "Sonali"); string password = textBoxPassword.Text; password = password.Replace(" ", "Sonali"); int Role = 0; int error = 0; loguser = userName; string conStr = ConfigurationManager.ConnectionStrings["PosConString"].ToString(); SqlConnection connection = new SqlConnection(conStr); string query = "SELECT * FROM [User] WHERE UserName = @userName AND Password= @Password"; SqlCommand command = new SqlCommand(query, connection); SqlParameter param = new SqlParameter(); SqlParameter param2 = new SqlParameter(); param.ParameterName = "@userName"; param.Value = userName; param2.ParameterName = "@Password"; param2.Value = password; command.Parameters.Add(param); command.Parameters.Add(param2); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Role = Convert.ToInt32(reader["Role"]); loguserID = Convert.ToInt32(reader["ID"]); error = 1; } loguserRole = Role; connection.Close(); if (error == 0) { MessageBox.Show("User Name or Password incorrect..."); } if (error != 0) { // User Log Info Start string CurrentUser = userName; int Companyid = CompanyID; string ComputerName = GetUserLogInfo.hostName; string MacAddress = GetUserLogInfo.GetMacAddress(); string LocalIPAddress = GetUserLogInfo.GetLocalIPAddress(); // string RealIPAddress = GetUserLogInfo.GetRealIPAddress(); string status = "1"; // InsertUserLog(CurrentUser, Companyid, ComputerName, MacAddress, LocalIPAddress, RealIPAddress, status); InsertUserLog(CurrentUser, Companyid, ComputerName, MacAddress, LocalIPAddress, status); // Without Real IP // User Log Info End MainBody amainbody = new MainBody(); amainbody.Show(); Hide(); } } catch (Exception) { MessageBox.Show("Database Connection Failed..."); } } }