Beispiel #1
0
 /// <summary>
 /// Create a NULL customer to conform to Null Object pattern
 /// </summary>
 /// <param name="customer"></param>
 /// <returns></returns>
 public static CustomerImpl Empty(this CustomerImpl customer)
 {
     return(new CustomerImpl()
     {
         CustomerId = NULL_ID, Address = "", Name = "", Jobs = new List <JobImpl>()
     });
 }
Beispiel #2
0
        public void AddComponentInstance_ByService()
        {
            var customer = new CustomerImpl();

            Kernel.Register(Component.For <ICustomer>().Instance(customer));
            Assert.AreSame(Kernel.Resolve <ICustomer>(), customer);
        }
Beispiel #3
0
        protected override object InternalCreate(CreationContext context)
        {
            CustomerImpl customer = new CustomerImpl();

            customer.Name = "James Bond";
            return(customer);
        }
Beispiel #4
0
        private void EditData()
        {
            try
            {
                var          obj  = new CustomerImpl();
                CustomerInfo item = obj.GetInfo(int.Parse(Request.QueryString["ID"]));

                if (item == null)
                {
                    Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                    return;
                }
                txtName.Text     = item.s_CustomerName;
                txtEmail.Text    = item.s_Email;
                txtAddress.Text  = item.s_Address;
                txtMobile.Text   = item.s_Mobile;
                txtHomepage.Text = item.s_Homepage;
                //s_img = item.s_Logo;
                HD_IMG.Value = item.s_Logo;
                IMG.ImageUrl = GetPathImgThumb(item.s_Logo);
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Add the given customer
        /// </summary>
        /// <param name="newCrsCustomer"></param>
        public void CreateCustomer(CustomerImpl newCrsCustomer)
        {
            newCrsCustomer.CustomerId = CreateNewCustomerId();

            db.CustomerImpls.Add(newCrsCustomer);
            db.SaveChanges();
        }
        protected void btDelete_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserDelete)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }
            try
            {
                int          i   = 0;
                CustomerImpl obj = new CustomerImpl();
                foreach (GridViewRow row in grvView.Rows)
                {
                    var status = (CheckBox)row.Cells[2].FindControl("StatusCheck");

                    if (status.Checked)
                    {
                        int ID = int.Parse(grvView.DataKeys[i].Value.ToString());
                        obj.Delete(ID);
                        //delete cache
                        CacheController.GetListCus_Delete();
                    }

                    i++;
                }
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
            BindGird();
        }
        /// <summary>
        /// Given a customerImpl, create a Customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public static Customer ToCustomer(this CustomerImpl customerImpl)
        {
            var customer = new Customer()
            {
                Id = customerImpl.CustomerId, Address = customerImpl.Address.TrimEnd(), Name = customerImpl.Name.TrimEnd()
            };

            return(customer);
        }
Beispiel #8
0
        /// <summary>
        /// Given a job, create a customer implemntation
        /// </summary>
        /// <param name="job"></param>
        /// <returns></returns>
        public static CustomerImpl ToCustomerImpl(this Customer customer)
        {
            var customerImpl = new CustomerImpl()
            {
                CustomerId = customer.Id, Name = customer.Name.TrimEnd(), Address = customer.Address.TrimEnd(), Jobs = null
            };

            return(customerImpl);
        }
Beispiel #9
0
        /// <summary>
        /// Given a job, create a customer implemntation
        /// </summary>
        /// <param name="job"></param>
        /// <returns></returns>
        public static CustomerImpl ToCustomerImpl(this Job job)
        {
            var customerImpl = new CustomerImpl()
            {
                CustomerId = job.Customer.Id, Address = job.Customer.Address.TrimEnd(), Name = job.Customer.Name.TrimEnd()
            };

            return(customerImpl);
        }
Beispiel #10
0
        /// <summary>
        /// Create a JobImpl from a regular Job class
        /// </summary>
        /// <param name="job"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        public static JobImpl ToJobImpl(this Job job, CustomerImpl customer)
        {
            var jobImpl = new JobImpl()
            {
                JobId = job.Id, Customer = customer, CustomerId = customer.CustomerId, Description = job.Description.TrimEnd(), State = job.State
            };

            return(jobImpl);
        }
Beispiel #11
0
        /// <summary>
        /// Given a crsCustomer, create a data model Customer
        /// </summary>
        /// <param name="crsCustomer"></param>
        /// <returns></returns>
        protected Customer CreateCustomer(CustomerImpl crsCustomer)
        {
            var customer = new Customer();

            customer.Id      = crsCustomer.CustomerId;
            customer.Name    = TrimValue(crsCustomer.Name);
            customer.Address = TrimValue(crsCustomer.Address);

            return(customer);
        }
Beispiel #12
0
        public void AddComponentInstance2()
        {
            var customer = new CustomerImpl();

            Kernel.Register(Component.For <CustomerImpl>().Named("key").Instance(customer));
            Assert.IsTrue(Kernel.HasComponent("key"));

            var customer2 = Kernel.Resolve <CustomerImpl>("key");

            Assert.AreSame(customer, customer2);

            customer2 = Kernel.Resolve <CustomerImpl>();
            Assert.AreSame(customer, customer2);
        }
            public override List <JobImpl> GetJobs()
            {
                var customer = new CustomerImpl()
                {
                    CustomerId = 1, Name = "Brass Nails           ", Address = "123           ", Jobs = null
                };
                var jobs = new List <JobImpl>();

                jobs.Add(new JobImpl()
                {
                    JobId = 1, Description = "Job1      ", CustomerId = 1, Customer = customer
                });
                return(jobs);
            }
        public void AddComponentInstance2()
        {
            CustomerImpl customer = new CustomerImpl();

            kernel.AddComponentInstance("key", customer);
            Assert.IsTrue(kernel.HasComponent("key"));

            CustomerImpl customer2 = kernel["key"] as CustomerImpl;

            Assert.AreSame(customer, customer2);

            customer2 = kernel[typeof(CustomerImpl)] as CustomerImpl;
            Assert.AreSame(customer, customer2);
        }
            public override List <JobImpl> GetJobsByCustomer(int id)
            {
                var crsCustomer = new CustomerImpl()
                {
                    CustomerId = 11, Name = "Nine Inch Nails", Jobs = null
                };

                var jobs = new List <JobImpl>();

                jobs.Add(new JobImpl()
                {
                    JobId = 1, CustomerId = 1, Description = "Job1", Customer = crsCustomer, State = 1
                });
                return(jobs);
            }
            public override JobImpl GetJob(int jobId)
            {
                if (jobId == 0)
                {
                    // simulate null object return
                    return(null);
                }

                var customer = new CustomerImpl()
                {
                    CustomerId = 1, Name = "Brass Tools", Address = "123 Fairway", Jobs = null
                };

                return(new JobImpl()
                {
                    JobId = 1, CustomerId = 1, Description = "job1", Customer = customer, State = 1
                });
            }
Beispiel #17
0
        /// <summary>
        /// Given a customerImpl, create a Customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public static Customer ToCustomer(this CustomerImpl customerImpl)
        {
            if (!string.IsNullOrEmpty(customerImpl.Address))
            {
                customerImpl.Address = customerImpl.Address.TrimEnd();
            }

            if (!string.IsNullOrEmpty(customerImpl.Name))
            {
                customerImpl.Name = customerImpl.Name.TrimEnd();
            }

            var customer = new Customer()
            {
                Id = customerImpl.CustomerId, Address = customerImpl.Address, Name = customerImpl.Name
            };

            return(customer);
        }
Beispiel #18
0
        private void BindGird()
        {
            try
            {
                CustomerImpl obj  = new CustomerImpl();
                var          list = obj.GetListCustomer();

                //dt.DefaultView.Sort = sortString;

                grvView.DataSource = list;
                grvView.DataBind();

                ltThongBao.Text = "<font color='red'>Có " + list.Count + " khách hàng được tìm thấy.</font>";
            }
            catch
            {
                Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                return;
            }
        }
Beispiel #19
0
        public static void BindCustomers(ComboBox comBox)
        {
            comBox.DropDownStyle = ComboBoxStyle.DropDownList;
            CustomerImpl services = new CustomerImpl();
            var          result   = services.GetList(new Model.Customers()
            {
                IsDel = 0
            });

            if (result.Code == 0)
            {
                result.Body.Insert(0, new Model.Customers()
                {
                    Id = 0, Name = "请选择客户"
                });
                comBox.DataSource    = result.Body;
                comBox.DisplayMember = "Name";
                comBox.ValueMember   = "Id";
            }
        }
Beispiel #20
0
        public static void Main(string[] a)
        {
            BusinessObjects.BAL.ServiceAreaImpl      SAI = new BusinessObjects.BAL.ServiceAreaImpl("");
            BusinessObjects.BAL.CustomerImpl         CI  = new CustomerImpl();
            BusinessObjects.BAL.CustomerRegistration CR  = new CustomerRegistration();
            Customer customerlist = CR.getUser(5);

            Console.WriteLine(customerlist.firstname);

            Customer customer = new Customer();

            customer.address   = "no5 anandaroad";
            customer.city      = "Chennai";
            customer.country   = "India";
            customer.DOB       = DateTime.Today;
            customer.firstname = "Kumar";
            customer.lastname  = "CM";
            customer.mobile    = "9874563222";
            customer.PIN       = "600017";
            customer.state     = "Tamilnadu";
            if (CI.saveUser(customer, "hellopwd"))
            {
                Console.WriteLine("Inserted Successfully");
            }
            else
            {
                Console.WriteLine("Failed to Insert");
            }


            Console.WriteLine(CR.checkUserRemoteExists("9874563210"));
            Console.WriteLine(CR.checkUserExists("9874563222"));

            dynamic SArea = SAI.getServiceAreas();

            foreach (var item in SArea)
            {
                Console.WriteLine(item.PIN);
            }
            Console.WriteLine(SAI.checkServiceability());
        }
Beispiel #21
0
        public void AddComponent_Instance_UsesInstance()
        {
            var customer = new CustomerImpl();

            Kernel.Register(
                Component.For <ICustomer>()
                .Named("key")
                .Instance(customer)
                );
            Assert.IsTrue(Kernel.HasComponent("key"));
            var handler = Kernel.GetHandler("key");

            Assert.AreEqual(customer.GetType(), handler.ComponentModel.Implementation);

            var customer2 = Kernel.Resolve <ICustomer>("key");

            Assert.AreSame(customer, customer2);

            customer2 = Kernel.Resolve <ICustomer>();
            Assert.AreSame(customer, customer2);
        }
 /// <summary>
 /// Update the given customer
 /// </summary>
 /// <param name="id"></param>
 public void UpdateCustomer(CustomerImpl customer)
 {
 }
Beispiel #23
0
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            if (!UserRightImpl.CheckRightAdminnistrator().UserEdit)
            {
                Response.Redirect(Utility.UrlRoot + Config.PathNotRight, false);
                return;
            }

            try
            {
                int userID = 0;

                var obj = new CustomerImpl();
                if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != string.Empty)
                {
                    try
                    {
                        userID = int.Parse(Request.QueryString["ID"]);
                        CustomerInfo item = obj.GetInfo(userID);

                        if (item == null)
                        {
                            Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                            return;
                        }
                        var objAdmin = (AdminInfo)Session[Constant.SessionNameAccountAdmin];

                        //string imgName = IMGName();

                        item.s_CustomerName = txtName.Text;
                        item.s_Email        = txtEmail.Text;
                        item.s_Address      = txtAddress.Text;
                        item.s_Mobile       = txtMobile.Text;
                        item.s_Homepage     = txtHomepage.Text;
                        item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);

                        obj.Update(item);
                        //Delete cache
                        CacheController.GetListCus_Delete();
                    }
                    catch
                    {
                        Response.Redirect(Utility.UrlRoot + Config.PathError, false);
                        return;
                    }
                }
                else
                {
                    var item = new CustomerInfo();
                    item.s_CustomerName = txtName.Text;
                    item.s_Email        = txtEmail.Text;
                    item.s_Address      = txtAddress.Text;
                    item.s_Mobile       = txtMobile.Text;
                    item.s_Homepage     = txtHomepage.Text;
                    item.s_Logo         = UntilityFunction.StringForNull(HD_IMG.Value);// IMGName();

                    obj.Insert(item);
                    //Delete cache
                    CacheController.GetListCus_Delete();
                }
                Response.Redirect("customer_manager.aspx", false);
            }
            catch
            {
                lblMsg.Text = "Tên khách hàng. Bạn chạy chọn một tên khác";
            }
        }
 public virtual void CreateCustomer(CustomerImpl newCrsCustomer)
 {
     throw new NotImplementedException();
 }
 public virtual void UpdateCustomer(CustomerImpl customer)
 {
     throw new NotImplementedException();
 }
        public void TestCustomerImplEmpty()
        {
            var customer = new CustomerImpl().Empty();

            Assert.IsTrue(customer.IsEmpty());
        }
 /// <summary>
 /// Add the given customer
 /// </summary>
 /// <param name="newCrsCustomer"></param>
 public void CreateCustomer(CustomerImpl newCrsCustomer)
 {
 }
Beispiel #28
0
 /// <summary>
 /// Determine if this is a null pattern object
 /// </summary>
 /// <param name="customer"></param>
 /// <returns></returns>
 public static bool IsEmpty(this CustomerImpl customer)
 {
     return(customer.CustomerId == NULL_ID);
 }