Exemplo n.º 1
0
        private void OnSubmit(object sender, RoutedEventArgs e)
        {
            String curStateString = cbTrangThai.Text;
            int    curState       = 1;

            if (curStateString.Equals("Đang đi"))
            {
                curState = 0;
            }

            chuyenDiDAOImpl.updateTrangThai(this.maChuyenDi, curState);

            //ChuyenDi newTrip = new ChuyenDi(maChuyenDi, curState, description);
            //chuyenDiDAOImpl.addChuyenDi(newTrip);

            if (extraExpense.Count() > 0)
            {
                foreach (MucChi mucChi in extraExpense)
                {
                    mucChiDAOlmpl.addMucChi(mucChi);
                }
            }

            if (milestones.Count() > 0)
            {
                foreach (CacMocLoTrinh milistone in milestones)
                {
                    cacMocLoTrinhDAOlmpl.addCacMocLoTrinh(milistone);
                }
            }

            if (members.Count() > 0)
            {
                foreach (ThanhVien member in members)
                {
                    thanhVienDAOlmpl.addThanhVien(member);
                }

                foreach (CHUYENDI_THANHVIEN trip_member in trip_memberList)
                {
                    chuyenDiThanhVienDAOImpl.addChuyenDiThanhVien(trip_member);
                }
            }



            if (fileList.Count() > 0)
            {
                var currentFolder = AppDomain.CurrentDomain.BaseDirectory;

                foreach (string file in fileList)
                {
                    var info    = new FileInfo(file);
                    var newName = $"{Guid.NewGuid()}{info.Extension}";
                    File.Copy(file, $"{currentFolder}Assets\\Images\\{newName}");
                    HinhAnhChuyenDi newImage = new HinhAnhChuyenDi()
                    {
                        HinhAnh = newName, MaChuyenDi = this.maChuyenDi
                    };
                    hinhAnhChuyenDiDAOlmpl.addHinhAnhChuyenDi(newImage);
                }
            }

            MessageBox.Show("Đã hoàn thành");
        }
Exemplo n.º 2
0
        private void OnSubmit(object sender, RoutedEventArgs e)
        {
            String tripName       = txtTripName.Text;
            String curStateString = cbTrangThai.Text;
            String location       = txtLocation.Text;
            String description    = txtDescription.Text;

            if (tripName == "")
            {
                MessageBox.Show("Bạn chưa nhập tên chuyến đi");
            }
            else if (location == "")
            {
                MessageBox.Show("Bạn chưa nhập địa điểm chuyến đi");
            }

            int curState = 1;

            if (curStateString.Equals("Đang đi"))
            {
                curState = 0;
            }

            ChuyenDi newTrip = new ChuyenDi(maChuyenDi, tripName, curState, location, description, anhbiaChuyenDi);

            chuyenDiDAOImpl.addChuyenDi(newTrip);

            if (extraExpense.Count() > 0)
            {
                foreach (MucChi mucChi in extraExpense)
                {
                    mucChiDAOlmpl.addMucChi(mucChi);
                }
            }

            if (milestones.Count() > 0)
            {
                foreach (CacMocLoTrinh milistone in milestones)
                {
                    cacMocLoTrinhDAOlmpl.addCacMocLoTrinh(milistone);
                }
            }

            if (members.Count() > 0)
            {
                foreach (ThanhVien member in members)
                {
                    thanhVienDAOlmpl.addThanhVien(member);
                }

                foreach (CHUYENDI_THANHVIEN trip_member in trip_memberList)
                {
                    chuyenDiThanhVienDAOImpl.addChuyenDiThanhVien(trip_member);
                }
            }



            if (fileList.Count() > 0)
            {
                //foreach(HinhAnhChuyenDi image in images)
                //{
                //    hinhAnhChuyenDiDAOlmpl.addHinhAnhChuyenDi(image);
                //}

                var currentFolder = AppDomain.CurrentDomain.BaseDirectory;

                foreach (string file in fileList)
                {
                    var info    = new FileInfo(file);
                    var newName = $"{Guid.NewGuid()}{info.Extension}";
                    File.Copy(file, $"{currentFolder}Assets\\Images\\{newName}");
                    HinhAnhChuyenDi newImage = new HinhAnhChuyenDi()
                    {
                        HinhAnh = newName, MaChuyenDi = this.maChuyenDi
                    };
                    hinhAnhChuyenDiDAOlmpl.addHinhAnhChuyenDi(newImage);
                }
            }
            //ChuyenDi newTrip = new ChuyenDi(maChuyenDi, tripName, curState, location, description, anhbia);
            //chuyenDiDAOImpl.addChuyenDi(newTrip);
            if (anhbiaChuyenDi != "")
            {
                var    currentFolder = AppDomain.CurrentDomain.BaseDirectory;
                string file          = AvatarName;
                File.Copy(file, $"{currentFolder}Assets\\Images\\{newNameAvt}");
            }
            MessageBox.Show("Đã hoàn thành");
        }