コード例 #1
0
ファイル: ServiceDAL.cs プロジェクト: xain123/Term-Projects
        public int UpdateService(ServiceBO item)
        {
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";

            using (DataClassesDataContext data = new DataClassesDataContext(constr))
            {
                var check = from a in data.Services
                            where a.PID == item.Pid
                            select a;

                if (!check.Any())
                {
                    return(3);
                }

                Service newItem = data.Services.SingleOrDefault(x => x.PID == item.Pid);
                newItem.Phone       = item.Phone;
                newItem.Return_Date = item.ReturnDate;


                try
                {
                    data.SubmitChanges();
                    return(0);
                }
                catch (Exception e)
                {
                    return(1);
                }
            }
        }
コード例 #2
0
ファイル: ServiceDAL.cs プロジェクト: xain123/Term-Projects
        public int newService(ServiceBO item)
        {
            string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\BCS DATA\Samester 6\C Sharp\Assingment 1\DAL\styloDatabase.mdf;Integrated Security=True";

            using (DataClassesDataContext data = new DataClassesDataContext(constr))
            {
                Service newItem = new Service
                {
                    PID           = item.Pid,
                    Customer_Name = item.CustomerName,
                    Address       = item.Address,
                    Phone         = item.Phone,
                    Charges       = item.Charges,
                    Service_Date  = item.ServiceDate,
                    Return_Date   = item.ReturnDate,
                };

                data.Services.InsertOnSubmit(newItem);
                try
                {
                    data.SubmitChanges();
                    return(0);
                }
                catch (Exception e)
                {
                    return(1);
                }
            }
        }
コード例 #3
0
        public void TestListService()
        {
            ApplicationSeeder.Seed();

            var bo = new ServiceBO();

            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count > 0);
        }
コード例 #4
0
        public void TestCreateAndListService()
        {
            ApplicationSeeder.Seed();

            var bo      = new ServiceBO();
            var service = new Service("Moving property", "Transporting property/belongings", true);

            var resCreate = bo.Create(service);
            var resGet    = bo.Read(service.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
コード例 #5
0
        public void TestCreateAndListServiceProvidedAsync()
        {
            ApplicationSeeder.Seed();

            var bo        = new ServiceProvidedBO();
            var foreignBO = new ServiceBO();

            var serviceProvided = new ServiceProvided(foreignBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.CreateAsync(serviceProvided).Result;
            var resGet    = bo.ReadAsync(serviceProvided.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
コード例 #6
0
        public void TestCreateAndListJobAsync()
        {
            ApplicationSeeder.Seed();

            var bo              = new JobBO();
            var foreignBO       = new ServiceBO();
            var foreignClientBO = new ClientBO();

            var job = new Job("Setúbal N4 1323", DateTime.Now.Date.AddDays(2), DateTime.Now.Date.AddDays(2).AddMinutes(180), 23.99, "Scheduled", 0, false, foreignBO.ListUndeleted().Result.First().Id, foreignClientBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.CreateAsync(job).Result;
            var resGet    = bo.ReadAsync(job.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
コード例 #7
0
        public void TestDeleteService()
        {
            ApplicationSeeder.Seed();

            var bo = new ServiceBO();

            var resList = bo.List();
            var total   = resList.Result.Count;

            var resDelete = bo.Delete(resList.Result.First().Id);

            var list = bo.ListUndeleted();

            Assert.IsTrue(resDelete.Success && resList.Success && list.Result.Count == (total - 1));
        }
コード例 #8
0
        public void TestUpdateService()
        {
            ApplicationSeeder.Seed();

            var bo = new ServiceBO();

            var resList = bo.List();

            var item = resList.Result.FirstOrDefault();

            item.IsActive = false;

            var resUpdate = bo.Update(item);

            var list = bo.ListUndeleted();

            Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().IsActive == false);
        }
コード例 #9
0
        public void TestUpdateServiceProvidedAsync()
        {
            ApplicationSeeder.Seed();

            var bo        = new ServiceProvidedBO();
            var foreignBO = new ServiceBO();

            var resList = bo.ListAsync().Result;

            var item = resList.Result.FirstOrDefault();

            item.ServiceId = foreignBO.ListUndeleted().Result.Last().Id;

            var resUpdate = bo.UpdateAsync(item).Result;

            var list = bo.ListUndeletedAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().ServiceId == foreignBO.ListUndeleted().Result.Last().Id);
        }
コード例 #10
0
        private void addService_btn_Click(object sender, RoutedEventArgs e)
        {
            int  n;
            bool isNumeric = int.TryParse(this.price.Text, out n);
            int  n2;
            bool isNumeric2 = int.TryParse(this.size.Text, out n2);

            if (string.IsNullOrWhiteSpace(this.pid.Text))
            {
                if (string.IsNullOrWhiteSpace(this.pid.Text))
                {
                    pid.Background = Brushes.Red;
                }
                MessageBox.Show("Validate");
                return;
            }
            if ((isNumeric == false) || string.IsNullOrWhiteSpace(this.category.Text) || (isNumeric2 == false) || string.IsNullOrWhiteSpace(this.color.Text) || string.IsNullOrWhiteSpace(this.brand.Text) || string.IsNullOrWhiteSpace(this.entryDate.Text))
            {
                search_btn_Click(sender, e);
                if (string.IsNullOrWhiteSpace(this.pid.Text))
                {
                    return;
                }
            }
            int  n3;
            bool isNumeric3 = int.TryParse(this.serviceCharges.Text, out n3);

            if ((isNumeric3 == false) || string.IsNullOrWhiteSpace(this.customerName.Text) || string.IsNullOrWhiteSpace(this.address.Text) || string.IsNullOrWhiteSpace(this.phone.Text))
            {
                if ((isNumeric3 == false))
                {
                    serviceCharges.Background = Brushes.Red;
                }
                if (string.IsNullOrWhiteSpace(this.customerName.Text))
                {
                    customerName.Background = Brushes.Red;
                }
                if (string.IsNullOrWhiteSpace(this.address.Text))
                {
                    address.Background = Brushes.Red;
                }
                if (string.IsNullOrWhiteSpace(this.phone.Text))
                {
                    phone.Background = Brushes.Red;
                }
                return;
            }
            ServiceBO item = new ServiceBO();

            item.Pid          = this.pid.Text;
            item.Charges      = Convert.ToInt32(this.serviceCharges.Text);
            item.CustomerName = this.customerName.Text;
            item.Address      = this.address.Text;
            item.Phone        = this.phone.Text;
            item.ServiceDate  = this.serviceDate.Text;
            item.ReturnDate   = this.returnDate.Text;

            //MessageBox.Show(item.Pid + " " + item.Price + " " + item.Category + " " + item.Size + " " + item.Color + " " + item.Brand + " " + item.Date);

            ServiceBLL itenbl = new ServiceBLL();
            int        rv     = itenbl.addService(item);

            if (rv == 0)
            {
                MessageBox.Show("Service Added");
                this.pid.Text      = null;
                this.price.Text    = null;
                this.pid.IsEnabled = true;

                //this.quantity.Text = null;
            }
            else if (rv == 3)
            {
                MessageBox.Show("Product ID Already Exist");
                this.pid.Text      = null;
                this.pid.IsEnabled = true;
            }
            else
            {
                MessageBox.Show("Error");
                this.pid.IsEnabled = true;
            }
        }
コード例 #11
0
 public int updateService(ServiceBO item)
 {
     return(sd.UpdateService(item));
 }
コード例 #12
0
 public int addService(ServiceBO item)
 {
     return(sd.newService(item));
 }