伪编码为C#程序 [英] Pseudocode to C# program

查看:69
本文介绍了伪编码为C#程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试这项任务。



我有这张桌子在我的数据库中。

Hi guys,

I am trying to do this task.

I have this table in my database.

items_table
------------------
Item_Name | Item ID
A	  |  1
B	  |  1
C	  |  2
D	  |  2
E	  |  Null
F	  |  
G	  |  1
H	  |  
I	  |  Null







Select * from items_table where Item_ID is Null or Item_ID is empty

Loop(while there are items without Item_ID)

Check the count of first Item_ID

if first Item_ID count is less than 8
(update items_table values (current Item_ID ) where Item_Name is current row Item_Name )

otherwise check next Item_ID

If no Item_ID count is less than 8, insert max((Item_ID)+1) where Item_Name is current row Item_Name  





对于上表,此代码应该是这样的。



E,F,H,我有Item_ID null或空



现在我必须为所有这些项插入Item_ID。



首先检查表中所有现有Item_ID的计数。如果任何item_ID与少于8个项目一起使用,则为当前项目插入Item_ID。如果没有Item_ID的计数小于8,那么创建一个新的Item_ID应该是最大的Item_ID + 1.





For the above table this code should do something like this.

E,F,H,I have Item_ID null or empty

Now i have to insert Item_ID for all these items.

First check count of all existing Item_IDs in the table. If any item_ID is used with less than 8 items, than insert that Item_ID for current Item. If no Item_ID has count less than 8, than create a new Item_ID which should be maximum Item_ID + 1.

private static void FIllItemID(string connectionString)
        {
            string queryStringNoItemID =
                "Use Items select * from table_items_shelves where Item_ID is Null or Item_ID = '';";
            SqlCommand GetAllWithoutID = new SqlCommand(queryStringNoGroupID);


            DataTable DataTableAllWithoutID = new DataTable();

            SqlDataAdapter adapterAllWithoutID = new SqlDataAdapter(GetAllWithoutID);

            adapterAllWithoutID.Fill(DataTableAllWithoutID);

            foreach (DataRow row in DataTableAllWithoutID.Rows)
            {
                
            }
            
        }



现在我如何检查Item_ID计数并插入它们。

任何人都可以帮忙用C#写这个。


Now how do i go with checking Item_ID count and inserting them.
Can any one help with writing this in C#.

推荐答案

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想象的一样困难!



看一下说明:它们是在易于完成的部分中列出的!所以依次做它们。

1)你知道如何从数据库中检索行:所以这样做!轻微的并发症是WHERE子句,但您的讲义应该涵盖这一点。这几乎导致......

2)循环。你正在阅读所需的记录,所以你需要循环遍历它们 - 你之前已经完成了这个,所以你知道该怎么做。

依旧......



试一试!你应该能够自己做...
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

Look at the instructions: they are laid out in easy-to-complete sections! So do them in turn.
1) You know how to retrieve rows from your database: so do it! The minor complication is the WHERE clause, but your lecture notes should cover that. That leads pretty much immediate into...
2) The loop. You are are reading the required records, so you need to loop through them - you have done this before, so it's something you know how to do.
And so on...

Give it a try! You should be able to do it on your own...


这篇关于伪编码为C#程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆