public DataTable GetListNSX() { var data = dAL.GetListNSX(); DatabaseDAL.CloseConnection(); return(data); }
public DataTable ThongKeXuatNhapTon(DateTime lastMonth, DateTime currentMonth) { var data = DatabaseDAL.ReadData("exec USP_KiemKeKho @lastMonth , @currentMonth ", new object[] { lastMonth, currentMonth }); DatabaseDAL.CloseConnection(); return(data); }
public void TestGetFamilyID() { DatabaseDAL readerDAL = new DatabaseDAL(_connectionString); Family family = new Family(); family.FamilyName = "Testing1234"; family.ID = readerDAL.CreateFamily(family); User user = new User(); user.FirstName = "Jose"; user.LastName = "Martino"; user.Password = "******"; PasswordHash ph = new PasswordHash(user.Password); user.Salt = ph.Salt; user.Password = ph.Hash; user.Username = "******"; user.FamilyID = family.ID; user.FamilyName = family.FamilyName; User newUser = readerDAL.CreateUser(user); user = readerDAL.GetUserByUsername(newUser.Username); Assert.AreEqual(user.FamilyID, family.ID); }
public void TestRegistration() { DatabaseDAL readerDAL = new DatabaseDAL(_connectionString); Family family = new Family(); family.FamilyName = "Hostetter"; int familyID = readerDAL.CreateFamily(family); User user = new User(); user.FirstName = "Ann"; user.LastName = "Hostetter"; user.Password = "******"; PasswordHash ph = new PasswordHash(user.Password); user.Salt = ph.Salt; user.Password = ph.Hash; user.Username = "******"; user.FamilyID = familyID; user.FamilyName = family.FamilyName; User newUser = readerDAL.CreateUser(user); Assert.AreEqual(user.FamilyID, familyID); }
public DataTable GetListPhieuNhap() { PhieuNhapDAL dAL = new PhieuNhapDAL(); var data = dAL.GetListPhieuNhap(); DatabaseDAL.CloseConnection(); return(data); }
public bool InsertChiTietPhieuNhap(ChiTietPhieuNhap chiTiet) { ChiTietPhieuNhapDAL dAL = new ChiTietPhieuNhapDAL(); var data = dAL.InsertChiTietPhieuNhap(chiTiet); DatabaseDAL.CloseConnection(); return(data); }
public bool InsertPhieuNhapKho(PhieuNhapKho phieuNhap, DataGridView dataGridView) { bool result = false; PhieuNhapDAL phieuNhapDAL = new PhieuNhapDAL(); ChiTietPhieuNhapDAL chiTietPhieuNhapDAL = new ChiTietPhieuNhapDAL(); try { if (!DatabaseDAL.TestConnection()) { DatabaseDAL.CreatConn(); } DatabaseDAL.Transaction(); try { result = phieuNhapDAL.InsertPhieuNhapHang(phieuNhap); for (int i = 0; i < dataGridView.RowCount; i++) { if (dataGridView.Rows[i].Cells["STT"].Value != null) { ChiTietPhieuNhap chiTietPhieu = new ChiTietPhieuNhap(); chiTietPhieu.SoChungTu = phieuNhap.SoChungTu; chiTietPhieu.MaHang = dataGridView.Rows[i].Cells["MaHang"].Value?.ToString(); chiTietPhieu.TenHang = dataGridView.Rows[i].Cells["TenHang"].Value?.ToString(); chiTietPhieu.DonViTinh = dataGridView.Rows[i].Cells["DonVitinh"].Value?.ToString(); chiTietPhieu.SoLuongNhap = Convert.ToInt32(dataGridView.Rows[i].Cells["SoLuongNhap"].Value?.ToString()); chiTietPhieu.DonGia = Convert.ToInt32(dataGridView.Rows[i].Cells["DonGia"]?.Value?.ToString()); chiTietPhieu.ThanhTien = Convert.ToDecimal(dataGridView.Rows[i].Cells["ThanhTien"].Value?.ToString()); if (!isEmptyOrNullOrSpecialCharacters(chiTietPhieu.SoChungTu) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.MaHang) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.TenHang) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.DonViTinh) && !isEmptyOrNotNumber(chiTietPhieu.SoLuongNhap) && !isEmptyOrNotNumber(chiTietPhieu.DonGia) && !isEmptyOrNotNumber(chiTietPhieu.ThanhTien)) { if (!isBelongToNSX(chiTietPhieu.MaHang, phieuNhap.MaNSX)) { DatabaseDAL.Rollback(); return(false); } result = chiTietPhieuNhapDAL.InsertChiTietPhieuNhap(chiTietPhieu); } } } DatabaseDAL.Commit(); DatabaseDAL.CloseConnection(); return(result); } catch (Exception e) { MessageBox.Show(e.Message); DatabaseDAL.Rollback(); DatabaseDAL.CloseConnection(); return(false); } } catch (Exception e) { DatabaseDAL.CloseConnection(); MessageBox.Show(e.Message); return(false); } }
public void CheckFamilyID() { DatabaseDAL readerDAL = new DatabaseDAL(_connectionString); Family family = new Family(); family.FamilyName = "Testingtesttest2"; int familyID = readerDAL.CreateFamily(family); Assert.AreNotEqual(0, familyID); }
static void Main(string[] args) { var myDal = new DatabaseDAL(); var all = myDal.GetAllAccounts().Count(); //foreach (var item in all) //{ // Console.WriteLine(item.Login + " - " + item.Password); //} Console.WriteLine(all.ToString()); }
public void CreateIfNotExists() { //var fileName = "FormotsDatabase.sdf"; //string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //// Set the data directory to the users %AppData% folder //// So the database file will be placed in: C:\\Users\\<Username>\\AppData\\Roaming\\ //AppDomain.CurrentDomain.SetData("DataDirectory", path); //string solutiondir = Directory.GetParent( // Directory.GetCurrentDirectory()).Parent.FullName; //string[] names = typeof(Database).Assembly.GetManifestResourceNames(); //string saveDir = Directory.GetCurrentDirectory(); ////var tititit = FormotsDAL.Resources. ////var formotsDal = System.Reflection.Assembly.LoadFrom("FormotsDAL").GetManifestResourceStream("FormotsDatabase.sdf"); //// Enure that the database file is present //if (!System.IO.File.Exists(System.IO.Path.Combine(path, fileName))) //{ // //Get path to our .exe, which also has a copy of the database file // var exePath = System.IO.Path.GetDirectoryName( // new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); // //Copy the file from the .exe location to the %AppData% folder // System.IO.File.Copy( // System.IO.Path.Combine(exePath, fileName), // System.IO.Path.Combine(path, fileName)); //} DatabaseDAL.CreateIfNotExists(); //var assembly = Assembly.GetExecutingAssembly(); //var resourceName = "MyCompany.MyProduct.MyFile.txt"; //using (Stream stream = assembly.GetManifestResourceStream(resourceName)) //using (StreamReader reader = new StreamReader(stream)) //{ // string result = reader.ReadToEnd(); //} }
public PhotographerBL(DatabaseDAL databaseDAL) { _databaseDAL = databaseDAL; }
public PictureBL(FileDAL fileDAL, DatabaseDAL databaseDAL) { _fileDAL = fileDAL; _databaseDAL = databaseDAL; }
public VMUser(User user, List <Project> projectsUserHasContributedTo = null) { FirstName = user.FirstName; LastName = user.LastName; Email = user.Email; ContactInfos = new List <VMContactInfo>(); LastDailyReportSendTime = user.LastDailyReportSendTime; ViewsSinceLastReport = user.ViewsSinceLastReport; TotalViews = user.TotalViews; if (user.ContactInfoes != null && user.ContactInfoes.Count > 0) { foreach (ContactInfo c in user.ContactInfoes) { ContactInfos.Add(new VMContactInfo(c)); } } Education = new List <VMEducation>(); if (user.Educations != null && user.Educations.Count > 0) { foreach (Education e in user.Educations) { Education.Add(new VMEducation(e)); } } Links = new List <VMLink>(); if (user.Links != null && user.Links.Count > 0) { foreach (Link l in user.Links) { Links.Add(new VMLink(l)); } } ProjectCatalog = new List <VMProject>(); if (projectsUserHasContributedTo != null && projectsUserHasContributedTo.Count > 0) { foreach (Project p in projectsUserHasContributedTo) { ProjectCatalog.Add(new VMProject(p, user.Id)); } } Portfolios = new List <VMPortfolio>(); if (user.Portfolios != null && user.Portfolios.Count > 0) { foreach (Portfolio p in user.Portfolios) { Portfolios.Add(new VMPortfolio(p)); } if (user.Portfolios.Any(p => p.IsMainPortfolio)) { MainPortfolio = new VMPortfolio(user.Portfolios.Where(p => p.IsMainPortfolio).FirstOrDefault()); } } DatabaseDAL data = new DatabaseDAL(); QuickContacts = new List <VMQuickContact>(); if (user.QuickReferences != null && user.QuickReferences.Count > 0) { foreach (QuickReference q in user.QuickReferences) { QuickContacts.Add(new VMQuickContact(data.retrieveUser(q.QuickReferenceId))); } } UserId = user.Id; Notifications = new List <VMNotification>(); if (user.Notifications != null && user.Notifications.Count > 0) { foreach (var n in user.Notifications) { Notifications.Add(new VMNotification(n)); } } }