private void btn_luu_Click(object sender, EventArgs e) { if (!CheckBeforeSave()) { return; } DTO_Xe xe = new DTO_Xe(); xe.ma_so_xe = txt_ma_so_xe.Text; xe.loai_xe = txt_loai_xe.Text; xe.nhan_hieu = txt_nhan_hieu.Text; xe.trong_luong = Convert.ToInt32(txt_trong_luong.Text); xe.ma_tinh_trang = Convert.ToInt32(cbb_tinh_trang.SelectedValue); xe.ngay_tao = DateTime.Now; if (txt_ma_so_xe.Enabled) { dal_xe.Create_Xe(xe); } else { dal_xe.Update_Xe(xe); } BindDataGridView(); ResetControl(); MethodHelper.ClearErrorProvider(); btn_xoa.Enabled = false; btn_sua.Enabled = false; }
private void cbb_soxe_SelectedIndexChanged(object sender, EventArgs e) { if (cbb_soxe.SelectedValue != null) { string chonsoxe = cbb_soxe.SelectedValue.ToString().Trim(); if (cbb_soxe.SelectedIndex == 0) { txt_trongluongxe.Text = ""; grv_NV.DataSource = dal_nv.dt_GetAll(); } else { // int i = cbb_soxe.SelectedIndex; grv_NV.DataSource = null; grv_NV.DataSource = dal_nv.GetAll_NV_ID(chonsoxe); DTO_Xe dto = new DTO_Xe(); dto.ma_so_xe = cbb_soxe.SelectedValue.ToString(); List <DTO_Xe> li = new BLL_DieuXe().Get_TrongLuongXe(dto); foreach (DTO_Xe xe in li) { txt_trongluongxe.Text = xe.trong_luong.ToString(); } //txt_trongluongxe.Text = grv_TTxe.Rows[i].Cells["coltrongluong"].Value.ToString(); } } }
public bool ThemXe(DTO_Xe xe) { try { _conn.Open(); var cmd = new SqlCommand("ThemXe", _conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@BienSo", SqlDbType.VarChar).Value = xe.sBienSo; cmd.Parameters.Add("@HieuXe", SqlDbType.VarChar).Value = xe.sHieuXe; cmd.Parameters.Add("@MaKH", SqlDbType.Int).Value = xe.iMaKH; cmd.Parameters.Add("@NgaySuaChua", SqlDbType.DateTime).Value = xe.dtNgaySuaChua; if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { _conn.Close(); } return(false); }
public List <DTO_Xe> Get_TrongLuongXe(DTO_Xe dto) { string sql = "select * from dm_xe where ma_so_xe='" + dto.ma_so_xe.Trim() + "'"; SqlDataReader dr = data.ExcuteDataReader(sql, null); return(data.MapDataReaderToObject <DTO_Xe>(dr)); }
///</summary> /// Thêm xe vào csdl /// </summary> /// <param name="_dxe"></param> /// <returns></returns> public bool themXe(DTO_Xe _dxe) { try { // Ket noi _conn.Open(); // Query string - vì mình để TV_ID là identity (giá trị tự tăng dần) nên ko cần fải insert ID string SQL = string.Format("INSERT INTO XE(Tenxe, Mahangxe,Mahieuxe,Bienso,Makhachhang,Ngaynhapgara) VALUES ('{0}', '{1}', '{2}', '{3}' , '{4}' , '{5}' )", _dxe.TENXE, _dxe.MAHANGXE, _dxe.MAHIEUXE, _dxe.BIENSO, _dxe.MAKHACHHANG, _dxe.NGAYNHAPGARA); // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều). SqlCommand cmd = new SqlCommand(SQL, _conn); // Query và kiểm tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { // Dong ket noi _conn.Close(); } return(false); }
private void buttonThem_Click(object sender, EventArgs e) { DTO_KhachHang kh = new DTO_KhachHang(textBoxTenKH.Text, textBoxDienThoai.Text, textBoxDiaChi.Text, 0); if (buskh.ThemKhachHang(kh)) { DAL_KhachHang layttkh = new DAL_KhachHang(); DataTable dt = layttkh.LayMaKH(textBoxTenKH.Text, textBoxDienThoai.Text); DateTime now = DateTime.Now; int imakh = int.Parse(dt.Rows[0]["MaKH"].ToString()); DTO_Xe xe = new DTO_Xe(imakh, textBoxBienSo.Text, comboBoxHieuXe.Text, now); if (busxe.ThemXe(xe)) { MessageBox.Show("Thêm xe thành công"); } else { MessageBox.Show("Thêm xe không thành công"); } } else { MessageBox.Show("Thêm khách hàng không thành công hoặc khách hàng đã có sẵn trong hệ thống"); } }
private void BtnTiepNhanXe_Click(object sender, EventArgs e) { if (getKhachhang() == "") { MessageBox.Show("Vui lòng chọn khách hàng", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (getHangxe() == "") { MessageBox.Show("Vui lòng chọn hãng xe", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (getHieuxe() == "") { MessageBox.Show("Vui lòng chọn hiệu xe", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txbTenXe.Text == "") { MessageBox.Show("Vui lòng nhập tên xe", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txbBienSo.Text == "") { MessageBox.Show("Vui lòng nhập biển số", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (busTNX.Checkbienso(txbBienSo.Text) == false) { DialogResult res = MessageBox.Show("Biển số đã tồn tại", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (res == DialogResult.OK) { txbBienSo.Text = String.Empty; } } else { // MessageBox.Show(busTNX.getMahangxe(getHangxe())); string s = getKhachhang().Substring((getKhachhang().LastIndexOf('-') + 1)).Trim(); string a = busTNX.getMakhachhang(s); // MessageBox.Show(DateTime.Parse(dateNhapXe.Value.ToShortDateString()).ToString()); DTO_Xe xe = new DTO_Xe(0, txbTenXe.Text, busTNX.getMahangxe(getHangxe()), busTNX.getMahieuxe(getHieuxe()), txbBienSo.Text, Int32.Parse(a), DateTime.Parse(dateNhapXe.Value.ToShortDateString())); DialogResult result; if (busTNX.themXe(xe)) { result = MessageBox.Show("Thêm xe thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { result = MessageBox.Show("Thêm xe thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (result == DialogResult.OK) { XoaDuLieu(); UC_TiepNhanXe_Load(sender, e); } } }
public bool Create_Xe(DTO_Xe xe) { string sql = "insert into dm_xe(ma_so_xe,trong_luong,loai_xe,nhan_hieu,ma_tinh_trang,ngay_tao) values(@ma_so_xe,@trong_luong,@loai_xe,@nhan_hieu,@ma_tinh_trang,@ngay_tao)"; SqlParameter[] prs = { new SqlParameter("@ma_so_xe", xe.ma_so_xe), new SqlParameter("@trong_luong", xe.trong_luong), new SqlParameter("@loai_xe", xe.loai_xe), new SqlParameter("@nhan_hieu", xe.nhan_hieu), new SqlParameter("@ma_tinh_trang", xe.ma_tinh_trang.ToString()), new SqlParameter("@ngay_tao", xe.ngay_tao) }; return(data.ExcuteNonQuery(sql, prs)); }
public bool Update_Xe(DTO_Xe xe) { string sql = "update dm_xe set trong_luong=@trong_luong,loai_xe=@loai_xe,nhan_hieu=@nhan_hieu,ma_tinh_trang=@ma_tinh_trang,ngay_tao=@ngay_tao where ma_so_xe=@ma_so_xe"; SqlParameter[] prs = { new SqlParameter("@ma_so_xe", xe.ma_so_xe), new SqlParameter("@trong_luong", xe.trong_luong), new SqlParameter("@loai_xe", xe.loai_xe), new SqlParameter("@nhan_hieu", xe.nhan_hieu), new SqlParameter("@ma_tinh_trang", xe.ma_tinh_trang), new SqlParameter("@ngay_tao", xe.ngay_tao) }; return(data.ExcuteNonQuery(sql, prs)); }
private void _Xe() { lvthongtintimkiem.Items.Clear(); lvthongtintimkiem.Columns.Add("STT", 60); lvthongtintimkiem.Columns.Add("Mã Số Xe", 100); lvthongtintimkiem.Columns.Add("Loại Xe", 100); lvthongtintimkiem.Columns.Add("Tải Trọng", 100); lvthongtintimkiem.Columns.Add("Nhãn Hiệu", 150); lvthongtintimkiem.Columns.Add("Tình Trạng Xe", 220); lvthongtintimkiem.Columns.Add("Ngày Nhập Dữ Liệu", 500); DTO_Xe xx = new DTO_Xe(); xx.ma_so_xe = _Key_id.Trim(); int STT = 1; if (new BLL_TraCuu()._Tim_ThongTinXe(xx) != null) { foreach (DTO_Xe dto in new BLL_TraCuu()._Tim_ThongTinXe(xx)) { ListViewItem item = new ListViewItem(STT.ToString()); ListViewItem.ListViewSubItem ie1 = new ListViewItem.ListViewSubItem(item, dto.ma_so_xe); item.SubItems.Add(ie1); ListViewItem.ListViewSubItem ie2 = new ListViewItem.ListViewSubItem(item, dto.loai_xe); item.SubItems.Add(ie2); ListViewItem.ListViewSubItem ie3 = new ListViewItem.ListViewSubItem(item, dto.trong_luong.ToString("###,###")); item.SubItems.Add(ie3); ListViewItem.ListViewSubItem ie4 = new ListViewItem.ListViewSubItem(item, dto.nhan_hieu); item.SubItems.Add(ie4); ListViewItem.ListViewSubItem ie5 = new ListViewItem.ListViewSubItem(item, dto.ten_tinh_trang); item.SubItems.Add(ie5); ListViewItem.ListViewSubItem ie6 = new ListViewItem.ListViewSubItem(item, dto.ngay_tao.ToShortDateString()); item.SubItems.Add(ie6); lvthongtintimkiem.Items.Add(item); STT++; } } }
//TIM THONG TIN XE public DTO_Xe[] _Tim_ThongTinXe(DTO_Xe xe) { string sql = "select * from dm_xe,dm_tinh_trang_xe where dm_xe.ma_tinh_trang=dm_tinh_trang_xe.ma_tinh_trang and ma_so_xe like '%" + xe.ma_so_xe.Trim() + "%' "; DataTable dt = data.ExcuteDataTable(sql, null); if (dt.Rows.Count > 0) { DTO_Xe[] Xxe = new DTO_Xe[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { Xxe[i] = new DTO_Xe(); Xxe[i].ma_so_xe = dt.Rows[i]["ma_so_xe"].ToString(); Xxe[i].loai_xe = dt.Rows[i]["loai_xe"].ToString(); Xxe[i].trong_luong = float.Parse(dt.Rows[i]["trong_luong"].ToString()); Xxe[i].nhan_hieu = dt.Rows[i]["nhan_hieu"].ToString(); Xxe[i].ten_tinh_trang = dt.Rows[i]["ten_tinh_trang"].ToString(); Xxe[i].ngay_tao = Convert.ToDateTime(dt.Rows[i]["ngay_tao"].ToString()); } return(Xxe); } return(null); }
public List <DTO_Xe> Get_List_Xe_DangOBai() { string sql = "select dm_xe.*,ten_tinh_trang from dm_xe,dm_tinh_trang_xe where dm_xe.ma_tinh_trang=dm_tinh_trang_xe.ma_tinh_trang and dm_xe.ma_tinh_trang=1 order by dm_xe.trong_luong desc"; DataTable dt = data.ExcuteDataTable(sql, null); if (dt != null && dt.Rows.Count > 0) { List <DTO_Xe> xe = new List <DTO_Xe>(); foreach (DataRow dr in dt.Rows) { DTO_Xe xx = new DTO_Xe(); xx.ma_so_xe = dr["ma_so_xe"].ToString(); xx.trong_luong = float.Parse(dr["trong_luong"].ToString()); xx.nhan_hieu = dr["nhan_hieu"].ToString(); xx.ten_tinh_trang = dr["ten_tinh_trang"].ToString(); xx.loai_xe = dr["loai_xe"].ToString(); xe.Add(xx); } return(xe); } return(null); }
private void grv_xe_CellClick(object sender, DataGridViewCellEventArgs e) { int i = e.RowIndex; if (e.RowIndex == 0) { return; } DTO_Xe xe = grv_xe.Rows[e.RowIndex].DataBoundItem as DTO_Xe; txt_ma_so_xe.Text = Convert.ToString(xe.ma_so_xe); txt_loai_xe.Text = xe.loai_xe; txt_nhan_hieu.Text = xe.nhan_hieu; txt_trong_luong.Text = Convert.ToString(xe.trong_luong); cbb_tinh_trang.SelectedValue = xe.ma_tinh_trang.ToString().Trim(); EnableControl(false); MethodHelper.ClearErrorProvider(); btn_luu.Enabled = false; btn_sua.Enabled = true; btn_xoa.Enabled = true; }
public List <DTO_Xe> GetAll_Xe_1() { List <DTO_Xe> listxe_1 = new List <DTO_Xe>(); string sql = "select *,B.ten_tinh_trang from dm_xe A join dm_tinh_trang_xe B on A.ma_tinh_trang=B.ma_tinh_trang and ten_tinh_trang=N'Đang ở bãi' order by ngay_tao desc"; SqlDataReader dr = data.ExcuteDataReader(sql, null); if (dr != null) { while (dr.Read()) { DTO_Xe xe = new DTO_Xe(); xe.ma_so_xe = dr["ma_so_xe"].ToString(); xe.ma_tinh_trang = Convert.ToInt32(dr["ma_tinh_trang"].ToString()); xe.loai_xe = dr["loai_xe"].ToString(); xe.nhan_hieu = dr["nhan_hieu"].ToString(); xe.trong_luong = Convert.ToInt32(dr["trong_luong"].ToString()); xe.ngay_tao = Convert.ToDateTime(dr["ngay_tao"].ToString()); xe.ten_tinh_trang = dr["ten_tinh_trang"].ToString(); listxe_1.Add(xe); } data.DisConnect(); } return(listxe_1); }
public bool themXe(DTO_Xe _dxe) { return(dalTiepnhanxe.themXe(_dxe)); }
public bool Create_Xe(DTO_Xe xe) { return(dal_xe.Create_Xe(xe)); }
public bool ThemXe(DTO_Xe xe) { return(dalThemXe.ThemXe(xe)); }
public bool Update_Xe(DTO_Xe xe) { return(dal_xe.Update_Xe(xe)); }
public DTO_Xe[] _Tim_ThongTinXe(DTO_Xe xe) { return(new DAL_TraCuu()._Tim_ThongTinXe(xe)); }
public List <DTO_Xe> Get_TrongLuongXe(DTO_Xe dto) { return(dx.Get_TrongLuongXe(dto)); }