示例#1
0
        public FrmChiTietCmnd(Cmnd cmnd)
        {
            InitializeComponent();

            this.cmnd = cmnd;

            SetData();
        }
示例#2
0
        public Cmnd Read(string soCmnd)
        {
            string query = string.Empty;

            query += "SELECT TOP 1 * ";
            query += "FROM [CMND] WHERE [SoCmnd]=@SoCmnd";

            Cmnd cd = new Cmnd();

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@SoCmnd", soCmnd);

                    try
                    {
                        con.Open();
                        SqlDataReader reader = null;

                        reader = cmd.ExecuteReader();
                        reader.Read();

                        cd.Ma              = int.Parse(reader["Ma"].ToString());
                        cd.SoCmnd          = reader["SoCmnd"].ToString();
                        cd.HoTen           = reader["HoTen"].ToString();
                        cd.QueQuan         = reader["QueQuan"].ToString();
                        cd.DiaChiHoKhau    = reader["DiaChiHoKhau"].ToString();
                        cd.DanToc          = reader["DanToc"].ToString();
                        cd.TonGiao         = reader["TonGiao"].ToString();
                        cd.DacDiemNhanDang = reader["DacDiemNhanDang"].ToString();
                        cd.NoiCap          = reader["NoiCap"].ToString();
                        cd.NguoiCap        = reader["NguoiCap"].ToString();

                        cd.NgaySinh = DateTime.Parse(reader["NgaySinh"].ToString());
                        cd.NgayCap  = DateTime.Parse(reader["NgayCap"].ToString());

                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(null);
                    }
                }
            }
            return(cd);
        }
        public void input()
        {
            Console.WriteLine("Nhap vao thong tin the ATM: ");
            do
            {
                Console.Write("Nhap vao So tai khoan:");
                Sotaikhoan = Convert.ToString(Console.ReadLine());
            } while (Sotaikhoan == null || Sotaikhoan.Length <= 10);

            do
            {
                Console.Write("\nNhap vao Ten chu the:");

                Tenchuthe = Convert.ToString(Console.ReadLine());
                //char getenter = Convert.ToChar(Console.ReadKey());
            } while (Tenchuthe == null || (Array.TrueForAll(Tenchuthe.ToCharArray(), c => char.IsDigit(c) == true)));
            DateTime require18 = DateTime.Now;

            do
            {
                Console.Write("\nNhap vao Ngay sinh- Format:MM/dd/yyyy-( Hay dam bao hien tai ban > 18 tuoi):");
                Ngaysinh = Convert.ToDateTime(Console.ReadLine());
            } while ((require18.Year - Ngaysinh.Year) < 18);
            do
            {
                Console.Write("\nNhap vao CMND( 9 chu so):");
                Cmnd = Convert.ToDecimal(Console.ReadLine());
            } while ((Cmnd.ToString().Length) < 9);
            do
            {
                Console.Write("\nNhap vao Ngay mo the- Format:MM/dd/yyyy-( Hay dam bao hien tai ban > 18 tuoi):");
                Ngaymothe = Convert.ToDateTime(Console.ReadLine());
            } while (Ngaymothe.Year < ngaySinh.Year + 18);
            do
            {
                Console.Write("\nNhap vao Thoi han:");
                Hansudung = Convert.ToInt32(Console.ReadLine());
            } while (Hansudung % 6 != 0);
            do
            {
                Console.Write("\nNhap vao So du( Toi thieu 100.000 VND) :");
                Sodu = Convert.ToDecimal(Console.ReadLine());
            } while (Sodu < 100000);
            do
            {
                Console.Write("\nNhap vao Ma PIN( 6 chu so):");
                Mapin = Convert.ToInt32(Console.ReadLine());
            } while ((Mapin.ToString().Length != 6) || Array.TrueForAll(Mapin.ToString().ToCharArray(), c => char.IsDigit(c) == false));


            Console.WriteLine("Mo the thanh cong !");
        }
        private void setCmndCccd()
        {
            if (congDan.CoCccd())
            {
                cccd = cccdBUS.Read(congDan.SoCccd);
            }
            else
            {
                btnXemCccd.Enabled = false;
            }

            if (congDan.CoCmnd())
            {
                cmnd = cmndBUS.Read(congDan.SoCmnd);
            }
            else
            {
                btnXemCmnd.Enabled = false;
            }
        }