/// <summary> /// Hàm lưu hộ chiếu /// </summary> /// <param name="list">Danh sách lỗ khoan cần lưu</param> /// <param name="_id">ID hộ chiếu</param> /// <returns>bool</returns> public static bool LuuBanVe(List <LoKhoan> list, String _id) { if (list.Count == 0) { return(true); } Connection conn = new Connection(); List <LoKhoan> lk = BS_LoKhoan.DanhSachLoKhoan(_id); String sql = ""; if (lk.Count == 0) { foreach (LoKhoan newValue in list) { sql = "INSERT INTO LoKhoan (MaHoChieu, MaBanVe, MaMayKhoan, MaLK, BanKinhLK, ChieuSauLK, HuongKhoan, ToaDoX, ToaDoY) VALUES ('" + newValue.MaHoChieu + "','" + newValue.MaBanVe + "','" + newValue.MaMayKhoan + "','" + newValue.MaLoKhoan + "','" + newValue.BanKinh + "','" + newValue.ChieuSau + "','" + newValue.HuongKhoan + "','" + Math.Round(newValue.ToaDoX, 2) + "','" + Math.Round(newValue.ToaDoY, 2) + "')"; conn.SetData(sql); } } else { sql = "DELETE FROM LoKhoan WHERE MaHoChieu = '" + _id + "'"; conn.SetData(sql); foreach (LoKhoan newValue in list) { sql = "INSERT INTO LoKhoan (MaHoChieu, MaBanVe, MaMayKhoan, MaLK, BanKinhLK, ChieuSauLK, HuongKhoan, ToaDoX, ToaDoY) VALUES ('" + newValue.MaHoChieu + "','" + newValue.MaBanVe + "','" + newValue.MaMayKhoan + "','" + newValue.MaLoKhoan + "','" + newValue.BanKinh + "','" + newValue.ChieuSau + "','" + newValue.HuongKhoan + "','" + Math.Round(newValue.ToaDoX, 2) + "','" + Math.Round(newValue.ToaDoY, 2) + "')"; conn.SetData(sql); } } return(true); }
/// <summary> /// Hàm lưu bản vẽ (ko dùng nữa) /// </summary> /// <param name="list">Danh sách lỗ khoan cần lưu</param> /// <param name="_id">ID bản vẽ</param> /// <param name="idTemplate">ID Template(để "" nếu không thay đổi)</param> /// <returns>bool</returns> public static bool LuuBanVe(List <LoKhoan> list, String _id, String idTemplate) { if (list.Count == 0) { return(true); } Connection conn = new Connection(); List <LoKhoan> lk = BS_LoKhoan.DanhSachLoKhoan(_id); String sql = ""; if (lk.Count == 0) { foreach (LoKhoan newValue in list) { sql = "INSERT INTO LoKhoan (MaHoChieu, MaBanVe, MaMayKhoan, MaLK, BanKinhLK, ChieuSauLK, HuongKhoan, ToaDoX, ToaDoY) VALUES ('" + newValue.MaHoChieu + "','" + newValue.MaBanVe + "','" + newValue.MaMayKhoan + "','" + newValue.MaLoKhoan + "','" + newValue.BanKinh + "','" + newValue.ChieuSau + "','" + newValue.HuongKhoan + "','" + newValue.ToaDoX + "','" + newValue.ToaDoY + "')"; conn.SetData(sql); } } else { sql = "DELETE FROM LoKhoan WHERE MaBanVe = '" + _id + "'"; conn.SetData(sql); foreach (LoKhoan newValue in list) { sql = "INSERT INTO LoKhoan (MaHoChieu, MaBanVe, MaMayKhoan, MaLK, BanKinhLK, ChieuSauLK, HuongKhoan, ToaDoX, ToaDoY) VALUES ('" + newValue.MaHoChieu + "','" + newValue.MaBanVe + "','" + newValue.MaMayKhoan + "','" + newValue.MaLoKhoan + "','" + newValue.BanKinh + "','" + newValue.ChieuSau + "','" + newValue.HuongKhoan + "','" + newValue.ToaDoX + "','" + newValue.ToaDoY + "')"; conn.SetData(sql); } } //cập nhật template if (idTemplate.Equals(String.Empty)) { return(true); } else { sql = "UPDATE BanVe SET Template = '" + idTemplate + "' WHERE ID = '" + _id + "'"; conn.SetData(sql); } return(true); }