Exemple #1
0
        private void LoadItemData(string keyFilter)
        {
            //set ให้ show column ทั้งหมด
            shtView.Columns[0, shtView.Columns.Count - 1].Visible = true;

            CustomerBIZ biz = new CustomerBIZ();
            CustomerDTO dto = new CustomerDTO();

            DataTable dt = null;

            if (m_searchType == eSearchType.All)
            {
                dt = biz.LoadCustomerAll();
                shtView.Columns[(int)eColView.CRT_BY].Visible        = false;
                shtView.Columns[(int)eColView.CRT_DATE].Visible      = false;
                shtView.Columns[(int)eColView.CRT_MACHINE].Visible   = false;
                shtView.Columns[(int)eColView.DELIVERY_LT].Visible   = false;
                shtView.Columns[(int)eColView.UPD_BY].Visible        = false;
                shtView.Columns[(int)eColView.UPD_DATE].Visible      = false;
                shtView.Columns[(int)eColView.UPD_MACHINE].Visible   = false;
                shtView.Columns[(int)eColView.CUSTOMER_TYPE].Visible = false;
                shtView.Columns[(int)eColView.REMARK].Visible        = false;
                shtView.Columns[(int)eColView.IS_ACTIVE].Visible     = false;
            }

            DataTable dtView = dt.Clone();

            if (keyFilter != string.Empty)
            {
                string [] colNames     = Enum.GetNames(typeof(eColView));
                string    filterString = string.Empty;

                for (int i = 0; i < colNames.Length; i++)
                {
                    filterString += string.Format(@"CONVERT({0},'System.String') LIKE '%{1}%' ", colNames[i], keyFilter);
                    if (i != colNames.Length - 1)
                    {
                        filterString += " OR ";
                    }
                }

                //get only the rows you want
                DataRow [] results = dt.Select(filterString);

                //populate new destination table
                foreach (DataRow dr in results)
                {
                    dtView.ImportRow(dr);
                }
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    dtView.ImportRow(dr);
                }
            }
            fpView.DataSource = dtView;
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            //Console.Write("Starting....");

            CustomerBIZ customer = new CustomerBIZ();

            customer.Run(null);
//            customer.StartWork();
            //Console.Write("Finish");
        }
        public ActionResult GetCustomerWithSeraching(SearchCustomer search, int?page)
        {
            List <Customer> customers = new List <Customer>();

            try
            {
                CustomerBIZ custBiz = new CustomerBIZ();
                customers = custBiz.GetAllCustomer();
            }
            catch (Exception ex)
            {
                // use logging error
                Response.Write(ex.Message);
            }

            return(PartialView("_PartialCustomers", customers.ToPagedList(page ?? 1, 5)));
        }
 public ActionResult CreateCustomer([Bind(Include = "CustomerId, CustomerName,Phone,Address")] Customer customer)
 {
     try
     {
         if (customer.CustomerName == "ABC")
         {
             ModelState.AddModelError("CustomerName", "Customer Name can not be ABC");
         }
         if (ModelState.IsValid)
         {
             CustomerBIZ custBiz = new CustomerBIZ();
             custBiz.AddNewCustomer(customer);
             return(Json(new { success = true }));
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
     return(PartialView(customer));
 }