Exemplo n.º 1
0
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            Console.WriteLine(User.FirstName);
            Console.WriteLine(User.UserName);
            Console.WriteLine(User.Password);
            Console.WriteLine(User.Role);

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"INSERT INTO UserTable (FirstName, UserName, Password, Role) VALUES (@FName, @UName, @Pwd, @Role)";

                command.Parameters.AddWithValue("@FName", User.FirstName);
                command.Parameters.AddWithValue("@UName", User.UserName);
                command.Parameters.AddWithValue("@Pwd", User.Password);
                command.Parameters.AddWithValue("@Role", User.Role);
                command.ExecuteNonQuery();
            }

            return(RedirectToPage("/Index"));
        }
Exemplo n.º 2
0
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"INSERT INTO Admin (AdminID, AdminName, AdminLastName, Email, Password) VALUES (@AID, @AName, @ALName, @Email, @PSWD)";

                command.Parameters.AddWithValue("@AID", Admin.AdminID);
                command.Parameters.AddWithValue("@AName", Admin.AdminName);
                command.Parameters.AddWithValue("@ALName", Admin.AdminLastName);
                command.Parameters.AddWithValue("@Email", Admin.Email);
                command.Parameters.AddWithValue("@PSWD", Admin.Password);

                Console.WriteLine(Admin.AdminID);
                Console.WriteLine(Admin.AdminName);
                Console.WriteLine(Admin.AdminLastName);
                Console.WriteLine(Admin.Email);
                Console.WriteLine(Admin.Password);

                command.ExecuteNonQuery();
            }
            return(RedirectToPage("./Index"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Post(string value)
        {
            string          buffer;
            DatabaseConnect dbConnect = new DatabaseConnect();

            User user = new User();

            HttpRequest request = HttpContext.Request;

            Microsoft.AspNetCore.Http.HttpRequestRewindExtensions.EnableBuffering(request);

            using (var sr = new StreamReader(request.Body))
            {
                buffer = sr.ReadToEnd();
            }

            user = JsonConvert.DeserializeObject <User>(buffer);


            bool exist = await dbConnect.User.Verify(user._userName, user._password);


            if (exist == true)
            {
                return(Ok(ModelState));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 4
0
        public IActionResult OnGet(int?Id) //we receive this Id from View.cs
        {
            DatabaseConnect DBCon = new DatabaseConnect();
            SqlConnection   conn  = new SqlConnection(DBCon.DatabaseString());

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT * FROM FileTable WHERE Id = @Id";
                command.Parameters.AddWithValue("@Id", Id);

                var reader = command.ExecuteReader();

                PlayerFileRec = new PlayerFile();
                while (reader.Read())
                {
                    PlayerFileRec.Id         = reader.GetInt32(0);
                    PlayerFileRec.PlayerName = reader.GetString(1); //to display on the html page
                    PlayerFileRec.FileName   = reader.GetString(2); //to display on the html page
                }

                Console.WriteLine("File name : " + PlayerFileRec.FileName);
            }

            return(Page());
        }
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();


            Console.WriteLine(Users.FirstName);
            Console.WriteLine(Users.LastName);
            Console.WriteLine(Users.EmailAddress);
            Console.WriteLine(Users.Password);
            Console.WriteLine(Users.Role);


            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"INSERT INTO Users (FirstName, LastName, EmailAddress, Password, Role) VALUES (@FName, @LName, @EAddress, @Pwd, @Role)";


                command.Parameters.AddWithValue("@FName", Users.FirstName);
                command.Parameters.AddWithValue("@LName", Users.LastName);
                command.Parameters.AddWithValue("@EAddress", Users.EmailAddress);
                command.Parameters.AddWithValue("@Pwd", Users.Password);
                command.Parameters.AddWithValue("@Role", Users.Role);
                command.ExecuteNonQuery();
            }

            return(RedirectToPage("/Login/Login"));
        }
Exemplo n.º 6
0
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();
            SqlConnection   conn         = new SqlConnection(DbConnection);

            conn.Open();

            Console.WriteLine("User ID :" + Users.UserID);
            Console.WriteLine("User First Name : " + Users.FirstName);
            Console.WriteLine("User Last Name : " + Users.LastName);
            Console.WriteLine("User Email Address : " + Users.EmailAddress);
            Console.WriteLine("User Password : "******"User Role : " + Users.Role);


            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = "UPDATE Users SET FirstName=@FName, LastName=@LName, EmailAddress=@EAddress, Password=@PWD, Role=@URole WHERE UserID = @UID";

                command.Parameters.AddWithValue("@UID", Users.UserID);
                command.Parameters.AddWithValue("@FName", Users.FirstName);
                command.Parameters.AddWithValue("@LName", Users.LastName);
                command.Parameters.AddWithValue("@EAddress", Users.EmailAddress);
                command.Parameters.AddWithValue("@PWD", Users.Password);
                command.Parameters.AddWithValue("@URole", Users.Role);

                command.ExecuteNonQuery();
            }
            conn.Close();
            return(RedirectToPage("/User/UserManagement"));
        }
Exemplo n.º 7
0
        public IActionResult OnGet(int?id)
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();
            SqlConnection   conn         = new SqlConnection(DbConnection);

            conn.Open();

            Users = new Users();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = "SELECT * FROM Users WHERE UserID = @UID";

                command.Parameters.AddWithValue("@UID", id);
                Console.WriteLine("User ID : " + id);

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Users.UserID       = reader.GetInt32(0);
                    Users.FirstName    = reader.GetString(1);
                    Users.LastName     = reader.GetString(2);
                    Users.EmailAddress = reader.GetString(3);
                    Users.Password     = reader.GetString(4);
                    Users.Role         = reader.GetString(5);
                }
            }
            return(Page());
        }
Exemplo n.º 8
0
    protected void CreateUser_Click(object sender, EventArgs e)
    {
        DatabaseConnect connectionObject = new DatabaseConnect();
        int             result           = Int32.Parse(connectionObject.userExists(Convert.ToInt64(ID.Text)).ToString());

        if (result != 0)
        {
            string script = "alert(\"User ID is taken" + result + "\");";
            ScriptManager.RegisterStartupScript(this, GetType(),
                                                "ServerControlScript", script, true);
        }
        else
        {
            var    host     = Dns.GetHostEntry(Dns.GetHostName());
            String IPAdress = "";
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    IPAdress = ip.ToString();
                }
            }
            connectionObject.InsertParticipant(Convert.ToInt64(ID.Text), GenderList.Text, UserName.Text, Date.Text, Job.Text, Email.Text, IPAdress, Password.Text);

            Response.Redirect("Login.aspx");
        }
    }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions <DatabaseFields> dbSettings, ILogger <Startup> logger)
        {
            if (DatabaseConnect.HasDatabase(dbSettings.Value))
            {
                logger.LogInformation("Initializing database schema");
                DatabaseConnect.CreateDatabase(dbSettings.Value, env);
            }
            else
            {
                logger.LogWarning("Database credentials are missing. Application will run without connecting to a database. Engagement events will not be persisted");
            }

            app.UseSwagger();
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Orca v1"));
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            if (!env.IsDevelopment())
            {
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        public void OnGet()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT * FROM Customer";

                SqlDataReader reader = command.ExecuteReader(); //SqlDataReader is used to read record from a table

                CustomerRec = new List <Customer>();            //this object of list is created to populate all records from the table

                while (reader.Read())
                {
                    Customer record = new Customer();              //a local var to hold a record temporarily
                    record.Id               = reader.GetInt32(0);  //getting the first field from the table
                    record.CustomerID       = reader.GetString(1); //getting the second field from the table
                    record.CustomerName     = reader.GetString(2); //getting the third field from the table
                    record.CustomerLastName = reader.GetString(3);
                    record.Email            = reader.GetString(4);

                    CustomerRec.Add(record); //adding the single record into the list
                }

                // Call Close when done reading.
                reader.Close();
            }
        }
Exemplo n.º 11
0
        public ModelInvokeResult <ServerPK> Update(string strServerId, Server server)
        {
            ModelInvokeResult <ServerPK> result = new ModelInvokeResult <ServerPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                var parameterObject = server.ToStringObjectDictionary(false);
                parameterObject["OldServerId"] = strServerId;
                /***********************begin 自定义代码*******************/
                /***********************end 自定义代码*********************/
                string sql = BuilderFactory.DefaultBulder().GetSql("Server_Update2", parameterObject);
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = "Server_Update2", ParameterObject = parameterObject, Type = SqlExecuteType.UPDATE
                });
                bool needDatabaseConnect = server.ServerId.StartsWith("Job");
                if (needDatabaseConnect)
                {
                    /***********************begin 自定义代码*******************/
                    DatabaseConnect databaseConnect = new DatabaseConnect
                    {
                        ConnectId             = "Job-" + server.ServerId,
                        ConnectName           = "作业-" + server.ServerName,
                        Provider              = GlobalManager.DIKey_00015_SqlServer2005,
                        ServerName            = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(server.IpAddress),
                        DatabaseName          = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Host_Database),
                        UserCode              = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Database_User),
                        UserPassword          = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.Job_Database_Password),
                        IBatisMapId           = "SqlMap-Job-" + server.ServerId,
                        IbatisConfigFileRefer = GlobalManager.IbatisConfigFileRefer,
                        IbatisConfigFileValue = e0571.web.core.Service.ServiceManager.Instance.CryptoService.StringCrypto.Encrypt(GlobalManager.IbatisConfigFileValue_Job)
                    };

                    var parameterObject2 = databaseConnect.ToStringObjectDictionary(false);
                    parameterObject2["OldConnectId"] = "Job-" + strServerId;

                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = "DatabaseConnect_Update2", ParameterObject = parameterObject2, Type = SqlExecuteType.UPDATE
                    });
                    /***********************end 自定义代码*********************/
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new ServerPK {
                    ServerId = strServerId
                };
                if (needDatabaseConnect)
                {
                    //注册数据连接ase
                    GlobalManager.RegisterDatabaseConnections();
                }
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public IActionResult OnGet(int?id)
        {
            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = "SELECT * FROM Customer WHERE Id = @ID";
                command.Parameters.AddWithValue("@ID", id);

                SqlDataReader reader = command.ExecuteReader();
                CustomerRec = new Customer();
                while (reader.Read())
                {
                    CustomerRec.Id               = reader.GetInt32(0);
                    CustomerRec.CustomerID       = reader.GetString(1);
                    CustomerRec.CustomerName     = reader.GetString(2);
                    CustomerRec.CustomerLastName = reader.GetString(3);
                    CustomerRec.Email            = reader.GetString(4);
                }
            }

            conn.Close();

            return(Page());
        }
Exemplo n.º 13
0
        public IActionResult OnGet(int?id)
        {
            DatabaseConnect DbCon = new DatabaseConnect();
            SqlConnection   conn  = new SqlConnection(DbCon.DatabaseString());

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = "SELECT * FROM PlayerTable WHERE Id = @ID";
                command.Parameters.AddWithValue("@ID", id);

                SqlDataReader reader = command.ExecuteReader();
                PlayerRec = new Player();
                while (reader.Read())
                {
                    PlayerRec.Id              = reader.GetInt32(0);
                    PlayerRec.PlayerID        = reader.GetString(1);
                    PlayerRec.PlayerFirstName = reader.GetString(2);
                    PlayerRec.PlayerSurname   = reader.GetString(3);
                    PlayerRec.PlayerAge       = reader.GetInt32(4);
                }
            }

            conn.Close();

            return(Page());
        }
Exemplo n.º 14
0
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();
            SqlConnection   conn         = new SqlConnection(DbConnection);

            conn.Open();

            Console.WriteLine("Product ID : " + Products.ProductID);
            Console.WriteLine("Product Name : " + Products.ProductName);
            Console.WriteLine("Product Price : " + Products.ProductPrice);
            Console.WriteLine("Product Category : " + Products.ProductCategory);
            Console.WriteLine("Product Description : " + Products.ProductDescription);

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = "UPDATE Products SET ProductName=@PName, ProductPrice=@PPrice, ProductCategory=@PCategory, ProductDescription=@PDescription WHERE ProductID = @PID";
                command.Parameters.AddWithValue("@PID", Products.ProductID);
                command.Parameters.AddWithValue("@PName", Products.ProductName);
                command.Parameters.AddWithValue("@PPrice", Products.ProductPrice);
                command.Parameters.AddWithValue("@PCategory", Products.ProductCategory);
                command.Parameters.AddWithValue("@PDescription", Products.ProductDescription);


                command.ExecuteNonQuery();
            }
            conn.Close();
            return(RedirectToPage("/Product/ProductIndex"));
        }
Exemplo n.º 15
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            DatabaseConnect dbstring     = new DatabaseConnect();     //creating an object from the class
            string          DbConnection = dbstring.DatabaseString(); //calling the method from the class

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            Console.WriteLine(User.UserName);
            Console.WriteLine(User.Password);


            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT FirstName, UserName, UserRole FROM UserTable WHERE UserName = @UName AND UserPassword = @Pwd";

                command.Parameters.AddWithValue("@UName", User.UserName);
                command.Parameters.AddWithValue("@Pwd", User.Password);

                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    User.FirstName = reader.GetString(0);
                    User.UserName  = reader.GetString(1);
                    User.Role      = reader.GetString(2);
                }
            }

            if (!string.IsNullOrEmpty(User.FirstName))
            {
                SessionID = HttpContext.Session.Id;
                HttpContext.Session.SetString("sessionID", SessionID);
                HttpContext.Session.SetString("username", User.UserName);
                HttpContext.Session.SetString("fname", User.FirstName);

                if (User.Role == "User")
                {
                    return(RedirectToPage("/UserPages/UserIndex"));
                }
                else
                {
                    return(RedirectToPage("/AdminPages/AdminIndex"));
                }
            }
            else
            {
                Message = "Invalid Username and Password!";
                return(Page());
            }
        }
Exemplo n.º 16
0
        public IActionResult OnGet(int?id)
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();
            SqlConnection   conn         = new SqlConnection(DbConnection);

            conn.Open();

            Products = new Products();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT * FROM Products WHERE ProductID = @PID";
                command.Parameters.AddWithValue("@PID", id);
                Console.WriteLine("Product ID : " + id);

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Products.ProductID          = reader.GetInt32(0);
                    Products.ProductName        = reader.GetString(1);
                    Products.ProductPrice       = reader.GetString(2);
                    Products.ProductCategory    = reader.GetString(3);
                    Products.ProductDescription = reader.GetString(4);
                }
            }
            conn.Close();
            return(Page());
        }
Exemplo n.º 17
0
        public IActionResult OnPost()
        {
            var FileToUpload = Path.Combine(_env.WebRootPath, "Files", File.FileName);//this variable consists of file path

            Console.WriteLine("File Name : " + FileToUpload);

            using (var FStream = new FileStream(FileToUpload, FileMode.Create))
            {
                File.CopyTo(FStream);//copy the file into FStream variable
            }

            DatabaseConnect DBCon    = new DatabaseConnect();
            string          DbString = DBCon.DatabaseString();
            SqlConnection   conn     = new SqlConnection(DbString);

            conn.Open();

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"INSERT StudentFile (StudentName, FileName) VALUES (@StdName, @FName)";
                command.Parameters.AddWithValue("@StdName", FileRec.Name);
                command.Parameters.AddWithValue("@FName", File.FileName);
                Console.WriteLine("File name : " + FileRec.Name);
                Console.WriteLine("File name : " + File.FileName);
                command.ExecuteNonQuery();
            }

            return(RedirectToPage("/index"));
        }
Exemplo n.º 18
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            DatabaseConnect dbConn   = new DatabaseConnect();
            string          DbString = dbConn.DatabaseString();

            var connStringBuilder = new SqliteConnectionStringBuilder();

            connStringBuilder.DataSource = DbString;

            var conn = new SqliteConnection(connStringBuilder.ConnectionString);

            conn.Open();

            var command = conn.CreateCommand();

            Console.WriteLine(User.UserName);
            Console.WriteLine(User.Password);

            command.CommandText = @"SELECT FirstName, UserName, UserRole FROM UserTable WHERE UserName = @UName AND UserPassword = @Pwd";

            command.Parameters.AddWithValue("@UName", User.UserName);
            command.Parameters.AddWithValue("@Pwd", User.Password);

            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                User.FirstName = reader.GetString(0);
                User.UserName  = reader.GetString(1);
                User.Role      = reader.GetString(2);
            }

            if (!string.IsNullOrEmpty(User.FirstName))
            {
                SessionID = HttpContext.Session.Id;
                HttpContext.Session.SetString("sessionID", SessionID);
                HttpContext.Session.SetString("username", User.UserName);
                HttpContext.Session.SetString("fname", User.FirstName);

                if (User.Role == "User")
                {
                    return(RedirectToPage("/UserPages/UserIndex"));
                }
                else
                {
                    return(RedirectToPage("/AdminPages/AdminIndex"));
                }
            }
            else
            {
                Message = "Invalid Username and Password!";
                return(Page());
            }
        }
Exemplo n.º 19
0
        private void StoreInDatabase(StudentEvent studentEvent)
        {
            _logger.LogInformation(studentEvent.ToString());
            DatabaseConnect connect = new DatabaseConnect();

            connect.StoreStudentToDatabase(studentEvent);
            connect.StoreEventToDatabase(studentEvent);
        }
Exemplo n.º 20
0
        public async Task <string> GetRecipes(string search)
        {
            DatabaseConnect Database = new DatabaseConnect();

            List <Recipe> recipes = await Database.Recipe.GetListAsync(search);

            return(JsonConvert.SerializeObject(recipes));
        }
Exemplo n.º 21
0
Arquivo: M12.cs Projeto: TPF-TUW/MDS
        private void XtraForm1_Load(object sender, EventArgs e)
        {
            //***** SET CONNECT DB ********
            if (this.ConnectionString != null)
            {
                if (this.ConnectionString != "")
                {
                    CONNECT_STRING = this.ConnectionString;
                }
            }

            this.DBC = new DatabaseConnect(CONNECT_STRING);

            if (this.DBC.chkCONNECTION_STING() == false)
            {
                this.DBC.setCONNECTION_STRING_INIFILE();
                if (this.DBC.chkCONNECTION_STING() == false)
                {
                    return;
                }
            }
            new ObjDE.setDatabase(this.DBC);
            //*****************************

            StringBuilder sbSQL = new StringBuilder();

            sbSQL.Append("SELECT TOP (1) ReadWriteStatus FROM FunctionAccess WHERE (OIDUser = '******') AND(FunctionNo = 'M12') ");
            int chkReadWrite = this.DBC.DBQuery(sbSQL).getInt();

            if (chkReadWrite == 0)
            {
                ribbonPageGroup1.Visible = false;
            }

            sbSQL.Clear();
            sbSQL.Append("SELECT FullName, OIDUSER FROM Users ORDER BY OIDUSER ");
            new ObjDE.setGridLookUpEdit(glueCREATE, sbSQL, "FullName", "OIDUSER").getData();
            new ObjDE.setGridLookUpEdit(glueUPDATE, sbSQL, "FullName", "OIDUSER").getData();

            glueCREATE.EditValue = UserLogin.OIDUser;
            glueUPDATE.EditValue = UserLogin.OIDUser;

            //glueCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
            //glueCode.Properties.AcceptEditorTextAsNewValue = DevExpress.Utils.DefaultBoolean.True;

            StringBuilder sbTYPE = new StringBuilder();

            sbTYPE.Append("SELECT Name AS VendorType, No AS ID FROM ENUMTYPE WHERE (Module = N'Vendor') ORDER BY No ");
            new ObjDE.setGridLookUpEdit(glueVendor, sbTYPE, "VendorType", "ID").getData();
            glueVendor.Properties.View.PopulateColumns(glueVendor.Properties.DataSource);
            glueVendor.Properties.View.Columns["ID"].Visible = false;
            //glueVendor.Properties.DataSource = vendorTypes;
            //glueVendor.Properties.DisplayMember = "NAME";
            //glueVendor.Properties.ValueMember = "ID";

            bbiNew.PerformClick();
        }
Exemplo n.º 22
0
        // Checks if the email of the contractor has inputted his hours for the month
        public Boolean ValidEmail(string email)
        {
            var db = new DatabaseConnect().ConnectionString();

            int contractID = 0;
            int empID      = 0;


            using (SqlConnection con = new SqlConnection(db))
            {
                string sql1 = "SELECT ContractorID FROM Contractor WHERE Email = '" + email + "'";

                using (SqlCommand cmd = new SqlCommand(sql1, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        contractID = reader.GetInt32(0);
                    }
                    reader.Close();
                    con.Close();
                }

                string sql2 = "SELECT ContractId FROM Contract WHERE ContractorId = " + empID + "";

                using (SqlCommand cmd = new SqlCommand(sql2, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        contractID = reader.GetInt32(0);
                    }
                    reader.Close();
                    con.Close();
                }

                string sql3 = "SELECT currentMonth FROM EmployeeHour WHERE ContractId = " + contractID + " AND Year = " + DateTime.Now.Year + " And Month =" + DateTime.Now.Month + "";

                using (SqlCommand cmd = new SqlCommand(sql3, con))
                {
                    con.Open();

                    Object obj = cmd.ExecuteScalar();
                    con.Close();

                    // if it exists
                    if (obj == null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 23
0
 public M07_01(DatabaseConnect DBase, int UserID, string TypeID, string TypeName, string CodeID)
 {
     InitializeComponent();
     this.DB        = DBase;
     this._UserID   = UserID;
     this._TypeID   = TypeID;
     this._TypeName = TypeName;
     this._CodeID   = CodeID;
 }
Exemplo n.º 24
0
 public M08_01(DatabaseConnect DBase, int UserID, string BranchID, string BranchName, string LineID)
 {
     InitializeComponent();
     this.DB          = DBase;
     this._UserID     = UserID;
     this._BranchID   = BranchID;
     this._BranchName = BranchName;
     this._LineID     = LineID;
 }
Exemplo n.º 25
0
Arquivo: F04.cs Projeto: TPF-TUW/MDS
        private void XtraForm1_Load(object sender, EventArgs e)
        {//***** SET CONNECT DB ********
            if (this.ConnectionString != null)
            {
                if (this.ConnectionString != "")
                {
                    CONNECT_STRING = this.ConnectionString;
                }
            }

            this.DBC = new DatabaseConnect(CONNECT_STRING);

            if (this.DBC.chkCONNECTION_STING() == false)
            {
                this.DBC.setCONNECTION_STRING_INIFILE();
                if (this.DBC.chkCONNECTION_STING() == false)
                {
                    return;
                }
            }
            new ObjDE.setDatabase(this.DBC);
            //*****************************

            StringBuilder sbSQL = new StringBuilder();

            sbSQL.Append("SELECT TOP (1) ReadWriteStatus FROM FunctionAccess WHERE (OIDUser = '******') AND(FunctionNo = 'F03') ");
            int chkReadWrite = this.DBC.DBQuery(sbSQL).getInt();

            if (chkReadWrite == 0)
            {
                ribbonPageGroup1.Visible = false;
            }

            sbSQL.Clear();
            sbSQL.Append("SELECT FullName, OIDUSER FROM Users ORDER BY OIDUSER ");
            new ObjDE.setGridLookUpEdit(glueCREATE, sbSQL, "FullName", "OIDUSER").getData();

            glueCREATE.EditValue = UserLogin.OIDUser;

            sbGROUP.Append("SELECT '0' AS [ID], 'Master' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '1' AS [ID], 'Development' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '2' AS [ID], 'MPS : Master Production Schedule' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '3' AS [ID], 'MRP : Material Resource Planning' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '4' AS [ID], 'Shipment' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '5' AS [ID], 'EXIMs' AS [Group Function] ");
            sbGROUP.Append("UNION ALL ");
            sbGROUP.Append("SELECT '6' AS [ID], 'Administrator' AS [Group Function] ");

            NewData();
            LoadData();
        }
Exemplo n.º 26
0
        public IActionResult OnPost()
        {
            DatabaseConnect dbstring     = new DatabaseConnect();
            string          DbConnection = dbstring.DatabaseString();

            Console.WriteLine(DbConnection);
            SqlConnection conn = new SqlConnection(DbConnection);

            conn.Open();

            Console.WriteLine(Login.Username);
            Console.WriteLine(Login.Password);

            using (SqlCommand command = new SqlCommand())
            {
                command.Connection  = conn;
                command.CommandText = @"SELECT FirstName, Username, User_Type FROM Logins WHERE Username = @Username AND Password = @Password";

                command.Parameters.AddWithValue("@Username", Login.Username);
                command.Parameters.AddWithValue("@Password", Login.Password);

                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Login.FirstName = reader.GetString(0);
                    Login.Username  = reader.GetString(1);
                    Login.User_Type = reader.GetString(2);
                }
            }
            if (!string.IsNullOrEmpty(Login.FirstName))
            {
                SessionID = HttpContext.Session.Id;
                HttpContext.Session.SetString("SessionID", SessionID);
                HttpContext.Session.SetString("username", Login.Username);
                HttpContext.Session.SetString("fname", Login.FirstName);

                if (Login.User_Type == "Student")
                {
                    return(RedirectToPage("/Student/StudentIndex"));
                }
                if (Login.User_Type == "Teacher")
                {
                    return(RedirectToPage("/Login/Create"));
                }
                else
                {
                    return(RedirectToPage("/Admin/AdminIndex"));
                }
            }
            else
            {
                Message = "Invalid Username or Password!";
                return(Page());
            }
        }
Exemplo n.º 27
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            connect   = new DatabaseConnect();
            eventData = connect.EventData();

            for (int i = 0; i < eventData.Count; i++)
            {
                cmbEvents.Items.Add(eventData[i][1]);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// This method Creates and instans of the ingredient object,
        /// it calls method from diffrent classe to attempts to intrepret and edit the names to become more clear.
        /// </summary>
        /// <param name="ind">The raw ingrdient string with no editing or crossrefresing done</param>
        /// <param name="fatalError">A bool which is triggered if the ingredient is determined uninterpretable</param>
        /// <param name="dbConnect">Instace of the database used to save and edit the database</param>
        /// <param name="functionality">A instance of a classe which contains many of the nessesary funtionalitys for the method</param>
        /// <returns>Return a new instance</returns>
        private Ingredient CreateIngriedient(string ind, out bool fatalError, DatabaseConnect dbConnect, AssistingClasses functionality)
        {
            float  amount = functionality.getDetermin().DeterminAmount(ind);
            String unit   = functionality.getDetermin().DeterminUnit(ind);
            String name   = functionality.getDetermin().DeterminName(ind).Trim();

            name = nameEditing_Evalution(name, out fatalError, dbConnect, functionality);

            return(new Ingredient(name.Trim(), unit, amount));
        }
Exemplo n.º 29
0
        private void openDatabaseWindow()
        {
            var databaseConnector = new DatabaseConnect();

            databaseConnector.TopMost = true;
            databaseConnector.Show();
            this.EnableDisable(false);
            databaseConnector.onConnect  += (sender, e) => SetInitialConnectionStatus(e);
            databaseConnector.FormClosed += (sender, e) => this.EnableDisable(true);
        }
Exemplo n.º 30
0
        public IActionResult OnGet()
        {
            UserName  = HttpContext.Session.GetString(SessionKeyName1);
            UserEmail = HttpContext.Session.GetString(SessionKeyName2);
            SessionID = HttpContext.Session.GetString(SessionKeyName3);


            Console.WriteLine("Current session: " + UserName);
            Console.WriteLine("Current session ID: " + SessionID);

            if (string.IsNullOrEmpty(UserName))
            {
                Console.WriteLine("Session ended");
                return(RedirectToPage("/Users/UserLogin"));
            }
            else
            {
                var             connectionStringBuilder = new SqliteConnectionStringBuilder();
                DatabaseConnect DBCon = new DatabaseConnect();
                string          dbStringConnection = DBCon.DBStringConnection(); //getting the connection string from this class


                connectionStringBuilder.DataSource = dbStringConnection;
                var connection = new SqliteConnection(connectionStringBuilder.ConnectionString);

                connection.Open();

                var selectCmd = connection.CreateCommand();
                selectCmd.CommandText = @"SELECT PicName FROM Picture WHERE Email=$email";
                selectCmd.Parameters.AddWithValue("$email", UserEmail);

                var reader   = selectCmd.ExecuteReader();
                var fileName = "";

                while (reader.Read())
                {
                    fileName = reader.GetString(0);
                }

                if (string.IsNullOrEmpty(fileName))
                {
                    pathPicture = "DefaulPic.jpeg";
                    Console.WriteLine("Default pic : " + pathPicture);
                    return(Page());
                }

                pathPicture = fileName;

                Console.WriteLine("File name is : " + fileName);
                pathPicture = fileName;

                return(Page());
            }
        }