コード例 #1
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
        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);
        }
コード例 #2
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
        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);
        }
コード例 #3
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
        private static AssetGroups FillBuyer(SqlDataReader rdr)
        {
            AssetGroups assetgroup = new AssetGroups();

            assetgroup.AssetGroupID = Convert.ToDecimal(rdr["AssetGroupID"]);
            assetgroup.AssetGroup   = rdr["AssetGroup"].ToString();
            return(assetgroup);
        }
コード例 #4
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
 public static AssetGroups SaveEntity(AssetGroups assetgroup)
 {
     if (assetgroup.AssetGroupID > 0)
     {
         return(UpdateEntity(assetgroup));
     }
     else
     {
         return(AddEntity(assetgroup));
     }
 }
コード例 #5
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
 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();
         }
     }
 }
コード例 #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()));
            }
        }
コード例 #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.");
        }
コード例 #8
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
 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);
 }
コード例 #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;
            }
        }
コード例 #10
0
ファイル: AssetGroups.cs プロジェクト: ysreedhar/POS
        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);
        }
コード例 #11
0
        private void SetupBindings()
        {
            BindingList <AssetGroups> buyerList = new BindingList <AssetGroups>(AssetGroups.GetEntityList());

            assetgroupBindingSource.DataSource = buyerList;
        }
コード例 #12
0
 public bool BeginsWithOrderID(AssetGroups assetgroup)
 {
     return(assetgroup.AssetGroupID.ToString().StartsWith(AssetGroupID.ToString()));
 }
コード例 #13
0
 public bool MatchesOrderID(AssetGroups assetgroup)
 {
     return(assetgroup.AssetGroupID == AssetGroupID);
 }