低级错误啊,浪费了那么长时间,对对象没有深刻理解

代码1:正确
  public void TimerReloadStores(int currentPage, int pageCount)
        {
            DataTable storeParm = bo.GetStoreParamSqlServer(currentPage, pageCount, "1", pageTotal);
            //如果只有一页数据
            if (currentPage == 1)
            {
                storeLogoSecond1.Visible = false;
                storeLogo1.Visible = true;
                StoreLogo sLogo = this.pnlParent.Controls["storeLogo" + 1] as StoreLogo;
                Panel pnlContainer = sLogo.Controls["pnlParent"] as Panel;
                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
                        //string storeID = "";
                        //string OnlineStatus = "";
                        //string ipaddress = "";
                        //int nport = 1433;
                        //bool bOK_1 = false;
                        //DataTable allStore = bo.GetAllEnabledStore();
                        //Panel pnl = this.pnl_queue.Controls["pnl_q" + i] as Panel;
                        //Panel pnl_offline = pnl.Controls["pnl_offline" + i] as Panel;
                        //QueueStore qs = pnl.Controls["queueStore" + i] as QueueStore;

                        //storeID = qs.StoreID;
                        //if (string.IsNullOrEmpty(storeID))
                        //    continue;
                        //OnlineStatus = qs.OnlineStatus;
                        int index = i + 1;
                        Panel pnl = pnlContainer.Controls["panel" + index] as Panel;
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        pnl.BackgroundImage = Image.FromFile(strStoreLogo);
                        pnl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
             //如果大于一页数据
            if (currentPage != 1)
            {
                storeLogo1.Visible = false;
                storeLogoSecond1.Visible = true;
                StoreLogoSecond sLogo = this.pnlParent.Controls["storeLogoSecond" + 1] as StoreLogoSecond;
                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
                        int index = i + 1;
                        Panel pnl = sLogo.Controls["panel" + index] as Panel;
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        pnl.BackgroundImage = Image.FromFile(strStoreLogo);
                        pnl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
        }
代码2: 错误,浪费很长时间
 public void TimerReloadStores(int currentPage, int pageCount)
        {
            DataTable storeParm = bo.GetStoreParamSqlServer(currentPage, pageCount, "1", pageTotal);
            //如果只有一页数据
            if (currentPage == 1)
            {
                storeLogoSecond1.Visible = false;
                storeLogo1.Visible = true;

                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
                       StoreLogo sLogo = this.pnlParent.Controls["storeLogo" + 1] as StoreLogo;
                Panel pnlContainer = sLogo.Controls["pnlParent"] as Panel;
                        int index = i + 1;
                        Panel pnl = pnlContainer.Controls["panel" + index] as Panel;
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        pnl.BackgroundImage = Image.FromFile(strStoreLogo);
                        pnl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
             //如果大于一页数据
            if (currentPage != 1)
            {
                storeLogo1.Visible = false;
                storeLogoSecond1.Visible = true;

                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
StoreLogoSecond sLogo = this.pnlParent.Controls["storeLogoSecond" + 1] as StoreLogoSecond;
                        int index = i + 1;
                        Panel pnl = sLogo.Controls["panel" + index] as Panel;
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        pnl.BackgroundImage = Image.FromFile(strStoreLogo);
                        pnl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
        }
代码3:最笨
public void ReloadStores(int currentPage, int pageCount)
        {
            DataTable storeParm = bo.GetStoreParamSqlServer(currentPage, pageCount, "1", pageTotal);
            //如果只有一页数据
            if (currentPage == 1)
            {
                storeLogoSecond1.Visible = false;
                storeLogo1.Visible = true;
                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
                        string storeID = storeParm.Rows[i]["STORE_ID"].ToString();
                        string onlineStatus = storeParm.Rows[i]["ONLINE_STATUS"].ToString();
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        if (i == 0)
                        {
                            storeLogo1.panel1.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel1.Enabled = true;
                                storeLogo1.myOpaqueLayer1.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel1.Enabled = false;
                                storeLogo1.myOpaqueLayer1.Visible = true;
                            }
                        }
                        if (i == 1)
                        {
                            storeLogo1.panel2.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel2.Enabled = true;
                                storeLogo1.myOpaqueLayer2.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel2.Enabled = false;
                                storeLogo1.myOpaqueLayer2.Visible = true;
                            }
                        }
                        if (i == 2)
                        {
                            storeLogo1.panel3.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel3.Enabled = true;
                                storeLogo1.myOpaqueLayer3.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel3.Enabled = false;
                                storeLogo1.myOpaqueLayer3.Visible = true;
                            }
                        }
                        if (i == 3)
                        {
                            storeLogo1.panel4.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel4.Enabled = true;
                                storeLogo1.myOpaqueLayer4.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel4.Enabled = false;
                                storeLogo1.myOpaqueLayer4.Visible = true;
                            }
                        }
                        if (i == 4)
                        {
                            storeLogo1.panel5.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel5.Enabled = true;
                                storeLogo1.myOpaqueLayer5.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel5.Enabled = false;
                                storeLogo1.myOpaqueLayer5.Visible = true;
                            }
                        }
                        if (i == 5)
                        {
                            storeLogo1.panel6.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogo1.panel6.Enabled = true;
                                storeLogo1.myOpaqueLayer6.Visible = false;
                            }
                            else
                            {
                                storeLogo1.panel6.Enabled = false;
                                storeLogo1.myOpaqueLayer6.Visible = true;
                            }
                        }

                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
            //如果大于一页数据
            if (currentPage != 1)
            {
                storeLogo1.Visible = false;
                storeLogoSecond1.Visible = true;
                for (int i = 0; i < pageCount; i++)
                {
                    try
                    {
                        string storeID = storeParm.Rows[i]["STORE_ID"].ToString();
                        string onlineStatus = storeParm.Rows[i]["ONLINE_STATUS"].ToString();
                        string strStoreLogo = Application.StartupPath + "/Resources/store_default.png";
                        string filepath = storeParm.Rows[i]["FILE_PATH"].ToString().Replace("~", "");
                        string filename = storeParm.Rows[i]["FILE_NAME"].ToString();
                        if (!string.IsNullOrEmpty(filepath) && !string.IsNullOrEmpty(filename))
                        {
                            filepath = Application.StartupPath + "/" + filepath + "/" + filename;

                            if (File.Exists(filepath))
                            {
                                strStoreLogo = filepath;
                            }
                        }
                        if (i == 0)
                        {
                            storeLogoSecond1.panel1.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel1.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer1.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel1.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer1.Visible = true;
                            }
                        }
                        if (i == 1)
                        {
                            storeLogoSecond1.panel2.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel2.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer2.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel2.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer2.Visible = true;
                            }
                        }
                        if (i == 2)
                        {
                            storeLogoSecond1.panel3.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel3.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer3.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel3.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer3.Visible = true;
                            }
                        }
                        if (i == 3)
                        {
                            storeLogoSecond1.panel4.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel4.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer4.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel4.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer4.Visible = true;
                            }
                        }
                        if (i == 4)
                        {
                            storeLogoSecond1.panel5.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel5.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer5.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel5.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer5.Visible = true;
                            }
                        }
                        if (i == 5)
                        {
                            storeLogoSecond1.panel6.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel6.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer6.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel6.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer6.Visible = true;
                            }
                        }
                        if (i == 6)
                        {
                            storeLogoSecond1.panel7.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel7.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer7.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel7.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer7.Visible = true;
                            }
                        }
                        if (i == 7)
                        {
                            storeLogoSecond1.panel8.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel8.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer8.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel8.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer8.Visible = true;
                            }
                        }
                        if (i == 8)
                        {
                            storeLogoSecond1.panel9.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel9.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer9.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel9.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer9.Visible = true;
                            }
                        }
                        if (i == 9)
                        {
                            storeLogoSecond1.panel10.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel10.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer10.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel10.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer10.Visible = true;
                            }
                        }
                        if (i == 10)
                        {
                            storeLogoSecond1.panel11.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel11.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer11.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel11.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer11.Visible = true;
                            }
                        }
                        if (i == 11)
                        {
                            storeLogoSecond1.panel12.BackgroundImage = Image.FromFile(strStoreLogo);
                            if (onlineStatus == "0")
                            {
                                storeLogoSecond1.panel12.Enabled = true;
                                storeLogoSecond1.myOpaqueLayer12.Visible = false;
                            }
                            else
                            {
                                storeLogoSecond1.panel12.Enabled = false;
                                storeLogoSecond1.myOpaqueLayer12.Visible = true;
                            }
                        }
                    }
                    catch (Exception errs)
                    {
                        LogCommon.WriteLogInfo(errs.ToString());
                    }
                }
            }
        }
时间: 2024-09-30 06:26:00

低级错误啊,浪费了那么长时间,对对象没有深刻理解的相关文章

这是第二道题内容要求写一个银行的ATM系统 这个浪费了好长时间 ,遇到了许多问题,不过都解决了,上程序

下面的4个用户是我宿舍的,当然我是钱最多的,呵呵! #include<iostream>#include<string>using namespace std; class consumer{public: void int_consumer(string ,string ,string ,float ); //初始化 string get_name(); //读取姓名 string get_id(); //读取账号 string get_password(); //读取密码 fl

阿呀在图书馆浪费了很长时间的样子。。。

垃圾概率论,垃圾wifilesshack,尤其是那个颖奇的视屏声音有小口音又重,,,垃圾.. 大概所谓的划水就是这样吧,还是要拼命读书才能变得更秃强 PS:推荐个歌曲 SAIKA II 好吧岛田家族的男孩子你们好...

web开发易犯的低级错误

web开发过程中,我们经常会犯一些小错误,但是却浪费了大量的时间,这里总结几个错误,以示警醒. 1.调试js的时候,明明设置了断点,但是就是不走断点.期初遇到这个问题,我不停的修改js代码,修改网页的html,不停的刷新浏览器,以为缓存的问题.结果后来发现,是因为有多出引入js,当我设置了一个断点,而程序走的却是其他的js,这个问题如果发现了,就根本不是问题,但是如果没发现,就要浪费你很长的时间咯. 2.提交表单,有的field的值却没有传递到后台.明明写了name属性啊,明明其他的field都

Java十大低级错误

前言 本文档根据java开发人员在编码过程中容易忽视或经常出错的地方进行了整理,总结了十个比较常见的低级错误点,方便大家学习. Java十大低级错误 不能用"=="比较两个字符串内容相等. 对list做foreach循环时,循环代码中不能修改list的结构. 日志和实际情况不一致:捕获异常后没有在日志中记录异常栈. 魔鬼数字. 空指针异常. 数组下标越界. 将字符串转换为数字时没有捕获NumberFormatException异常. 对文件.IO.数据库等资源进行操作后没有及时.正确进

Azure编程笔记(5):长时间的异步操作带来的问题

?? 内容提要 Azure Storage里很多操作需要花费很长的时间.为了提高效率,这些耗时的操作是以异步的方式响应的.也就是说调用这些操作对应的函数虽然结束,但背后的操作可能还要持续一段时间.如果没有合理的对待从函数返回到操作真正结束这段时间,我们的程序就有可能出现问题.下面以删除CloudTable为例讨论这类问题. 问题描述 我们写一个简单的单元测试的Class来重现这个问题.首先我们定义两个函数,分别用来初始化测试函数和清理测试函数所留下的数据.函数InitializeTest初始化一

JVM 调优 —— GC 长时间停顿问题及解决方法

零. 简介 垃圾收集器长时间停顿,表现在 Web 页面上可能是页面响应码 500 之类的服务器错误问题,如果是个支付过程可能会导致支付失败,将造成公司的直接经济损失,程序员要尽量避免或者说减少此类情况发生. 一. 并发模式失败(concurrent mode failure) 并发模式失败日志: 2016-02-21T13:53:07.974+0800: 171467.254: [GC [1 CMS-initial-mark: 1436199K(1560576K)] 1512927K(25043

MTK 开机黑屏很长时间

MT6735平台,可以开机,但是黑屏很长时间才看到开机图片. 查看串口LOG发现手机是正常运行的,也就是说LCM驱动没有异常,黑屏阶段也没有什么错误报出. 在MTK的FAQ上找到如下: [DESCRIPTION] 本FAQ只讨论开机过程中黑屏,不讨论花屏(可以参考刷).只讨论L/M版本(之前的KK/JB版本可以作为参考). 首先要看一下是否IPO开机,即在setting-->辅助功能-->不勾选"fast boot",如果不黑屏,说明是因为ipo这个过程中的问题,那么问题需

学习PHP开发难么?需要多长时间可以学会?

PHP开发在现在互联网行业中名声越来响亮,因为它随着市场经济的发展凸显了越来越重要的地位,PHP入门快,薪水高,就业广,让更多的人了解到PHP的发展前景,让更多的年轻人投入进来,那么都有哪些人适合学习PHP呢?,学习PHP需要多长时间? 学习PHP就要看你想怎么样去学习了,如果是自学的话耗费的时间比较长,根据自身的优势和基础学习的时间长短也是不一样的,有基础天赋高的同学自学会比较容易一些,但是知识点难点会花费比较多时间去解决,如果是零基础且不是特别聪明的同学自学的话会比较困难,毕竟软件技术也不是

低级错误总结

作为一名OIer,无论是蒟蒻还是神犇都会犯一些低级错误,而这些低级错误在考试时就有可能会让你从AK变成爆零.所以在考试时应当避免这类错误.在这里给大家总结一些常见的低级错误来与大家共勉. 一.文件类 1.许多OIer习惯在写代码前先写上文件操作然后注释掉,写完之后就经常会忘记删除注释.只是考场上常见的一种低级错误,不管你写的是正解还是暴力,最后的结果都是爆零. 2.考试时要注意题面第一页的文件要求,是独立文件夹还是都存在一个文件夹里. 3.文件操作最好不要写完第一个直接后两个都复制,这样如果第一