示例#1
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (DoB.GetValueOrDefault() > DateTime.Now)
     {
         yield return(new ValidationResult("Születési idő nem lehet a jövőben"));
     }
 }
示例#2
0
        public int getAge()
        {
            int now       = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
            int chef_bday = int.Parse(DoB.ToString("yyyyMMdd"));

            return((now - chef_bday) / 10000);
        }
示例#3
0
        public void Register()
        {
            Name.SendKeys("Test User");
            DoB.SendKeys("11/11/11");
            Address.SendKeys("125 King Street, Auckland");
            Contact.SendKeys("+64100200300");
            Submit.Click();
            commonLib cl = new commonLib();

            cl.popup(this.driver);
        }
示例#4
0
 public string GetDateOfBirth()
 {
     return(DoB.ToString("yyyy/MM/dd"));
 }
 public override string ToString()
 {
     return($"{ID} {Name} {DoB.ToShortDateString()} {Address} {Email} {Dept}");
 }
示例#6
0
        public FrmPhong(string Khu, string MaPhong)
        {
            InitializeComponent();
            cmbKhu.Text          = Khu.Trim();
            cmbKhu.Enabled       = false;
            cmbPhong.Text        = MaPhong.Trim();
            cmbPhong.Enabled     = false;
            cmbLoaiPhong.Enabled = false;
            try
            {
                //Lấy DS sinh viên trong phòng
                var dt = FrmMain.bS_Layer.Select_DSSV_Stay(ref error, cmbKhu.Text.Trim(), cmbPhong.Text.Trim());
                if (error == "")
                {
                    dgv.Rows.Clear();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //Lấy thông tin sinh viên
                        string mssv = dt.Rows[i]["MSSV"].ToString();
                        var    sv   = FrmMain.bS_Layer.Select(ref error, BS_layer.TableName.SinhVien, EnumConst.SinhVien.MSSV, mssv);
                        if (error != "")
                        {
                            continue;
                        }
                        DSSV.Add(mssv);
                        DateTime DoB;
                        try
                        {
                            DoB = DateTime.ParseExact(dt.Rows[0]["NgayBD"].ToString(), "yyyy-MM-dd", CultureInfo.CurrentCulture);
                        }
                        catch
                        {
                            DoB = DateTime.Now;
                        }

                        string[] str = new string[]
                        {
                            sv.Rows[0]["MSSV"].ToString(),
                            sv.Rows[0]["HoTen"].ToString(),
                            sv.Rows[0]["MaLop"].ToString(),
                            DoB.ToString("yyyy-MM-dd"),
                            sv.Rows[0]["SDT"].ToString(),
                            sv.Rows[0]["QueQuan"].ToString()
                        };
                        dgv.Rows.Add(str);
                    }
                }
                else
                {
                    MessageBox.Show(error, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi");
            }

            try
            {
                var loaiPhong = FrmMain.bS_Layer.Select(ref error, BS_layer.TableName.Phong, Khu, MaPhong);
                if (loaiPhong != null)
                {
                    cmbLoaiPhong.Text = loaiPhong.Rows[0]["LoaiPhong"].ToString();
                    var tmp = FrmMain.bS_Layer.LayThongTinLoaiPhong(ref error, cmbLoaiPhong.Text);
                    lbMaxSV.Text = tmp.Rows[0]["SoSV"].ToString();
                }
            }
            catch { }
        }
示例#7
0
        private void btnRenew_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("\"", "");
                }
            }


            // Check if any books borrowed
            DialogResult two = MessageBox.Show("Are you sure you want to renew this membership?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (two == DialogResult.No)
            {
                goto End;
            }
            if (lboxBookID.Items.Count != 0 || lblFine.Text != "0/-")
            {
                MessageBox.Show("The books borrowed by the member must be returned and all fines should be paid before attempting a membership renewal", "Return books and pay fines", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (txtFName.Text == "" || txtLName.Text == "" || cboxType.Text == "" || txtAddr.Text == "" || txtNIC.Text == "" || txtWork.Text == "" || txtTP.Text == "" || txtDobDate.Text == "" || txtDobMon.Text == "" || txtDobYear.Text == "" || txtDobDate.Text == "Date" || txtDobMon.Text == "Month" || txtDobYear.Text == "Month")
            {
                MessageBox.Show("One or many of the required fields are left blank. Please fill them and try again", "Field(s) left blank", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (txtNIC.Text.Length != 10)
            {
                MessageBox.Show("NIC number invalid", "Invalid NIC", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (cboxType.Text == "Child Membership" && txtGuardian.Text == "")
            {
                MessageBox.Show("A guardian should be specified for a Child Member", "Specify Guardian", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            bool isDate = DateTime.TryParse((txtDobMon.Text + "/" + txtDobDate.Text + "/" + txtDobYear.Text), out DoB);

            if (!isDate)
            {
                MessageBox.Show("Date of Birth is invalid", "Invalid Date of Birth", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }


            if (lblStatus.Text == "Valid")
            {
                DialogResult one = MessageBox.Show("The membership is not yet expired. Beginning of new membership will be calculated from the end of present membership. Do you want to continue?", "Membership still valid", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (one == DialogResult.No)
                {
                    goto End;
                }
            }
            DateR = DateTime.Now;

            if (lblStatus.Text == "Blocked")
            {
                MessageBox.Show("This member is blocked and marked in Blacklist, maybe due to book theft or any other illegal activity. This membership cannot be renewed. \r\n\r\nPlease take nessasary actions.", "Member in Blacklist", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto End;
            }
            // Disclaimers End


            //Declarations
            FName = txtFName.Text; LName = txtLName.Text; Guard = txtGuardian.Text; NIC = txtNIC.Text; Work = txtWork.Text; Addr = txtAddr.Text; TP = txtTP.Text; Email = txtEmail.Text; Status = "Valid";
            Fine  = 0; DoB = DateTime.Parse(txtDobMon.Text + "/" + txtDobDate.Text + "/" + txtDobYear.Text); Popul p = new Popul(); Stars = p.MemCalc(MemID, false);
            if (cboxType.Text == "Child Member")
            {
                MType = "Child";
            }
            else if (cboxType.Text == "Adult Member")
            {
                MType = "Adult";
            }

            if (lblStatus.Text == "Valid")
            {
                DateR = DateJ.AddMonths(set.Expire[MTi]);
            }

            //Check age and type
            DateTime now = DateTime.Today;
            int      age = now.Year - DoB.Year; if (DoB > now.AddYears(-age))

            {
                age--;
            }

            if (age >= set.AgeMin && MType == "Child")
            {
                DialogResult r = MessageBox.Show("This Child member is now old enough to be an Adult Member. Continue creating an adult membership?", "Adult Member", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (r == DialogResult.Yes)
                {
                    MType = "Adult"; cboxType.Text = "Adult Member";
                }
                else
                {
                    goto End;
                }
            }
            if (MType == "Child")
            {
                MTi = 0;
            }
            else
            {
                MTi = 1;
            }

            Renewed = int.Parse(lblRenew.Text) + 1;

            // Declaring MemID
            {
                string MaxID;

                // Getting the MaxID from DB
                string sqlMaxID = "SELECT MAX(MemberID) as MaxID FROM Member"; OleDbCommand cmdMaxID = new OleDbCommand(sqlMaxID, db.con);
                if (db.con.State.Equals(ConnectionState.Closed))
                {
                    db.con.Open();
                }
                OleDbDataReader drMaxID = cmdMaxID.ExecuteReader();
                if (drMaxID.Read())
                {
                    MaxID = drMaxID["MaxID"].ToString().Substring(1, 4);
                }
                else
                {
                    goto End;
                }

                // Increment MaxID to PresentID
                int    iID = int.Parse(MaxID) + 1;
                string sID = iID.ToString();

                //Loop to add enough zeros for the 5-character format (M0001)

                for (int i = sID.Length; i != 4; i++)
                {
                    sID = "0" + sID;
                }
                NewMemID = "M" + sID;
            }
            // Declarations End

            //Request paying

            fee = set.NewC[MTi];
            DialogResult receive = MessageBox.Show(string.Format("Rs. {0}/- should be received for renewal of a {1} membership. Receive the amount and continue.", fee, MType), "Receive Fees", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (receive == DialogResult.Cancel)
            {
                goto End;
            }

            // Adding Transaction details

            string       sqlTrans = string.Format("INSERT INTO Cash (TDate, Amount, TDetail, Event) VALUES('{0}', {1}, '{2}', 'RenewMem')", DateTime.Now.ToString(), fee, "MemberID = " + MemID);
            OleDbCommand cmdTrans = new OleDbCommand(sqlTrans, db.con);

            cmdTrans.ExecuteNonQuery();
            // Transactions added.

            // Add all to Relation 'Member' in DB.

            string       sqlNew = string.Format("INSERT INTO Member (MemberID, FName, LName, MType, MStatus, DateJoined, Email, DateofBirth, TP, Guardian, NIC, Address, MWork, Renewed, TimesBorrow, Stars) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', {13}, {14}, {15})", NewMemID, FName, LName, MType, Status, DateR.ToShortDateString(), Email, DoB.ToShortDateString(), TP, Guard, NIC, Addr, Work, Renewed, TimesBorrow, Stars);
            OleDbCommand cmdNew = new OleDbCommand(sqlNew, db.con); cmdNew.ExecuteNonQuery();

            //Delete Old Member
            string       sqlDel = string.Format("DELETE FROM Member WHERE MemberID = '{0}'", MemID);
            OleDbCommand cmdDel = new OleDbCommand(sqlDel, db.con); cmdDel.ExecuteNonQuery();

            MessageBox.Show(string.Format("Membership of Member({0}) has been successfully renewed as ID '{1}'", MemID, NewMemID), "Renewal Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); // Message

            // Reset Form
            Reset();



            End : if (db.con.State.Equals(ConnectionState.Open))
            {
                db.con.Close();
            }
        }
示例#8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //Verify
            DialogResult one = MessageBox.Show(string.Format("Are you sure you want to update these details to the member '{0}'?", MemID), "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (one == DialogResult.No)
            {
                goto End;
            }

            // Disclaimers

            //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("\"", "");
                }
            }

            if (txtFName.Text == "" || txtLName.Text == "" || txtAddr.Text == "" || txtNIC.Text == "" || txtWork.Text == "" || txtTP.Text == "" || txtDobDate.Text == "" || txtDobMon.Text == "" || txtDobYear.Text == "" || txtDobDate.Text == "Date" || txtDobMon.Text == "Month" || txtDobYear.Text == "Month")
            {
                MessageBox.Show("One or many of the required fields are left blank. Please fill them and try again", "Field(s) left blank", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (txtNIC.Text.Length != 10)
            {
                MessageBox.Show("NIC number invalid", "Invalid NIC", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if ((MType == "Child" && cboxType.Text == "Adult Member") || (MType == "Adult" && cboxType.Text == "Child Member"))
            {
                MessageBox.Show("Member type cannot be changed", "Can't change member type", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (cboxType.Text == "Child Member" && txtGuardian.Text == "")
            {
                MessageBox.Show("A guardian must be specified for a child member.", "Specify Guardian", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }


            // Disclaimers End

            //Declarations
            FName = txtFName.Text; LName = txtLName.Text; Guard = txtGuardian.Text; NIC = txtNIC.Text; Work = txtWork.Text; Addr = txtAddr.Text; TP = txtTP.Text; Email = txtEmail.Text; Status = "Valid";
            Fine  = 0; DoB = DateTime.Parse(txtDobMon.Text + "/" + txtDobDate.Text + "/" + txtDobYear.Text);

            // Declarations End

            // Update all to Relation 'Member' in DB.

            string       sqlUpd = string.Format("UPDATE Member SET FName ='{0}', LName ='{1}', Email ='{2}', DateofBirth ='{3}', TP ='{4}', Guardian ='{5}', NIC ='{6}', Address ='{7}', MWork ='{8}' WHERE MemberID = '{9}'", FName, LName, Email, DoB.ToShortDateString(), TP, Guard, NIC, Addr, Work, MemID);
            OleDbCommand cmdUpd = new OleDbCommand(sqlUpd, db.con); if (db.con.State.Equals(ConnectionState.Closed))

            {
                db.con.Open();
            }
            cmdUpd.ExecuteNonQuery();

            MessageBox.Show(string.Format("Details of Member({0}) have been updated successfully", MemID), "Update Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); // Message

            // Reset Form
            Reset();

            End : if (db.con.State.Equals(ConnectionState.Open))
            {
                db.con.Close();
            }
        }
示例#9
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            // Disclaimers

            //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("\"", "");
                }
            }

            if (txtFName.Text == "" || txtLName.Text == "" || cboxType.Text == "" || txtAddr.Text == "" || txtNIC.Text == "" || txtWork.Text == "" || txtTP.Text == "" || txtDobDate.Text == "" || txtDobMon.Text == "" || txtDobYear.Text == "" || txtDobDate.Text == "Date" || txtDobMon.Text == "Month" || txtDobYear.Text == "Month")
            {
                MessageBox.Show("One or many of the required fields are left blank. Please fill them and try again", "Field(s) left blank", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (txtNIC.Text.Length != 10)
            {
                MessageBox.Show("NIC number invalid", "Invalid NIC", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (cboxType.Text == "Child Membership" && txtGuardian.Text == "")
            {
                MessageBox.Show("A guardian should be specified for a Child Member", "Specify Guardian", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            bool isDate = DateTime.TryParse((txtDobMon.Text + "/" + txtDobDate.Text + "/" + txtDobYear.Text), out DoB);

            if (!isDate)
            {
                MessageBox.Show("Date of Birth is invalid", "Invalid Date of Birth", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }

            //Declarations
            FName = txtFName.Text; LName = txtLName.Text; Guard = txtGuardian.Text; NIC = txtNIC.Text; Work = txtWork.Text; Addr = txtAddr.Text; TP = txtTP.Text; Email = txtEmail.Text; Status = "Valid";
            DateJ = DateTime.Today.Date; Fine = 0;
            if (cboxType.Text == "Child Membership")
            {
                MType = "Child";
            }
            else if (cboxType.Text == "Adult Membership")
            {
                MType = "Adult";
            }

            //Check age and type
            DateTime now = DateTime.Today;
            int      age = now.Year - DoB.Year; if (DoB > now.AddYears(-age))

            {
                age--;
            }

            //Disclaim age and type
            if (age < set.AgeMin && MType == "Adult")
            {
                MessageBox.Show("This person is not old enough for an adult membership.", "Age not enough", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }
            if (age >= set.AgeMin && MType == "Child")
            {
                MessageBox.Show("This person is old enough for an adult membership. Therefore, child membership cannot be created", "Invalid Age", MessageBoxButtons.OK, MessageBoxIcon.Error); goto End;
            }

            //Check for previous NIC, address and Blacklist
            string sqlDupl = string.Format("SELECT MemberID, FName, LName, MType, MStatus, NIC, Address, MWork, Email, TP FROM Member WHERE NIC = '{0}' OR Address = '{1}' OR MWork = '{2}' OR Email = '{3}' OR TP = '{4}'", NIC, Addr, Work, Email, TP); OleDbCommand cmdDupl = new OleDbCommand(sqlDupl, db.con);

            if (db.con.State.Equals(ConnectionState.Closed))
            {
                db.con.Open();
            }
            OleDbDataReader drDupl = cmdDupl.ExecuteReader(); drDupl.Read();

            if (drDupl.HasRows && Email != "")
            {
                string tMemID = drDupl["MemberID"].ToString(), tMType = drDupl["MType"].ToString(), tFName = drDupl["FName"].ToString(), tLName = drDupl["LName"].ToString(), tNIC = drDupl["NIC"].ToString(), tStatus = drDupl["MStatus"].ToString(), tAddr = drDupl["Address"].ToString(), tMWork = drDupl["MWork"].ToString(), tEmail = drDupl["Email"].ToString(), tTP = drDupl["TP"].ToString();


                if (tStatus == "Blocked" && (tNIC == NIC || tEmail == Email) && MType == tMType)
                {
                    MessageBox.Show(string.Format("A person with such personal credentials, MemberID '{0}' and in the name name: '{1} {2}' is blocked and marked in Blacklist, maybe due to book theft or any other illegal activity. \r\n\r\nPlease take nessasary actions.", tMemID, tFName, tLName), "Person in Blacklist", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto End;
                }
                else if (tStatus == "Valid" && (tNIC == NIC || tEmail == Email) && MType == tMType && MType == "Adult")
                {
                    MessageBox.Show(string.Format("This person is already a valid member in the library with the name: '{0} {1}'\r\n\r\nIf not, please change the personal credentials, such as Email or NIC number anew", tFName, tLName), "Valid member", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto End;
                }
                else if (tStatus == "Expired" && (tNIC == NIC || tEmail == Email) && MType == tMType && MType == "Adult")
                {
                    MessageBox.Show(string.Format("This person holds an expired membership with MemberID '{0}' in the library with the name: '{1} {2}'\r\n\r\nIf not, please change the personal credentials, such as Email or NIC number anew", tMemID, tFName, tLName), "Expired member", MessageBoxButtons.OK, MessageBoxIcon.Warning); goto End;
                }
                else if (tStatus == "Blocked" && (tAddr == Addr || tMWork == Work || tTP == TP))
                {
                    MessageBox.Show(string.Format("A person with these home address, work address or telephone number with MemberID '{0}' and in the name: '{1} {2}' is blocked and marked in Blacklist, maybe due to book theft or any other illegal activity. \r\n\r\nYou may inquire about the blocked member from this person. This person will be added as a Member", tMemID, tFName, tLName), "Person in Blacklist", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            // Declaring MemID
            {
                string MaxID;

                // Getting the MaxID from DB
                string sqlMaxID = "SELECT MAX(MemberID) as MaxID, COUNT(MemberID) as CountID FROM Member"; OleDbCommand cmdMaxID = new OleDbCommand(sqlMaxID, db.con);
                if (db.con.State.Equals(ConnectionState.Closed))
                {
                    db.con.Open();
                }
                OleDbDataReader drMaxID = cmdMaxID.ExecuteReader(); drMaxID.Read();

                if (drMaxID["CountID"].ToString() != "0")
                {
                    MaxID = drMaxID["MaxID"].ToString();
                    Methods meth = new Methods();
                    MemID = meth.NewID(MaxID);
                }
                else
                {
                    MemID = "M0001";
                }
            }
            if (MType == "Child")
            {
                MTi = 1;
            }
            else
            {
                MTi = 0;
            }
            // Declarations End

            //Request paying
            fee = set.NewC[MTi];
            DialogResult receive = MessageBox.Show(string.Format("Rs. {0}/- should be received for creation of a new {1} membership. Receive the amount and continue.", fee, MType), "Receive Fees", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (receive == DialogResult.Cancel)
            {
                goto End;
            }

            // Adding Transaction details

            string       sqlTrans = string.Format("INSERT INTO Cash (TDate, Amount, TDetail, Event) VALUES('{0}', {1}, '{2}', 'NewMem')", DateTime.Now.ToString(), fee, "MemberID = " + MemID);
            OleDbCommand cmdTrans = new OleDbCommand(sqlTrans, db.con);

            cmdTrans.ExecuteNonQuery();
            // Transactions added.

            // Add all to Relation 'Member' in DB.

            string       sqlNew = string.Format("INSERT INTO Member (MemberID, FName, LName, MType, MStatus, DateJoined, Email, DateofBirth, TP, Guardian, NIC, Address, MWork) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')", MemID, FName, LName, MType, Status, DateJ.ToShortDateString(), Email, DoB.ToShortDateString(), TP, Guard, NIC, Addr, Work);
            OleDbCommand cmdNew = new OleDbCommand(sqlNew, db.con); cmdNew.ExecuteNonQuery();

            MessageBox.Show(string.Format("New Member '{0}' has been added successfully and transactions have been recorded.", MemID), "Adding Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); // Message

            // Reset Form
            txtFName.Text = txtLName.Text = cboxType.Text = txtGuardian.Text = txtDobDate.Text = txtDobMon.Text = txtDobYear.Text = txtNIC.Text = txtAddr.Text = txtWork.Text = txtTP.Text = txtEmail.Text = "";


            End : if (db.con.State.Equals(ConnectionState.Open))
            {
                db.con.Close();
            }
        }
示例#10
0
 public int GetAge()
 {
     return(DoB.GetAge());
 }