private void toolBtnFindOrderNumber_Click(object sender, EventArgs e)
        {
            List <DeliveryPoint> orderList  = new List <DeliveryPoint>(dpBindingSource.DataSource as BindingList <DeliveryPoint>);
            DeliveryPointFilter  userFilter = new DeliveryPointFilter(Convert.ToInt32(toolTxtFindOrderNumber.Text));
            //Predicate<DeliveryPoint> filterByOrderID = new Predicate<DeliveryPoint>(orderFilter.MatchesOrderID);
            Predicate <DeliveryPoint> filterByOrderID = new Predicate <DeliveryPoint>(userFilter.BeginsWithOrderID);
            DeliveryPoint             deliverypoint   = orderList.Find(filterByOrderID);

            if (deliverypoint == null)
            {
                MessageBox.Show("No matching DeliveryPoint found", "Not Found", MessageBoxButtons.OK);
            }
            else
            {
                int index = dpBindingSource.IndexOf(deliverypoint);
                dpBindingSource.Position = index;
            }
        }
Example #2
0
 private static DeliveryPoint UpdateEntity(DeliveryPoint deliverypoint)
 {
     using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
     {
         string proc = "pr_DeliveryPoint_Update";
         using (SqlCommand cmd = new SqlCommand(proc, cn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@DeliveryPointID", deliverypoint.DeliveryPointID);
             cmd.Parameters.AddWithValue("@DeliveryPointName", deliverypoint.DeliveryPointName);
             cmd.Parameters.AddWithValue("@DeliveryPointAddress", deliverypoint.DeliveryPointAddress);
             cn.Open();
             cmd.ExecuteNonQuery();
         }
     }
     deliverypoint = GetEntity(deliverypoint.DeliveryPointID);
     return(deliverypoint);
 }
Example #3
0
        private static DeliveryPoint AddEntity(DeliveryPoint deliverypoint)
        {
            int DeliveryPointID = 0;

            using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
            {
                string proc = "pr_DeliveryPoint_Add";
                using (SqlCommand cmd = new SqlCommand(proc, cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DeliveryPointName", deliverypoint.DeliveryPointName);
                    cmd.Parameters.AddWithValue("@DeliveryPointAddress", deliverypoint.DeliveryPointAddress);
                    cmd.Parameters.Add(new SqlParameter("@DeliveryPointID", SqlDbType.Int));
                    cmd.Parameters["@DeliveryPointID"].Direction = ParameterDirection.Output;
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    DeliveryPointID = Convert.ToInt32(cmd.Parameters["@DeliveryPointID"].Value);
                }
                deliverypoint = GetEntity(DeliveryPointID);
            }
            return(deliverypoint);
        }
        private void SetupBindings()
        {
            BindingList <DeliveryPoint> deliverypointList = new BindingList <DeliveryPoint>(DeliveryPoint.GetEntityList());

            dpBindingSource.DataSource = deliverypointList;
        }
 public bool BeginsWithOrderID(DeliveryPoint deliverypoint)
 {
     return(deliverypoint.DeliveryPointID.ToString().StartsWith(DeliveryPointID.ToString()));
 }
 public bool MatchesOrderID(DeliveryPoint deliverypoint)
 {
     return(deliverypoint.DeliveryPointID == DeliveryPointID);
 }