| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 664 人关注过本帖
标题:重载怎么样改成PUBLIC的一个类
只看楼主 加入收藏
屯兵
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-11-9
结帖率:100%
收藏
 问题点数:0 回复次数:4 
重载怎么样改成PUBLIC的一个类
using System;
using System.Collections.Generic;
using
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DB;


namespace  WindowsApplication1
{
    public partial class Route : UserControl
    {
        //ReQueue1 rq1;
        //ReQueue2 rq2;
        string filedId = Confing.FieldId;
        string couseid = "";
        string daikaoQueue = Confing.DaikaoQueue;
        string kaoshiQueue = Confing.KaoshiQueue;
        int time = Convert.ToInt32(Confing.Time.Trim());
        string NumberSwitch = Confing.NumberSwitch;
        mainform mf;

       public Route(string couseName, string couseId, string fangshi, mainform main)
        {
            InitializeComponent();
            try
            {
                couseid = couseId;
                mf = main;
                label1.Text = couseName;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (fangshi == "1")
            {
                timer2.Interval = time;
                timer2.Enabled = true;
            }
         
            else if (fangshi == "2")
            {
                try
                {
                    mf.rq1.Re_Exam_Queue.Clear();
                    mf.rq1.Exam_State.Clear();
                    DB.DBhelp.GetExamStateByFieldId(filedId,mf.rq1);
                    DBhelp.GetReExamQueueByCourseId(couseid,mf.rq1);
                    int count1 = 0;
                    int count2 = 1;
                    groupBox2.Controls.Clear();
                    groupBox3.Controls.Clear();
                    addTitl();
                    int nPosX = 16;
                    int nPosY = 25;
                    foreach (ReQueue1.Re_Exam_QueueRow row in mf.rq1.Re_Exam_Queue)
                    {
                        mf.rq1.Exam_result.Clear();
                        DBhelp.ExamResult(row.Examid_No, mf.rq1);
                        if (row.Exam_Status_Cd == "AW")
                        {
                            try
                            {
                                if (count1 + 1 > Convert.ToInt16(daikaoQueue))
                                    continue;
                                string y = "";
                                if (count1 % 2 == 0)
                                {
                                    y = "0";
                                }
                                else
                                {
                                    y = "1";
                                }
                                Daikao dq = new Daikao((count1 + 1).ToString(), row.Exame_Name, row.Examid_No, y, row.Pid_No);
                                dq.Location = new Point(nPosX, count1 * 13 + nPosY);

                                groupBox2.Controls.Add(dq);
                                count1++;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }

                        }
                        else if (row.Exam_Status_Cd == "IE")
                        {
                            try
                            {
                                if (count2 > Convert.ToInt16(kaoshiQueue))
                                    continue;
                                string st = "";
                                string cj = "";
                                foreach (ReQueue1.Exam_StateRow row2 in mf.rq1.Exam_State)
                                {
                                    if (row.Examid_No == row2.Examid_No)
                                    {
                                        switch (row2.Ei_Desc)
                                        {
                                            case "上坡路定点停车与坡道起步":
                                                st = "坡道起步"; break;
                                            case "限速通过限宽门":
                                                st = "限速限宽门"; break;
                                            default:
                                                st = row2.Ei_Desc; break;
                                        }
                                    }
                                }
                                foreach (ReQueue1.Exam_resultRow row3 in mf.rq1.Exam_result)
                                {
                                    cj = row3.Exam_Score;
                                }
                                if (st == "")
                                {
                                    st = "准备考试";
                                }
                                kaoshi kq = new kaoshi(row.Auto_Id, row.Exame_Name, st, cj);
                                kq.Width = groupBox2.Width - 10;
                                kq.Location = new Point(16, 30 + (count2 - 1) * 13);
                                groupBox3.Controls.Add(kq);
                                count2++;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }

                        }

                    }
                    //find();
                    //copyrq1();
                    int count3 = 1;
                    try
                    {
                        foreach (ReQueue1.DispcompleteExamRow row in mf.rq1.DispcompleteExam)
                        {

                            if (Convert.ToInt16(row.Count) < 2)
                            {
                                mf.rq1.Exam_result.Clear();
                                DBhelp.ExamResult(row.Examid_No, mf.rq1);
                                string cj = "";
                                foreach (ReQueue1.Exam_resultRow row3 in mf.rq1.Exam_result)
                                {
                                    cj = row3.Exam_Score;
                                }
                                kaoshi kq = new kaoshi(row.Auto_id, row.Exam_Name, "考试结束", cj);
                                kq.Location = new Point(16, 300 - (count3 - 1) * 13);
                                groupBox3.Controls.Add(kq);

                                int x = Convert.ToInt16(row.Count);
                                x++;
                                row.Count = x.ToString();
                                count3++;
                            }
                            else
                            {
                                mf.rq1.DispcompleteExam.RemoveDispcompleteExamRow(row);

                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                catch(Exception ex)
                { MessageBox.Show(ex.Message); }
            }
           
         
        }
      
        private void Route_Load(object sender, EventArgs e)
        {
            if (NumberSwitch == "1")
            {
                label4.Text = "身份证号码";
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            mf.rq1.Re_Exam_Queue.Clear();
            mf.rq1.Exam_State.Clear();
            DB.DBhelp.GetExamStateByFieldId(filedId, mf.rq1);
            DBhelp.GetReExamQueueByCourseId(couseid, mf.rq1);
            int count1 = 0;
            int count2 = 1;
            groupBox2.Controls.Clear();
            groupBox3.Controls.Clear();
            addTitl();
            int nPosX = 16;
            int nPosY = 25;
            foreach (ReQueue1.Re_Exam_QueueRow row in mf.rq1.Re_Exam_Queue)
            {
                try
                {
                    
                    mf.rq1.Exam_result.Clear();
                    DBhelp.ExamResult(row.Examid_No, mf.rq1);
                    if (row.Exam_Status_Cd == "AW")
                    {
                        if (count1 + 1 > Convert.ToInt16(daikaoQueue))
                            continue;
                        string y = "";
                        if (count1 % 2 == 0)
                        {
                            y = "0";
                        }
                        else
                        {
                            y = "1";
                        }
                        Daikao dq = new Daikao((count1 + 1).ToString(), row.Exame_Name, row.Examid_No, y, row.Pid_No);
                        dq.Location = new Point(nPosX, count1 * 13 + nPosY);
                        //dq.Location = new Point(1630+count1*30);
                        // dq.Width = groupBox2.Width - 10;
                        groupBox2.Controls.Add(dq);
                        
                        count1++;

                    }
                    else if (row.Exam_Status_Cd == "IE")
                    {
                        if (count2 > Convert.ToInt16(kaoshiQueue))
                            continue;
                        string st = "";
                        string cj = "";
                        foreach (ReQueue1.Exam_StateRow row2 in mf.rq1.Exam_State)
                        {
                            if (row.Examid_No == row2.Examid_No)
                            {
                                switch (row2.Ei_Desc)
                                {
                                    case "上坡路定点停车与坡道起步":
                                        st = "坡道起步"; break;
                                    case "限速通过限宽门":
                                        st = "限速限宽门"; break;
                                    default:
                                        st = row2.Ei_Desc; break;
                                }
                            }
                        }
                        foreach (ReQueue1.Exam_resultRow row3 in mf.rq1.Exam_result)
                        {
                            cj = row3.Exam_Score;

                        }
                        kaoshi kq = new kaoshi(row.Auto_Id, row.Exame_Name, st, cj);
                        kq.Width = groupBox2.Width - 10;
                        kq.Location = new Point(16, 30 + (count2 - 1) * 13);
                        groupBox3.Controls.Add(kq);
                       
                        count2++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            //find();
            //copyrq1();
            int count3 = 1;
            try
            {
                foreach (ReQueue1.DispcompleteExamRow row in mf.rq1.DispcompleteExam)
                {

                       if (Convert.ToInt16(row.Count) < 3)
                        {
                            mf.rq1.Exam_result.Clear();
                            DBhelp.ExamResult(row.Examid_No, mf.rq1);
                            string cj = "";
                            foreach (ReQueue1.Exam_resultRow row3 in mf.rq1.Exam_result)
                            {
                                cj = row3.Exam_Score;
                            }
                            kaoshi kq = new kaoshi(row.Auto_id, row.Exam_Name, "考试结束", cj);
                            kq.Location = new Point(16, 175 - (count3 - 1) * 13);
                            groupBox3.Controls.Add(kq);

                            int x = Convert.ToInt16(row.Count);
                            x++;
                            row.Count = x.ToString();
                            count3++;
                        }
                        else
                        {
                            mf.rq1.DispcompleteExam.RemoveDispcompleteExamRow(row);

                        }
                    
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        void addTitl()
        {
            try
            {
                groupBox2.Controls.Add(label2);
                if (NumberSwitch == "1")
                {
                    label4.Text = "身份证号码";
                }
                groupBox2.Controls.Add(label3);
                groupBox2.Controls.Add(label4);

                groupBox3.Controls.Add(label5);
                groupBox3.Controls.Add(label6);
                groupBox3.Controls.Add(label7);
                groupBox3.Controls.Add(label8);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        void find()
        {
            foreach (ReQueue2.Re_Exam_QueueRow rowB in mf.rq2.Re_Exam_Queue)
            {

                int i = mf.rq1.Re_Exam_Queue.Rows.Count;
                foreach (ReQueue1.Re_Exam_QueueRow rowN in mf.rq1.Re_Exam_Queue)
                {
                    if (rowN.Exam_Status_Cd == "IE")
                    {
                        if (rowB.Examid_No == rowN.Examid_No)
                        {
                            i--;
                        }
                    }
                }
                if (i != mf.rq1.Re_Exam_Queue.Rows.Count)
                    continue;
                else
                {
                    ReQueue1.DispcompleteExamRow drow = mf.rq1.DispcompleteExam.NewDispcompleteExamRow();
                    drow.Auto_id = rowB.Auto_Id;
                    drow.Course_Id = rowB.Course_Id;
                    drow.Exam_Name = rowB.Exame_Name;
                    drow.Examid_No = rowB.Examid_No;
                    drow.Count = "0";
                    mf.rq1.DispcompleteExam.AddDispcompleteExamRow(drow);
                }
            }
        }
        void copyrq1()
        {
            mf.rq2.Re_Exam_Queue.Clear();
            foreach (ReQueue1.Re_Exam_QueueRow rowN in mf.rq1.Re_Exam_Queue)
            {
                ReQueue2.Re_Exam_QueueRow rowB = mf.rq2.Re_Exam_Queue.NewRe_Exam_QueueRow();

                if (rowN.Exam_Status_Cd == "IE")
                {
                    rowB.Auto_Id = rowN.Auto_Id;
                    rowB.Course_Id = rowN.Course_Id;
                    rowB.Exame_Name = rowN.Exame_Name;
                    rowB.Examid_No = rowN.Examid_No;
                    mf.rq2.Re_Exam_Queue.AddRe_Exam_QueueRow(rowB);
                }
            }
        }

      

      
    }
}
就是红字的那部分怎么样改写成一个public的类
搜索更多相关主题的帖子: PUBLIC 重载 
2010-11-11 09:16
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:0 
新建一个public类 把那个方法放进去不就行了

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2010-11-11 09:22
屯兵
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-11-9
收藏
得分:0 
回复 2楼 wangnannan
不行啊总是有错啊
2010-11-11 09:48
shayadang
Rank: 1
等 级:新手上路
帖 子:3
专家分:3
注 册:2010-5-21
收藏
得分:0 
晕了。楼主。你太牛了。。太长了。。结果俺看不懂啦。。愁死啦。。
2010-12-01 20:03
zhoufeng1988
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:北京
等 级:贵宾
威 望:27
帖 子:1432
专家分:6329
注 册:2009-5-31
收藏
得分:0 
public Route(string couseName, string couseId, string fangshi, mainform main)

改写成一个类?这不是个构造函数吗?
不过这个构造函数挺长的,没设计好吧?
把代码提取出来,封装成一个方法。
2010-12-02 10:28
快速回复:重载怎么样改成PUBLIC的一个类
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052793 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved