Esempio n. 1
0
        public override Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            string dateString      = FullDate.GetValue(dc.State);
            string dateShortString = dateString.Substring(0, 8);

            if (this.DateShort != null)
            {
                dc.State.SetValue(this.DateShort.GetValue(dc.State), dateShortString);
            }
            return(dc.EndDialogAsync(result: dateShortString, cancellationToken: cancellationToken));
        }
Esempio n. 2
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            //Remove single & double quotes which cause sql troubles
            foreach (Control c in this.Controls)
            {
                if (c is TextBox || c is ComboBox || c is RichTextBox)
                {
                    c.Text = c.Text.Replace("'", ""); c.Text = c.Text.Replace("\"", "");
                }
            }

            //Declare MemID based on Input Type
            if (cvar.InsertID && txtMemID.Text == "")
            {
                MemID = cvar.MemID; txtMemID.Text = MemID;
            }                                                                                        // If input from outside.
            else if (txtMemID.Text == "")
            {
                goto End;                           // If Form opened anew.
            }
            else
            {
                MemID = txtMemID.Text;  // If Value entered in textbox.
            }
            //Access Database for Details
            string       sqlMemD = string.Format("SELECT * FROM Member WHERE MemberID = '{0}'", MemID);
            OleDbCommand cmdMemD = new OleDbCommand(sqlMemD, db.con); if (db.con.State.Equals(ConnectionState.Closed))
            {
                db.con.Open();
            }
            OleDbDataReader drMemD = cmdMemD.ExecuteReader();

            if (drMemD.Read())
            {
                txtMemID.Enabled = false; MakeWide(); //Make the form wider.

                txtFName.Text    = drMemD["FName"].ToString();
                txtLName.Text    = drMemD["LName"].ToString();
                txtAddr.Text     = drMemD["Address"].ToString();
                txtEmail.Text    = drMemD["Email"].ToString();
                txtGuardian.Text = drMemD["Guardian"].ToString();
                txtNIC.Text      = drMemD["NIC"].ToString();
                txtTP.Text       = drMemD["TP"].ToString();
                txtWork.Text     = drMemD["MWork"].ToString();
                lblStatus.Text   = drMemD["MStatus"].ToString();
                Fine             = double.Parse(drMemD["Fine"].ToString());
                lblFine.Text     = Fine.ToString() + "/-";
                lblRenew.Text    = drMemD["Renewed"].ToString();
                Popul p = new Popul();
                TimesBorrow = int.Parse(drMemD["TimesBorrow"].ToString());

                if (Fine == 0)
                {
                    btnFine.Enabled = false;
                }
                else
                {
                    btnFine.Enabled = true;
                }


                DateTime now = DateTime.Today;
                DateTime Dob = DateTime.Parse(drMemD["DateOfBirth"].ToString());
                int      age = now.Year - Dob.Year; if (Dob > now.AddYears(-age))
                {
                    age--;
                }
                lblAge.Text = age.ToString();

                MType = drMemD["MType"].ToString();
                if (MType == "Child")
                {
                    cboxType.SelectedIndex = 0; lblLLg.Visible = txtGuardian.Visible = true; lblLLNic.Text = "Guardian's NIC";
                }
                else if (MType == "Adult")
                {
                    cboxType.SelectedIndex = 1; lblLLg.Visible = txtGuardian.Visible = false; lblLLNic.Text = "NIC Number"; cboxType.Enabled = false;
                }

                if (lblStatus.Text == "Blocked")
                {
                    btnBlack.Text = "Remove from Blacklist";
                }
                else
                {
                    btnBlack.Text = "Add to Blacklist";
                }

                //Split & Use Date of Birth
                string   Fulldob  = drMemD["DateOfBirth"].ToString();
                string[] DoBSpace = Fulldob.Split(' ');     // Split Date from Time
                string[] DoBSlash = DoBSpace[0].Split('/'); // SpilitDate components

                txtDobMon.Text = DoBSlash[0]; txtDobDate.Text = DoBSlash[1]; txtDobYear.Text = DoBSlash[2];

                //Split & Use Date Joined
                DateJ    = DateTime.Parse(drMemD["DateJoined"].ToString());
                FullDate = DateJ.ToString();
                string[] DateSpace = FullDate.Split(' ');     // Split Date from Time
                string[] DateSlash = DateSpace[0].Split('/'); // SpilitDate components

                lblDate.Text = DateSlash[1] + "-" + DateSlash[0] + "-" + DateSlash[2];

                // To Retrive BookIDs

                string       sqlBookID = string.Format("SELECT BookID FROM LendStatus WHERE MemberID = '{0}'", MemID);
                OleDbCommand cmdBookID = new OleDbCommand(sqlBookID, db.con); OleDbDataReader drBookID = cmdBookID.ExecuteReader();

                while (drBookID.Read()) // For Each bookID
                {
                    string BookID = drBookID["BookID"].ToString();

                    string       sqlBook = string.Format("SELECT TitleID FROM Book WHERE BookID = '{0}'", BookID); //Get TitleID from BookID
                    OleDbCommand cmdBook = new OleDbCommand(sqlBook, db.con); OleDbDataReader drBook = cmdBook.ExecuteReader();

                    if (drBook.Read())
                    {
                        string TitleID = drBook["TitleID"].ToString();

                        string       sqlTitle = string.Format("SELECT BTitle, Author, Genre FROM Title WHERE TitleID = '{0}'", TitleID); // Get Title info from TitleID
                        OleDbCommand cmdTitle = new OleDbCommand(sqlTitle, db.con); OleDbDataReader drTitle = cmdTitle.ExecuteReader();

                        if (drTitle.Read())
                        {
                            lboxBookID.Items.Add(BookID); lboxTitle.Items.Add(drTitle["BTitle"].ToString()); lboxAuthor.Items.Add(drTitle["Author"].ToString()); lboxGenre.Items.Add(drTitle["Genre"].ToString());
                        }
                    }
                }

                //To Get last Check In

                string       sqlCheckIn = string.Format("SELECT Max(CDate) as MaxCheckIn FROM CheckInOut WHERE MemberID = '{0}' AND EVENT = 'In' GROUP BY MemberID, Event", MemID);
                OleDbCommand cmdCheckIn = new OleDbCommand(sqlCheckIn, db.con); OleDbDataReader drCheckIn = cmdCheckIn.ExecuteReader();

                if (drCheckIn.Read() & drCheckIn.HasRows)
                {
                    DateTime CheckIn = DateTime.Parse(drCheckIn["MaxCheckIn"].ToString()); lblCheckIn.Text = CheckIn.ToString("dd-MM-yyyy");
                }



                //Calculate Recent Star Points Via method & Display
                Popul star = new Popul();
                fullStars     = star.MemCalc(MemID, false);
                Stars         = double.Parse(Math.Round(decimal.Parse(fullStars.ToString()), 2).ToString());
                lblStars.Text = Stars.ToString();

                btnGet.Enabled = false;
            }
            else
            {
                MessageBox.Show("MemberID does not match with any of the members. Try again", "Invalid MemberID", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            cvar.MemID = ""; cvar.InsertID = false;
            if (db.con.State.Equals(ConnectionState.Open))
            {
                db.con.Close();
            }


            End : if (db.con.State.Equals(ConnectionState.Open))
            {
                db.con.Close();
            }
        }