private void btnCapNhat_Click(object sender, EventArgs e) { try { Tre tre = new Tre(); tre.MaTre = maTre; tre.HoTenTre = txtHoTen.Text; if (rdoNam.Checked) { tre.GioiTinh = "Nam"; } else { tre.GioiTinh = "Nu"; } tre.NgaySinh = dtNgaySinh.Value; tre.HoTenCha = txtHoTenBo.Text; tre.HoTenMe = txtHoTenMe.Text; tre.DiaChi = txtDiaChi.Text; tre.SoDT = txtDienThoai.Text; MessageBox.Show(tre.MaTre); TreBLL.CapNhatThongTinTre(tre); MessageBox.Show("Cập nhật thành công", "Thông báo"); GetDataGridView(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Thông báo"); } }
private void btnSua_Click(object sender, EventArgs e) { try { if (txtHoTen.Text.Length > 50 || txtHoTenCha.Text.Length > 50 || txtHoTenMe.Text.Length > 50 || txtDiaChi.Text.Length > 100) { MessageBox.Show("Các trường họ tên không được quá dài (ít hơn 50 ký tự)", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrEmpty(txtHoTen.Text) || String.IsNullOrEmpty(txtHoTenCha.Text) || String.IsNullOrEmpty(txtHoTenMe.Text) || String.IsNullOrEmpty(txtDiaChi.Text) || String.IsNullOrEmpty(txtSDT.Text)) { MessageBox.Show("Phải nhập đầy đủ trưởng thông tin. Không có ghi rõ: 'Không có'", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((DateTime.Now - dateNgaySinh.Value).TotalDays <= 1095 || (DateTime.Now - dateNgaySinh.Value).TotalDays >= 2190) { MessageBox.Show("Nhà trường chỉ nhận trẻ từ 3 đến 6 tuổi vào học", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Tre tre = new Tre(); tre.MaTre = maTre; tre.HoTen = txtHoTen.Text; if (rdbNam.Checked) { tre.GioiTinh = (int)GioiTinh.Nam; } else { tre.GioiTinh = (int)GioiTinh.Nu; } tre.NgaySinh = dateNgaySinh.Value; tre.TenCha = txtHoTenCha.Text; tre.TenMe = txtHoTenMe.Text; tre.DiaChi = txtDiaChi.Text; tre.DienThoai = txtSDT.Text; TreBLL.CapNhatThongTinTre(tre); MessageBox.Show("Cập nhật thành công", "Thông báo"); loadDataGridView(); } catch (Exception ex) { MessageBox.Show("Cập nhật không thành công.\nHãy xem lại thông tin nhập", "Thông báo"); } }
public static bool CapNhatThongTinTre(Tre tre) { try { TreDAL.CapNhatThongTinTre(tre); } catch (Exception ex) { return(false); } return(true); }
private void btnThem_Click(object sender, EventArgs e) { if (txtHoTen.Text.Length > 50 || txtHoTenCha.Text.Length > 50 || txtHoTenMe.Text.Length > 50 || txtDiaChi.Text.Length > 100) { MessageBox.Show("Các trường họ tên không được quá dài (ít hơn 50 ký tự)", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrEmpty(txtHoTen.Text) || String.IsNullOrEmpty(txtHoTenCha.Text) || String.IsNullOrEmpty(txtHoTenMe.Text) || String.IsNullOrEmpty(txtDiaChi.Text) || String.IsNullOrEmpty(txtSDT.Text)) { MessageBox.Show("Phải nhập đầy đủ trưởng thông tin. Không có ghi rõ: 'Không có'", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((DateTime.Now - dateNgaySinh.Value).TotalDays <= 1095 || (DateTime.Now - dateNgaySinh.Value).TotalDays >= 2190) { MessageBox.Show("Nhà trường chỉ nhận trẻ từ 3 đến 6 tuổi vào học", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Tre hocsinhmoi = new Tre(txtMaHocSinh.Text, txtHoTen.Text, rdbNam.Checked == true ? (int)GioiTinh.Nam : (int)GioiTinh.Nu, Convert.ToDateTime(dateNgaySinh.Value.ToShortDateString()), txtHoTenCha.Text, txtHoTenMe.Text, txtDiaChi.Text, txtSDT.Text); string ngaytiepnhan = DateTime.Now.ToString("dd-MM-yyyy"); PhieuTiepNhanTre phieumoi = new PhieuTiepNhanTre(txtMaHocSinh.Text, txtMaPhieu.Text, ngaytiepnhan, txtNguoiTiepNhan.Text); try { if (TreBLL.ThemTre(hocsinhmoi) && PhieuTiepNhanBLL.ThemPhieu(phieumoi)) { MessageBox.Show("Đã thêm trẻ thành công", "Thông báo", MessageBoxButtons.OK); CleanInput(); loadDataGridView(); } else { MessageBox.Show("Lỗi khi thêm trẻ", "Thông báo", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("Vui lòng nhập đầy đủ thông tin cần thiết!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static bool ThemTre(Tre hocsinhmoi) { DataTable dt = TreDAL.ThemTre(hocsinhmoi); foreach (DataRow row in dt.Rows) { if (row.ItemArray[0].ToString().Trim() == "0") { return(true); } } return(false); }
private void btnCapNhat_Click(object sender, System.EventArgs e) { Tre tempTre = new Tre(txtMaTre.Text, txtHoTen.Text, rdoNam.Checked ? 1 : 0, dtNgaySinh.Value, txtHoTenCha.Text, txtHoTenMe.Text, txtDiaChi.Text, txtSDT.Text); if (TreBLL.CapNhatThongTinTre(tempTre)) { MessageBox.Show("Cập nhật thông tin trẻ thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); loadDataGirdView(); } }
public static void CapNhatThongTinTre(Tre tre) { DataAccessHelper db = new DataAccessHelper(); SqlCommand cmd = db.Command("SUATTTRE"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MaTre", tre.MaTre); cmd.Parameters.AddWithValue("@TenTre", tre.HoTenTre); cmd.Parameters.AddWithValue("@GioiTinh", tre.GioiTinh); cmd.Parameters.AddWithValue("@NgaySinh", tre.NgaySinh); cmd.Parameters.AddWithValue("@TenBo", tre.HoTenCha); cmd.Parameters.AddWithValue("@TenMe", tre.HoTenMe); cmd.Parameters.AddWithValue("@DiaChi", tre.DiaChi); cmd.Parameters.AddWithValue("@DienThoai", tre.SoDT); SqlDataAdapter da = new SqlDataAdapter(cmd); db.dt = new DataTable(); da.Fill(db.dt); }
public static void ThemTreVaoDBTuExcel(DataTable data, string ngayTiepNhan, string nguoiTiepNhan) { if (data == null || data.Rows.Count == 0) { MessageBox.Show("Không có dữ liệu để import"); return; } try { for (int i = 0; i < data.Rows.Count; i++) { string maTre = TreBLL.GenMaTre(); Tre tre = new Tre(maTre, data.Rows[i][0].ToString().Trim(), // Họ tên Convert.ToInt32(data.Rows[i][1].ToString()), // Giới tính, DateTime.Parse(data.Rows[i][2].ToString().Trim()), // Ngày sinh data.Rows[i][3].ToString().Trim(), // Họ tên cha data.Rows[i][4].ToString().Trim(), // Họ tên mẹ data.Rows[i][5].ToString().Trim(), // Địa chỉ data.Rows[i][6].ToString().Trim()); // SĐT PhieuTiepNhanTre phieumoi = new PhieuTiepNhanTre(maTre, PhieuTiepNhanBLL.GenMaPhieu(), ngayTiepNhan, nguoiTiepNhan); try { TreBLL.ThemTre(tre); PhieuTiepNhanBLL.ThemPhieu(phieumoi); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } MessageBox.Show("Import hoàn tất", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("File nhập vào không đúng định dạng!\nVui lòng xem HDSD để chuẩn bị file có định dạng đúng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void CapNhatThongTinTre(Tre tre) { DataAccessHelper.GetInstance().Open(); SqlCommand cmd = DataAccessHelper.GetInstance().Command("SUATTTRE"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MaTre", tre.MaTre); cmd.Parameters.AddWithValue("@TenTre", tre.HoTen); cmd.Parameters.AddWithValue("@GioiTinh", tre.GioiTinh); cmd.Parameters.AddWithValue("@NgaySinh", tre.NgaySinh); cmd.Parameters.AddWithValue("@TenBo", tre.TenCha); cmd.Parameters.AddWithValue("@TenMe", tre.TenMe); cmd.Parameters.AddWithValue("@DiaChi", tre.DiaChi); cmd.Parameters.AddWithValue("@DienThoai", tre.DienThoai); SqlDataAdapter da = new SqlDataAdapter(cmd); DataAccessHelper.GetInstance().SetDataTable(new DataTable()); da.Fill(DataAccessHelper.GetInstance().GetDataTable()); DataAccessHelper.GetInstance().Close(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //Human person = new Human("Allisa"); //Human person2 = new Human(); // Human is the base class for these 3 classes // Tre and Jimmy are derived classes // John is a derived class from Jimmy // Thus, Jimmy is both a base class and a derived class Jimmy jimmy = new Jimmy(); Tre tre = new Tre(); John john = new John(); // can't do this, because Robot is abstract // Robot neth = new Robot(); Jeff jeff = new Jeff("Jeff", 34); string answer = jeff.TakeOverTheWorld(); Console.WriteLine(answer); // these four can be in the same array because they // are all derived from the Creature class Creatures[] myHumans = { jimmy, john, tre, jeff }; for (int i = 0; i < myHumans.Length; i++) { if (myHumans[i] is Human) { // this outputs only 3 humans // because jeff is a robot Console.WriteLine($"{myHumans[i].Name} is human."); } } }
public static void CapNhatThongTinTre(Tre tre) { TreDAL.CapNhatThongTinTre(tre); }
//Распределительный метод public void DistributionMethod(StreamWriter streamWriter) { //Находим первый опорный план FirstSupportPlan(); streamWriter.WriteLine("Первый опорный план"); PrintMatr(streamWriter); List <Tre> listLoop = new List <Tre>(); //Проходимся по всей матрице X и для пустых клеток составляем цикл пересчета for (int i = 0; i < a.Length; i++) { for (int j = 0; j < b.Length; j++) { if (x[i, j] == 0) { listLoop.Add(new Tre(i, j, 1)); Loop(ref listLoop); int g = Gamma(listLoop); if (g < 0) { //Находим в клетках с отрицательным знаком минимальный элемент Tre min = listLoop[1]; for (int ij = 3; ij < listLoop.Count; ij += 2) { if (x[min.I, min.J] > x[listLoop[ij].I, listLoop[ij].J]) { min = listLoop[ij]; } } //streamWriter.Write("min = {0}. ", x[min.I, min.J]); //Производим сдвиг по циклу пересчета int tmp = x[min.I, min.J]; for (int ij = 0; ij < listLoop.Count; ij++) { x[listLoop[ij].I, listLoop[ij].J] += tmp * listLoop[ij].Zn; } //Проверяем матрицу X заново i = j = 0; streamWriter.Write("Произвели сдвиг по циклу [g = {0}]: ", g); for (int ij = 0; ij < listLoop.Count; ij++) { streamWriter.Write("[{0}, {1}]", listLoop[ij].I + 1, listLoop[ij].J + 1); } streamWriter.WriteLine(); PrintMatr(streamWriter); } listLoop.RemoveRange(0, listLoop.Count); } } } //PrintMatr(streamWriter); int summ = 0; //Вычисляем значение целевой функции for (int i = 0; i < a.Length; i++) { for (int j = 0; j < b.Length; j++) { summ += c[i, j] * x[i, j]; } } streamWriter.WriteLine("Z = {0}", summ); }