private void bt_luu_Click(object sender, EventArgs e) { if (check_null()) { ThayDoiQuyDinhDTO thaydoi = thaydoiBus.select(); int line = data_vtpt.RowCount; if (line < thaydoi.SoLoaiVTPT1) { VatTuPhuTungDTO vtpt = new VatTuPhuTungDTO(); vtpt.Maloaivattu = int.Parse(tb_mavtpt.Text); vtpt.Tenloaivattu = tb_tenvtpt.Text; vtpt.Soluongton = int.Parse(tb_soluongton.Text); vtpt.Dongia = int.Parse(tb_dongia.Text); bool kq = vtptBus.them(vtpt); if (kq == false) { MessageBox.Show("Thêm vật tư phụ tùng thất bại. Vui lòng kiểm tra lại dữ liệu"); } else { MessageBox.Show("Thêm vật tư phụ tùng thành công"); this.loadData_Vao_GridView(); } CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_vtpt.DataSource]; myCurrencyManager.Refresh(); } else { MessageBox.Show("Vượt quá số vtpt cho phép"); } } }
private void bt_luu_Click(object sender, EventArgs e) { if (check_null()) { ThayDoiQuyDinhDTO thaydoi = thaydoiBus.select(); int line = data_tiencong.RowCount; if (line < thaydoi.SoLoaiTienCong1) { TienCongDTO tc = new TienCongDTO(); tc.Maloaitiencong = int.Parse(tb_matiencong.Text); tc.Tenloaitiencong = tb_tenloaitc.Text; tc.Tiencong = int.Parse(tb_tiencong.Text); bool kq = tcBus.them(tc); if (kq == false) { MessageBox.Show("Thêm tiền công thất bại. Vui lòng kiểm tra lại dữ liệu"); } else { MessageBox.Show("Thêm tiền công thành công"); this.loadData_Vao_GridView(); } CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_tiencong.DataSource]; myCurrencyManager.Refresh(); } else { MessageBox.Show("Vượt quá số tiền công cho phép"); } } }
private void bt_luu_Click(object sender, EventArgs e) { if (check_null()) { ThayDoiQuyDinhDTO thaydoi = thaydoiBus.select(); int line = data_hieuxe.RowCount; if (line < thaydoi.SoLuongHieuXe1) { HieuXeDTO hx = new HieuXeDTO(); hx.Mahieuxe = int.Parse(tb_mahieuxe.Text); hx.Tenhieuxe = tb_hieuxe.Text; bool kq = hxBus.them(hx); if (kq == false) { MessageBox.Show("Thêm hiệu xe thất bại. Vui lòng kiểm tra lại dữ liệu"); } else { MessageBox.Show("Thêm hiệu xe thành công"); this.loadData_Vao_GridView(); } CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_hieuxe.DataSource]; myCurrencyManager.Refresh(); } else { MessageBox.Show("Vượt quá số hiệu xe cho phép"); } } }
public bool ThayDoiQD(ThayDoiQuyDinhDTO thaydoi) { string query = string.Empty; query += "UPDATE THAMSO SET [SoLuongHieuXe] = @SoLuongHieuXe,[SoLoaiVTPT] = @SoLoaiVTPT,[SoLuongSuaChuaToiDa] = @SoLuongSuaChuaToiDa,[SoLoaiTienCong] = @SoLoaiTienCong"; 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("@SoLuongHieuXe", thaydoi.SoLuongHieuXe1); cmd.Parameters.AddWithValue("@SoLoaiVTPT", thaydoi.SoLoaiVTPT1); cmd.Parameters.AddWithValue("@SoLuongSuaChuaToiDa", thaydoi.SoLuongSuaChuaToiDa1); cmd.Parameters.AddWithValue("@SoLoaiTienCong", thaydoi.SoLoaiTienCong1); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); con.Dispose(); } catch (Exception ex) { con.Close(); return(false); } } } return(true); }
private void loadData_Vao_Textbox() { ThayDoiQuyDinhDTO thaydoi = thaydoiBus.select(); if (thaydoi == null) { MessageBox.Show("Có lỗi khi lấy DB"); return; } tb_sohieuxe.Text = thaydoi.SoLuongHieuXe1.ToString(); tb_max_xe.Text = thaydoi.SoLuongSuaChuaToiDa1.ToString(); tb_sotiencong.Text = thaydoi.SoLoaiTienCong1.ToString(); tb_sovattu.Text = thaydoi.SoLoaiVTPT1.ToString(); }
public ThayDoiQuyDinhDTO select() { string query = string.Empty; query += "SELECT *"; query += " FROM [THAMSO]"; ThayDoiQuyDinhDTO thaydoi = new ThayDoiQuyDinhDTO(); //List<ThayDoiQuyDinhDTO> lsThayDoi = new List<ThayDoiQuyDinhDTO>(); using (SqlConnection con = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; try { con.Open(); SqlDataReader reader = null; reader = cmd.ExecuteReader(); if (reader.HasRows == true) { while (reader.Read()) { thaydoi.SoLuongHieuXe1 = int.Parse(reader["SoLuongHieuXe"].ToString()); thaydoi.SoLuongSuaChuaToiDa1 = int.Parse(reader["SoLuongSuaChuaToiDa"].ToString()); thaydoi.SoLoaiVTPT1 = int.Parse(reader["SoLoaiVTPT"].ToString()); thaydoi.SoLoaiTienCong1 = int.Parse(reader["SoLoaiTienCong"].ToString()); } } con.Close(); con.Dispose(); } catch (Exception ex) { con.Close(); return(null); } } } return(thaydoi); }
private void bt_luu_Click(object sender, EventArgs e) { ThayDoiQuyDinhDTO thaydoi = new ThayDoiQuyDinhDTO(); thaydoi.SoLuongHieuXe1 = int.Parse(tb_sohieuxe.Text); thaydoi.SoLuongSuaChuaToiDa1 = int.Parse(tb_max_xe.Text); thaydoi.SoLoaiTienCong1 = int.Parse(tb_sotiencong.Text); thaydoi.SoLoaiVTPT1 = int.Parse(tb_sovattu.Text); //2. Kiểm tra data hợp lệ or not //3. Thêm vào DB bool kq = thaydoiBus.ThayDoiQD(thaydoi); if (kq == false) { MessageBox.Show("Thất bại. Vui lòng kiểm tra lại dữ liệu"); } else { MessageBox.Show("Thành công"); } loadData_Vao_Textbox(); }
public bool ThayDoiQD(ThayDoiQuyDinhDTO tdqd) { bool re = tdqdDal.ThayDoiQD(tdqd); return(re); }