示例#1
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);
        }
示例#2
0
 public string GetDateOfBirth()
 {
     return(DoB.ToString("yyyy/MM/dd"));
 }
示例#3
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 { }
        }