示例#1
0
        private void BtSave_Click(object sender, EventArgs e)
        {
            //get all values from the form interface.
            var platenum         = txtLic.Text;
            var fname            = txtFirstName.Text;
            var lname            = txtLastName.Text;
            var type             = cbvehicle.SelectedValue;
            var purpose          = cbreason.SelectedValue;
            var items            = cbitems.SelectedValue;
            var userinfo         = txtUser.Text;
            var recordDateTimeIn = DateTime.Now; // Capturing the time stamp from Computer

            // Step 2 create the object from the database
            ctx = new GateInDatabaseEntities();


            if (String.IsNullOrEmpty(lname) || String.IsNullOrEmpty(platenum))
            {//Validating that the Text Box is not empty
                MessageBox.Show("Platenum or Last Name is empty");
            }

            MessageBox.Show($"Name: {fname} {lname} \r\n Plate Number: {platenum} \r\n Car Type: {type}" +
                            $"\r\n Item/s Declared  {items}  Reason for Visit: {purpose}");



            //GateIn record = new GateInTable();
            //table that you are about to store data in
            var record = new GateInTable();


            //Populate the fields in the object
            record.FirstName        = fname;
            record.LastName         = lname;
            record.PlateNum         = platenum;
            record.PurposeID        = (int)purpose;
            record.ItemsToDeclareID = Convert.ToInt32(items);
            record.VehicletypesID   = (int)type;
            record.DateTimeIn       = recordDateTimeIn;



            //Add the record to this table
            //In this "object" in this "Table" in row
            ctx.GateInTables.Add(record);
            ctx.SaveChanges();



            MessageBox.Show("Document has been saved");
        }
示例#2
0
        private void btSubmit_Click(object sender, EventArgs e)
        {
            var ctx = new GateInDatabaseEntities();

            var username = txtUserName.Text;
            var password = txtPassword.Text;



            if (username == "")
            {
                String txtusername = String.Empty;
                MessageBox.Show("The username fields are empty kindly enter the following information required");
            }

            else if (password == "")
            {
                MessageBox.Show("The password fields are empty kindly enter the following information required");
            }

            else
            {
                var userCount = ctx.Users.Count(q => q.Username == username && q.Password == password);



                if (userCount != 1)
                {
                    MessageBox.Show("Invalid creditials");
                }
                else
                {
                    this.Close();
                    //btLogin.Show();
                    MessageBox.Show("Welcome ");
                }
            }



            User usern = new User();
            //MessageBox.Show();
            var showid = usern.Id;

            Select  where ID is 1
            MessageBox.Show("Hello: " + showid);
        }