示例#1
0
        public List <ChiTietChuyenDi> getAll(string maChuyenDi)
        {
            String sql = "select * from ChiTietChuyenDi where maChuyenDi = @maChuyenDi";

            SqlParameter p1 = new SqlParameter("@maChuyenDi", maChuyenDi);

            SqlParameter[] param = { p1 };
            DataTable      table = manager.executeQuery(sql, param);

            List <ChiTietChuyenDi> list = new List <ChiTietChuyenDi>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow row = table.Rows[i];

                string benXeTrungGian = (string)row["benXeTrungGian"];
                int    thoiGianDung   = (int)row["thoiGianDung"];
                string ghiChu         = (string)row["ghiChu"];

                ChiTietChuyenDi c = new ChiTietChuyenDi(maChuyenDi, benXeTrungGian, thoiGianDung, ghiChu);

                list.Add(c);
            }

            return(list);
        }
示例#2
0
 private void addChiTietChuyenDi(ChiTietChuyenDi m)
 {
     try
     {
         bool kq = chiTietChuyenDiDB.add(m);
         if (kq)
         {
             loadData();
             ClearInput();
         }
         else
         {
             MessageBox.Show("Them ko thanh cong");
         }
     }
     catch (Exception e)
     {
         if (e.Message.Contains("UNIQUE"))
         {
             MessageBox.Show("Email trung lap");
         }
         else
         {
             MessageBox.Show("Khong the thuc hien duoc: " + e.Message);
         }
     }
 }
示例#3
0
        private void Display(ChiTietChuyenDi c)
        {
            cbbMaChuyenDi.Text     = c.MaChuyenDi;
            cbbBenXeTrungGian.Text = c.BenXeTrungGian;
            txtThoiGianDung.Text   = c.ThoiGianDung.ToString();
            txtGhiChu.Text         = c.GhiChu;

            setEditMode(true);
        }
示例#4
0
        public bool update(ChiTietChuyenDi c)
        {
            String sql = "update ChiTietChuyenDi set thoiGianDung = @thoiGianDung, ghiChu = @ghiChu where maChuyenDi = @maChuyenDi and benXeTrungGian = @benXeTrungGian";

            SqlParameter p1 = new SqlParameter("@maChuyenDi", c.MaChuyenDi);
            SqlParameter p2 = new SqlParameter("@benXeTrungGian", c.BenXeTrungGian);
            SqlParameter p3 = new SqlParameter("@thoiGianDung", c.ThoiGianDung);
            SqlParameter p4 = new SqlParameter("@ghiChu", c.GhiChu);

            SqlParameter[] param = { p1, p2, p3, p4 };

            return(manager.executeUpdate(sql, param));
        }
示例#5
0
        private void gridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;

            if (row < 0 || row >= list.Count)
            {
                return;
            }

            ChiTietChuyenDi c = list[row];

            Display(c);
        }
示例#6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string maChuyenDi     = cbbMaChuyenDi.Text.Trim();
            string benXeTrungGian = cbbBenXeTrungGian.Text.Trim();
            int    thoiGianDung   = Convert.ToInt32(txtThoiGianDung.Text.Trim());
            string ghiChu         = txtGhiChu.Text.Trim();

            ChiTietChuyenDi m = new ChiTietChuyenDi(maChuyenDi, benXeTrungGian, thoiGianDung, ghiChu);

            list.Add(m);
            gridView.DataSource = null;
            gridView.DataSource = list;
            addChiTietChuyenDi(m);
        }
示例#7
0
        public bool add(ChiTietChuyenDi c)
        {
            try
            {
                String sql = "insert into ChiTietChuyenDi values(@maChuyenDi, @benXeTrungGian, @thoiGianDung, @ghiChu)";

                SqlParameter p1 = new SqlParameter("@maChuyenDi", c.MaChuyenDi);
                SqlParameter p2 = new SqlParameter("@benXeTrungGian", c.BenXeTrungGian);
                SqlParameter p3 = new SqlParameter("@thoiGianDung", c.ThoiGianDung);
                SqlParameter p4 = new SqlParameter("@ghiChu", c.GhiChu);

                SqlParameter[] param = { p1, p2, p3, p4 };

                return(manager.executeUpdate(sql, param));
            }
            catch (Exception e)
            {
                return(false);
            }
        }
示例#8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!isInputValid())
            {
                return;
            }

            string maChuyenDi     = cbbMaChuyenDi.Text.Trim();
            string benXeTrungGian = cbbBenXeTrungGian.Text.Trim();
            int    thoiGianDung   = Convert.ToInt32(txtThoiGianDung.Text.Trim());
            string ghiChu         = txtGhiChu.Text.Trim();

            DialogResult result = MessageBox.Show("Ban co muon cap nhat " + maChuyenDi, "Cap nhat thong tin ", MessageBoxButtons.YesNo);

            if (result != DialogResult.Yes)
            {
                return;
            }

            ChiTietChuyenDi m = new ChiTietChuyenDi(maChuyenDi, benXeTrungGian, thoiGianDung, ghiChu);

            bool ketQua = chiTietChuyenDiDB.update(m);

            // thong bao
            if (ketQua)
            {
                MessageBox.Show("Cap nhat thanh cong");
            }
            else
            {
                MessageBox.Show("Cap nhat ko thanh cong");
            }

            list = chiTietChuyenDiDB.getAll(cbbMaChuyenDi.Text);
            gridView.DataSource = null;
            gridView.DataSource = list;
        }