Ejemplo n.º 1
0
 public bool create(TamVang TT)
 {
     try
     {
         string sqlString = "INSERT INTO TamVangs VALUES ('" + TT.SoQuyen + "','" + TT.SoDK + "','" + TT.MaCD + "',N'" + TT.LyDoTamVang + "','" + TT.NgayDK.ToShortDateString() + "','" + TT.NgayHuy.Value.ToShortDateString() + "')";
         return(db.MyExecuteNonQuery(sqlString, CommandType.Text));
     }
     catch (Exception e)
     {
         MessageBox.Show("Lỗi create Thuong Tru + " + e.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
        private void btnTimCMND_Click(object sender, EventArgs e)
        {
            if (comBoBoxChucNang.SelectedIndex == 0)
            {
                //Thêm đăng ký tạm vắng
                string        imfor = null;
                QuanLyCongDan QLCD  = new QuanLyCongDan();

                CongDan CD = new CongDan();

                CD = QLCD.TimCD_CMND(txtCMND_Search.Text.Trim(), ref imfor);

                txtMaCD.Text     = CD.MaCD;
                txtHoVaTen.Text  = CD.HoLot + " " + CD.Ten;
                txtNgaySinh.Text = CD.NgaySinh.ToShortDateString();
                txtTonGiao.Text  = CD.TonGiao;
                txtNoiSong.Text  = CD.DiaChiThuongTru;
                txtCMND.Text     = CD.soCMND;
                txtDanToc.Text   = CD.DanToc;
                txtQuocTich.Text = CD.QuocTich;

                DevExpress.XtraEditors.XtraMessageBox.Show(imfor);
            }
            if (comBoBoxChucNang.SelectedIndex == 1)
            {
                string        imfor = null;
                QuanLyCongDan QLCD  = new QuanLyCongDan();

                CongDan CD = new CongDan();

                CD = QLCD.TimCD_CMND(txtCMND_Search.Text.Trim(), ref imfor);

                txtMaCD.Text     = CD.MaCD;
                txtHoVaTen.Text  = CD.HoLot + " " + CD.Ten;
                txtNgaySinh.Text = CD.NgaySinh.ToShortDateString();
                txtTonGiao.Text  = CD.TonGiao;
                txtNoiSong.Text  = CD.DiaChiThuongTru;
                txtCMND.Text     = CD.soCMND;
                txtDanToc.Text   = CD.DanToc;
                txtQuocTich.Text = CD.QuocTich;

                QuanLyTamVang QLTV = new QuanLyTamVang();

                TamVang TV = QLTV.TimTamTru_MaCD(CD.MaCD, ref imfor);

                txtLyDoTamVang.Text   = TV.LyDoTamVang;
                txtSoQL.Text          = TV.SoDK.ToString();
                txtSoQuyen.Text       = TV.SoQuyen;
                datePick_NgayDK.Value = TV.NgayDK;
            }
        }
Ejemplo n.º 3
0
        public TamVang TimMaCD(string MaCD)
        {
            string         sqlString  = "select * from TamVangs where MaCD = " + MaCD + "";
            DataSet        ds         = db.ExecuteQueryDataSet(sqlString, CommandType.Text);
            DataTable      dt         = ds.Tables[0];
            List <TamVang> thuongtrus = new List <TamVang>();

            foreach (DataRow dr in dt.Rows)
            {
                TamVang tt = findById((string)dr.ItemArray[0]);
                thuongtrus.Add(tt);
            }
            return(thuongtrus[0]);
        }
Ejemplo n.º 4
0
 public TamVang TimTamTru_MaCD(string MaCD, ref string imfor)
 {
     try
     {
         KetNoiTamVang Connect = new KetNoiTamVang();
         TamVang       TT      = Connect.TimMaCD(MaCD);
         imfor = "OK!!";
         return(TT);
     }
     catch
     {
         imfor = "Không tìm thấy CMND này!!";
         return(null);
     }
 }
Ejemplo n.º 5
0
        public void TaoMoiThuTucTamVang(string MaCD, DateTime NgayDk, string LyDoTamVang, ref string imfor)
        {
            // Tạo ra đối tượng thường trú
            TamVang TT = new TamVang();

            TT.MaCD        = MaCD;
            TT.NgayDK      = NgayDk;
            TT.LyDoTamVang = LyDoTamVang;
            TT.SoQuyen     = "STTr" + DateTime.Now.Year + "-" + DateTime.Now.Month;

            // Kết nối cơ sở dữ liệu để lưu đối tượng
            KetNoiTamVang Connect = new KetNoiTamVang();

            Connect.TaoMoi(TT);
        }
Ejemplo n.º 6
0
        public void LayGiaTriID(ref int ID)
        {
            string         sqlString    = "select * from TamVangs ";
            DataSet        ds           = db.ExecuteQueryDataSet(sqlString, CommandType.Text);
            DataTable      dt           = ds.Tables[0];
            List <TamVang> lstThuongtru = new List <TamVang>();

            foreach (DataRow dr in dt.Rows)
            {
                TamVang tt = findById((string)dr.ItemArray[0]);
                lstThuongtru.Add(tt);
            }
            TamVang ttr = lstThuongtru.LastOrDefault();

            ID = ttr.SoDK;
        }
Ejemplo n.º 7
0
        public void TaoMoi(TamVang TV)
        {
            try
            {
                string         sqlString  = "select * from TamVangs ";
                DataSet        ds         = db.ExecuteQueryDataSet(sqlString, CommandType.Text);
                DataTable      dt         = ds.Tables[0];
                List <TamVang> thuongtrus = new List <TamVang>();
                foreach (DataRow dr in dt.Rows)
                {
                    TamVang tt = findById((string)dr.ItemArray[0]);
                    thuongtrus.Add(tt);
                }

                TamVang tts     = thuongtrus.LastOrDefault();
                int     MaxSoDk = tts.SoDK;
                TV.SoDK = MaxSoDk + 1;

                create(TV);
            }
            catch (Exception e)
            {
            }
        }
Ejemplo n.º 8
0
        public TamVang findById(string id)
        {
            try
            {
                string  sqlString = "select * from TamVangs where So = " + id + "";
                DataSet ds        = db.ExecuteQueryDataSet(sqlString, CommandType.Text);
                TamVang gks       = new TamVang()
                {
                    SoQuyen     = (string)ds.Tables[0].Rows[0].ItemArray[0],
                    SoDK        = (int)ds.Tables[0].Rows[0].ItemArray[1],
                    MaCD        = (string)ds.Tables[0].Rows[0].ItemArray[2],
                    LyDoTamVang = (string)ds.Tables[0].Rows[0].ItemArray[0],

                    NgayDK  = (DateTime)ds.Tables[0].Rows[0].ItemArray[6],
                    NgayHuy = (DateTime)ds.Tables[0].Rows[0].ItemArray[7],
                };
                return(gks);
            }
            catch (Exception e)
            {
                MessageBox.Show("Lỗi FindById TamVang!!! + " + e.Message);
                return(null);
            }
        }