Exemplo n.º 1
0
        public static List <AssetGroups> GetEntityList()
        {
            List <AssetGroups> assetgroupList = new List <AssetGroups>();

            using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
            {
                string proc = "pr_AssetGroup_GetList";
                using (SqlCommand cmd = new SqlCommand(proc, cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cn.Open();
                    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    while (rdr.Read())
                    {
                        AssetGroups assetgroup = FillBuyer(rdr);
                        assetgroupList.Add(assetgroup);
                    }
                    if (!rdr.IsClosed)
                    {
                        rdr.Close();
                    }
                }
            }
            return(assetgroupList);
        }
Exemplo n.º 2
0
        public static AssetGroups GetEntity(decimal AssetGroupID)
        {
            AssetGroups assetgroup = null;

            using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
            {
                string proc = "pr_AssetGroup_Get";
                using (SqlCommand cmd = new SqlCommand(proc, cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@AssetGroupID", AssetGroupID);
                    cn.Open();
                    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    if (rdr.HasRows)
                    {
                        rdr.Read();
                        assetgroup = FillBuyer(rdr);
                    }
                    if (!rdr.IsClosed)
                    {
                        rdr.Close();
                    }
                }
            }
            return(assetgroup);
        }
Exemplo n.º 3
0
        private static AssetGroups FillBuyer(SqlDataReader rdr)
        {
            AssetGroups assetgroup = new AssetGroups();

            assetgroup.AssetGroupID = Convert.ToDecimal(rdr["AssetGroupID"]);
            assetgroup.AssetGroup   = rdr["AssetGroup"].ToString();
            return(assetgroup);
        }
Exemplo n.º 4
0
 public static AssetGroups SaveEntity(AssetGroups assetgroup)
 {
     if (assetgroup.AssetGroupID > 0)
     {
         return(UpdateEntity(assetgroup));
     }
     else
     {
         return(AddEntity(assetgroup));
     }
 }
Exemplo n.º 5
0
 public static void DeleteEntity(AssetGroups assetgroup)
 {
     using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
     {
         string proc = "pr_AssetGroup_Delete";
         using (SqlCommand cmd = new SqlCommand(proc, cn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@AssetGroupID", assetgroup.AssetGroupID);
             cn.Open();
             cmd.ExecuteNonQuery();
         }
     }
 }
Exemplo n.º 6
0
        private void Delete()
        {
            AssetGroups assetgroup = assetgroupBindingSource.Current as AssetGroups;
            // (BindingList<AssetGroup>)userBindingSource.DataSource;
            //AssetGroup assetgroup = OrderList[userBindingSource.Position];

            decimal      AssetGroupID = assetgroup.AssetGroupID;
            DialogResult dlg          = MessageBox.Show(string.Format("Are you sure you want to delete Asset Group # {0}?", AssetGroupID.ToString()));

            if (dlg == System.Windows.Forms.DialogResult.OK)
            {
                AssetGroups.DeleteEntity(assetgroup);
                assetgroupBindingSource.RemoveCurrent();
                MessageBox.Show(string.Format("AssetGroup # {0} was deleted.", AssetGroupID.ToString()));
            }
        }
Exemplo n.º 7
0
        private void Save()
        {
            assetgroupBindingSource.EndEdit();
            AssetGroups assetgroup = assetgroupBindingSource.Current as AssetGroups;

            //BindingList<AssetGroup> OrderList = (BindingList<AssetGroup>)userBindingSource.DataSource;
            //AssetGroup AssetGroup = OrderList[userBindingSource.Position];

            AssetGroups.SaveEntity(assetgroup);

            BindingList <AssetGroups> orderList = new BindingList <AssetGroups>(AssetGroups.GetEntityList());

            assetgroupBindingSource.DataSource = orderList;

            MessageBox.Show("Asset Group was saved.");
        }
Exemplo n.º 8
0
 private static AssetGroups UpdateEntity(AssetGroups assetgroup)
 {
     using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
     {
         string proc = "pr_AssetGroup_Update";
         using (SqlCommand cmd = new SqlCommand(proc, cn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@AssetGroupID", assetgroup.AssetGroupID);
             cmd.Parameters.AddWithValue("@AssetGroup", assetgroup.AssetGroup);
             cn.Open();
             cmd.ExecuteNonQuery();
         }
     }
     assetgroup = GetEntity(assetgroup.AssetGroupID);
     return(assetgroup);
 }
Exemplo n.º 9
0
        private void toolBtnFindOrderNumber_Click(object sender, EventArgs e)
        {
            List <AssetGroups> orderList  = new List <AssetGroups>(assetgroupBindingSource.DataSource as BindingList <AssetGroups>);
            AssetGroupFilter   userFilter = new AssetGroupFilter(Convert.ToInt32(toolTxtFindOrderNumber.Text));
            //Predicate<AssetGroup> filterByOrderID = new Predicate<AssetGroup>(orderFilter.MatchesOrderID);
            Predicate <AssetGroups> filterByOrderID = new Predicate <AssetGroups>(userFilter.BeginsWithOrderID);
            AssetGroups             assetgroup      = orderList.Find(filterByOrderID);

            if (assetgroup == null)
            {
                MessageBox.Show("No matching Asset Group found", "Not Found", MessageBoxButtons.OK);
            }
            else
            {
                int index = assetgroupBindingSource.IndexOf(assetgroup);
                assetgroupBindingSource.Position = index;
            }
        }
Exemplo n.º 10
0
        private static AssetGroups AddEntity(AssetGroups assetgroup)
        {
            int AssetGroupID = 0;

            using (SqlConnection cn = new SqlConnection(Common.ConnectionString))
            {
                string proc = "pr_AssetGroup_Add";
                using (SqlCommand cmd = new SqlCommand(proc, cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@AssetGroup", assetgroup.AssetGroup);
                    cmd.Parameters.Add(new SqlParameter("@AssetGroupID", SqlDbType.Int));
                    cmd.Parameters["@AssetGroupID"].Direction = ParameterDirection.Output;
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    AssetGroupID = Convert.ToInt32(cmd.Parameters["@AssetGroupID"].Value);
                }
                assetgroup = GetEntity(AssetGroupID);
            }
            return(assetgroup);
        }
Exemplo n.º 11
0
        private void SetupBindings()
        {
            BindingList <AssetGroups> buyerList = new BindingList <AssetGroups>(AssetGroups.GetEntityList());

            assetgroupBindingSource.DataSource = buyerList;
        }
Exemplo n.º 12
0
 public bool BeginsWithOrderID(AssetGroups assetgroup)
 {
     return(assetgroup.AssetGroupID.ToString().StartsWith(AssetGroupID.ToString()));
 }
Exemplo n.º 13
0
 public bool MatchesOrderID(AssetGroups assetgroup)
 {
     return(assetgroup.AssetGroupID == AssetGroupID);
 }