Esempio n. 1
0
        protected void btn_sure_Click(object sender, EventArgs e)
        {
            Customers         customer = this.AddCustomers();
            CustomersProvider provider = new CustomersProvider();

            switch (this.OperationFlag)
            {
            case Operation.Add:
                if (this.IsSame() == 1)
                {
                    break;
                }
                if (provider.Insert(customer))
                {
                    this.Alert("添加成功!!!");
                }
                break;

            case Operation.Update:
                if (provider.Update(customer))
                {
                    this.Alert("修改成功!!!");
                    this.BindText();
                }
                break;
            }
        }
Esempio n. 2
0
        private void BindText()
        {
            Customers customer = new Customers();

            customer.Customers_id = Convert.ToInt32(id);
            CustomersProvider provider = new CustomersProvider();
            DataTable         table    = new DataTable();

            table = provider.Select(customer);

            this.txt_address.Text         = table.Rows[0]["customers_address"].ToString();
            this.txt_code.Text            = table.Rows[0]["customers_code"].ToString();
            this.txt_fax.Text             = table.Rows[0]["customers_fax"].ToString();
            this.txt_name.Text            = table.Rows[0]["customers_name"].ToString();
            this.txt_network_address.Text = table.Rows[0]["customers_network_address"].ToString();
            this.txt_one_cell.Text        = table.Rows[0]["customers_person_one_cell"].ToString();
            this.txt_one_email.Text       = table.Rows[0]["customers_person_one_email"].ToString();
            this.txt_person_one.Text      = table.Rows[0]["customers_person_one"].ToString();
            this.txt_person_two.Text      = table.Rows[0]["customers_person_two"].ToString();
            this.txt_phone.Text           = table.Rows[0]["customers_phone"].ToString();
            this.txt_region.Text          = table.Rows[0]["customers_region"].ToString();
            this.txt_telephone.Text       = table.Rows[0]["customers_telephone"].ToString();
            this.txt_two_cell.Text        = table.Rows[0]["customers_person_two_cell"].ToString();
            this.txt_two_email.Text       = table.Rows[0]["customers_person_two_email"].ToString();
            this.txt_type.Text            = table.Rows[0]["customers_type"].ToString();
        }
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int rowIndex = e.RowIndex;

            Customers customer = new Customers();

            customer.Customers_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value);

            CustomersProvider provider = new CustomersProvider();

            if (provider.Delete(customer))
            {
                this.Alert("删除成功!!!");

                if (this.txt_Name.Text == "")
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource(null);
                }
                else
                {
                    this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1;
                    this.BindSource("%" + this.txt_Name.Text + "%");
                }
            }
        }
        [TestMethod]//siempre es bueno probar un escenario negativo y positivo
        public void GetAsyncReturnsNotFound()
        {
            var customersProvider  = new CustomersProvider();
            var customerController = new CustomersController(customersProvider);

            var result = customerController.Get("99").Result;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Esempio n. 5
0
        public void GetAsyncReturnsOK()
        {
            var customerProvider    = new CustomersProvider();
            var customersController = new CustomersController(customerProvider);

            var result = customersController.GetAsync("1").Result;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
        }
        protected void btn_Result_Click(object sender, EventArgs e)
        {
            Customers customer = new Customers();

            customer.Customers_name = "%" + this.txt_Name.Text + "%";
            CustomersProvider provider = new CustomersProvider();

            this.ListPager1.RecordCount = provider.GetSize(customer);
            this.BindSource(0, "%" + this.txt_Name.Text + "%");
            this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
        }
Esempio n. 7
0
        public void GetAsyncReturnNoFound()
        {
            var customerProvider = new CustomersProvider();
            //is needed to pass the provider class to controller as a parameter
            var customerController = new CustomersController(customerProvider);

            var resultado = customerController.GetAsync("5").Result;

            Assert.IsNotNull(resultado);
            Assert.IsInstanceOfType(resultado, typeof(NotFoundResult));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         CustomersProvider provider = new CustomersProvider();
         this.ListPager1.RecordCount = provider.GetSize();
         this.BindSource(0, null);
     }
     this.account.Text           = Session["LOGINED"].ToString();
     this.datetime.Text          = this.BindDayWeek();
     this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange);
 }
Esempio n. 9
0
    public void LoadContent(int customerId)
    {
        DateTime startDate = GetSalesStartDate();
        DateTime endDate   = GetSalesEndDate();

        HorizontalBarChart.Title = DateTimeHelper.GetDateRangeString(startDate, endDate);
        HorizontalBarChart.SetData(SalesProvider.GetCustomerPurchasesGroupedByProduct(customerId, startDate, endDate));
        using (CustomersProvider provider = new CustomersProvider())
            Location = provider.GetCustomerLocation(customerId);
        CustomerDetailsHolder.Visible  = true;
        EmptyDataMessageHolder.Visible = false;
    }
Esempio n. 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (CustomersProvider provider = new CustomersProvider()) {
         CustomersGridView.DataSource = provider.GetList();
         CustomersGridView.DataBind();
         if (!CustomersGridView.IsCallback)
         {
             Customer focusedRow = CustomersGridView.GetRow(CustomersGridView.FocusedRowIndex) as Customer;
             if (focusedRow != null)
             {
                 CustomerDetails.LoadContent(focusedRow.Id);
             }
         }
     }
 }
Esempio n. 11
0
        private void BindSource()
        {
            FreightProvider freight = new FreightProvider();

            this.ddl_freight.DataSource = freight.GetAll();
            this.ddl_freight.DataBind();
            SendProvider send = new SendProvider();

            this.ddl_send.DataSource = send.GetAll();
            this.ddl_send.DataBind();
            CustomersProvider customers = new CustomersProvider();

            this.ddl_customers.DataSource = customers.GetAll();
            this.ddl_customers.DataBind();
        }
Esempio n. 12
0
        public async Task GetCustomerReturnsCustomerUsingInvalidId()
        {
            var options = new DbContextOptionsBuilder <CustomersDbContext>()
                          .UseSqlServer("Data Source=LAPTOP-U3V1724K;Initial Catalog=Microservices.Customers.Database;Integrated Security=True")
                          .Options;
            var dbContext = new CustomersDbContext(options);

            var customerProfile = new CustomerProfile();
            var configuration   = new MapperConfiguration(cfg => cfg.AddProfile(customerProfile));
            var mapper          = new Mapper(configuration);

            var customersProvider = new CustomersProvider(dbContext, null, mapper, configuration, null);

            var customer = await customersProvider.GetCustomerAsync(-1);

            Assert.False(customer.IsSuccess);
            Assert.Null(customer.Customer);
            Assert.NotNull(customer.ErrorMessage);
        }
Esempio n. 13
0
        private int IsSame()
        {
            Customers         customer = this.AddCustomers();
            CustomersProvider provider = new CustomersProvider();

            customer.Customers_code = this.txt_code.Text;
            DataTable table = new DataTable();

            table = provider.Select(customer);
            if (table.Rows.Count != 0)
            {
                this.Alert("该客户代码已经存在,请重新输入!!!");
                return(1);
            }
            else
            {
                return(0);
            }
        }
 /// <summary>
 ///  绑定Customer信息的数据源
 /// </summary>
 private void BindSource(int start, string name)
 {
     if (name != null)
     {
         Customers customer = new Customers();
         customer.Customers_name = name;
         CustomersProvider provider = new CustomersProvider();
         DataTable         table    = provider.Select(customer, start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
     else
     {
         CustomersProvider provider = new CustomersProvider();
         DataTable         table    = provider.GetAll(start, this.ListPager1.PageSize);
         this.GridView1.DataSource = table.DefaultView;
         this.GridView1.DataBind();
     }
 }
Esempio n. 15
0
        public async Task GetCustomerWithInvalidId()
        {
            var options = new DbContextOptionsBuilder <CustomersDbContext>()
                          .UseInMemoryDatabase(nameof(GetAllCustomersReturnsAllCustomers))
                          .Options;
            var dbContext = new CustomersDbContext(options);

            SeedData(dbContext);

            var customerProfile = new CustomerProfile();
            var configuration   = new MapperConfiguration(cfg => cfg.AddProfile(customerProfile));
            var mapper          = new Mapper(configuration);

            var customersProvider = new CustomersProvider(dbContext, null, mapper);
            var results           = await customersProvider.GetCustomerAsync(-1);

            Assert.False(results.IsSuccess);
            Assert.Null(results.Customer);
            Assert.NotNull(results.ErrorMessage);
        }
Esempio n. 16
0
        public async Task GetCustomerAsyncTest()
        {
            var options = new DbContextOptionsBuilder <CustomersDbContext>()
                          .UseInMemoryDatabase(nameof(GetCustomerAsyncTest))
                          .EnableSensitiveDataLogging()
                          .Options;

            var dbContext = new CustomersDbContext(options);

            CreateCustomers(dbContext);

            var customerProfile = new CustomerProfile();
            var configuration   = new MapperConfiguration(config => config.AddProfile(customerProfile));
            var mapper          = new Mapper(configuration);

            var customersProvider = new CustomersProvider(dbContext, null, mapper);

            var customers = await customersProvider.GetCustomerAsync(11);

            Assert.IsNotNull(customers.Customer);
            Assert.IsTrue(customers.IsSuccess);
            Assert.IsNull(customers.ErrorMessage);
        }