Exemplo n.º 1
0
        /// <summary>
        /// �������б���г�ʼ��
        /// </summary>
        private void PopulateListView()
        {
            #region ��ʼʱ�������ʱ���ʼ��
            Task task = new Task();
            SqlDataReader dataReader = null;
            dataReader = task.GetPeriodInfo();
            ArrayList a = new ArrayList();
            while (dataReader.Read())
            {
                string[] b = dataReader[1].ToString().Split('-');
                listBeginTime.Items.Add(new ListItem(b[0], dataReader[0].ToString()));
                listEndTime.Items.Add(new ListItem(b[0], dataReader[0].ToString()));
            }
            dataReader.Close();
            a = null;

            listBeginTime.SelectedIndex = Int32.Parse(CurrTime) - startTimeNo;
            listEndTime.SelectedIndex = listBeginTime.SelectedIndex + 1;

            //			listBeginTime.DataTextField = "period";
            //			listBeginTime.DataValueField = "id";
            //			listBeginTime.DataSource = dataReader;
            //			listBeginTime.DataBind();
            //			for(int j=startTimeNo;j<19;j++)
            //			{
            //				ListItem li = new ListItem(j.ToString()+":00",j.ToString());
            //				listBeginTime.Items.Insert(j-8,li);
            //				listEndTime.Items.Insert(j-8,li);
            //			}

            txtBeginDate.Text = DateTime.Parse(CurrDate).ToString("yyyy-MM-dd");
            //			listBeginTime.SelectedIndex   = Int32.Parse(CurrTime)-startTimeNo;
            txtEndDate.Text = DateTime.Parse(CurrDate).ToString("yyyy-MM-dd");
            #endregion

            #region �������Գ�ʼ��
            rbAttribute.Items.Add(new ListItem("��ռ����", "1"));
            rbAttribute.Items.Add(new ListItem("��ʱ����", "0"));
            rbAttribute.Items[0].Selected = true;
            #endregion

            #region �������ͳ�ʼ��
            rbType.Items.Add(new ListItem("����", "1"));
            rbType.Items.Add(new ListItem("��", "2"));
            rbType.Items.Add(new ListItem("����", "3"));
            rbType.Items.Add(new ListItem("�绰", "4"));
            rbType.Items.Add(new ListItem("�߷�", "5"));
            rbType.Items.Add(new ListItem("���", "6"));
            rbType.Items.Add(new ListItem("����", "7"));
            rbType.Items.Add(new ListItem("����", "8"));
            rbType.Items.Add(new ListItem("ϵͳ", "9"));
            rbType.Items.Add(new ListItem("��ѵ", "10"));
            rbType.Items[0].Selected = true;
            #endregion

            #region Эͬ��Ա�б��ʼ��
            UDS.Components.Staff staff = new UDS.Components.Staff();
            try
            {
                listCooperator.DataTextField = "RealName";
                listCooperator.DataValueField = "Staff_Name";
                listCooperator.DataSource = staff.GetAllStaffs();
                listCooperator.DataBind();

            }
            catch (Exception e)
            {
                UDS.Components.Error.Log(e.ToString());
                Server.Transfer("../Error.aspx");
            }
            finally
            {
                staff = null;
            }
            #endregion

            lblArrangedBy.Text = UDS.Components.Staff.GetRealNameByUsername(Username);
        }
Exemplo n.º 2
0
        private ArrayList CheckExist()
        {
            ArrayList cooperatorList = new ArrayList();
            ArrayList ExistList = new ArrayList();
            Task task = new Task();

            if (this.cbNeedCo.Checked)
            {
                if (this.cbNeedCo.Checked)
                {
                    string[] UnameArr = System.Text.RegularExpressions.Regex.Split(UnameStr, ",");
                    for (int uc = 0; uc < UnameArr.Length; uc++)
                        cooperatorList.Add(UnameArr[uc].ToString());
                }
                else
                {
                    cooperatorList.Add(Username);
                }
            }
            else
            {
                cooperatorList.Add(Username);
            }

            foreach (string s in cooperatorList)
            {
                // һ������
                #region ����ǵ��������
                if (this.txtBeginDate.Text.ToString() == this.txtEndDate.Text.ToString())
                {
                    // ȫ������
                    if (this.cbIsAllDay.Checked)
                    {
                        SqlDataReader dataReader = task.GetPeriodInfo();
                        while (dataReader.Read())
                        {
                            if (task.CheckExist(Int32.Parse(dataReader[0].ToString()), s, this.txtBeginDate.Text.ToString()))
                            {
                                TaskConflictRecord conrec = new TaskConflictRecord();
                                conrec.Username = s;
                                conrec.Date = this.txtBeginDate.Text.ToString();
                                conrec.Period = dataReader[0].ToString();
                                ExistList.Add(conrec);
                                conrec = null;
                            }
                        }
                        dataReader.Close();
                    }
                    else
                    {
                        for (int t = Int32.Parse(this.listBeginTime.SelectedItem.Value.ToString()); t < Int32.Parse(this.listEndTime.SelectedItem.Value.ToString()); t++)
                            if (task.CheckExist(t, s, this.txtBeginDate.Text.ToString()))
                            {
                                TaskConflictRecord conrec = new TaskConflictRecord();
                                conrec.Username = s;
                                conrec.Date = this.txtBeginDate.Text.ToString();
                                conrec.Period = t.ToString();
                                ExistList.Add(conrec);
                                conrec = null;
                            }

                    }

                }
                #endregion

                // ����Ƕ��������
                #region ����Ƕ��������
                if (DateTime.Parse(this.txtBeginDate.Text.ToString()) < DateTime.Parse(this.txtEndDate.Text.ToString()))
                {
                    TimeSpan ts = new TimeSpan();
                    ts = DateTime.Parse(this.txtEndDate.Text.ToString()) - DateTime.Parse(this.txtBeginDate.Text.ToString());
                    for (int t = 0; t < Int32.Parse(ts.Days.ToString()) + 1; t++) //��������ѭ�����
                    {
                        string tmpDate = DateTime.Parse(this.txtBeginDate.Text.ToString()).AddDays(t).ToString("yyyy-MM-dd");

                        #region �����ȫ������
                        if (this.cbIsAllDay.Checked) //�����ȫ������
                        {
                            SqlDataReader dataReader = task.GetPeriodInfo();
                            while (dataReader.Read())
                            {
                                if (task.CheckExist(Int32.Parse(dataReader[0].ToString()), s, tmpDate))
                                {
                                    TaskConflictRecord conrec = new TaskConflictRecord();
                                    conrec.Username = s;
                                    conrec.Date = tmpDate;
                                    conrec.Period = dataReader[0].ToString();
                                    ExistList.Add(conrec);
                                    conrec = null;
                                }
                            }
                            dataReader.Close();
                        }
                        #endregion

                        #region  �����ʱ������
                        else //�����ʱ������
                        {
                            if (this.cbIsRepeat.Checked) // �����ʱ���ظ�
                            {
                                for (int j = Int32.Parse(this.listBeginTime.SelectedItem.Value.ToString()); j < Int32.Parse(this.listEndTime.SelectedItem.Value.ToString()); j++)
                                    if (task.CheckExist(j, s, tmpDate))
                                    {
                                        TaskConflictRecord conrec = new TaskConflictRecord();
                                        conrec.Username = s;
                                        conrec.Date = tmpDate;
                                        conrec.Period = j.ToString();
                                        ExistList.Add(conrec);
                                        conrec = null;
                                    }
                            }
                            else   // �����ȫ��ʱ��
                            {
                                if (tmpDate == this.txtBeginDate.Text.ToString())// ����ǿ�ʼ��
                                {

                                    for (int k = Int32.Parse(this.listBeginTime.SelectedItem.Value.ToString()); k < 20; k++)
                                        if (task.CheckExist(k, s, tmpDate))
                                        {
                                            TaskConflictRecord conrec = new TaskConflictRecord();
                                            conrec.Username = s;
                                            conrec.Date = tmpDate;
                                            conrec.Period = (k).ToString();
                                            ExistList.Add(conrec);
                                            conrec = null;
                                        }
                                }
                                else if (tmpDate == this.txtEndDate.Text.ToString())
                                {
                                    for (int k = 1; k < Int32.Parse(this.listEndTime.SelectedItem.Value.ToString()); k++)
                                        if (task.CheckExist(k, s, tmpDate))
                                        {
                                            TaskConflictRecord conrec = new TaskConflictRecord();
                                            conrec.Username = s;
                                            conrec.Date = tmpDate;
                                            conrec.Period = k.ToString();
                                            ExistList.Add(conrec);
                                            conrec = null;
                                        }
                                }
                                else
                                {
                                    SqlDataReader dataReader = task.GetPeriodInfo();
                                    while (dataReader.Read())
                                    {
                                        if (task.CheckExist(Int32.Parse(dataReader[0].ToString()), s, tmpDate))
                                        {
                                            TaskConflictRecord conrec = new TaskConflictRecord();
                                            conrec.Username = s;
                                            conrec.Date = tmpDate;
                                            conrec.Period = dataReader[0].ToString();
                                            ExistList.Add(conrec);
                                            conrec = null;
                                        }

                                    }
                                    dataReader.Close();

                                }
                            }
                        }
                        #endregion
                    }

                }
                #endregion
            }

            return ExistList;
        }
Exemplo n.º 3
0
        public void PopulateDateToTable(DateTime sDate,int dayCount)
        {
            string Username = (string)Session["Username"];
            string[] UnameStr = System.Text.RegularExpressions.Regex.Split(Username,",");
            Task task = new Task();

            #region ��ʼ���ճ�����
            int[][] TaskData = new int[1][];
            Hashtable htcolorlist = new Hashtable();
            // ��ʼ����������ArrayList
            //			ArrayList demoDayData = new ArrayList();
            //			demoDayData.Add(9);
            //			demoDayData.Add(10);
            //			demoDayData.Add(11);
            //			demoDayData.Add(12);

            //			int[][] TaskData = new int[5][];  //ÿ�յ���������
            //			TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
            //			TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
            //			TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
            //			TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
            //			TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
            //			demoData[5] = new int[]{0,0,0,0,0,0,0,0};
            //			demoData[6] = new int[]{0,0,0,0,0,0,0,0};
            //			demoData[7] = new int[]{0,0,0,0,0,0,0,0};
            // �����к͵�Ԫ��
            ArrayList DaySch = new ArrayList(dayCount+1);//����ѡ��������������� ��1����Ϊ������һ��Ϣ��
            ArrayList DayTask = new ArrayList(dayCount+1); //��¼ÿ���ǰ��������ID
            DaySch.Add(new int[5][]);  //����һ������
            DayTask.Add(new String[5]);
            for(int p=0;p<dayCount;p++)
            {
                TaskData = new int[5][];
                string tmpDate = sDate.AddDays(p).ToString();
                String[] a = new String[5];
                a = task.GetTop5DayTaskList(tmpDate,UnameStr[0].ToString());

                //	TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
                //				TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
                //				TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
                //				TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
                //				TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
                for(int k=0;k<a.Length;k++)
                {
                    TaskData[k] = task.GetTaskPeriod(tmpDate,UnameStr[0],Int32.Parse(a[k].ToString()));
                }
                DaySch.Add(TaskData);
                DayTask.Add(a);
            }

            #endregion

            int numcells = dayCount;
            //	int startTimeNo = 8;
            SqlDataReader dataReader = null;
            dataReader =  task.GetPeriodInfo();
            ArrayList period = new ArrayList();
            try
            {
                while (dataReader.Read())
                    period.Add(dataReader[1].ToString());
            }
            finally
            {
                dataReader.Close();
            }
            int numrows = period.Count;

            //  ��ʼ����ͷ

            TableRow r = new TableRow();
            // ����һ����һ�У���ͷΪʱ��
            TableCell c = null;

            if(Username!="")
            {

                for (int i=0; i<numcells+1; i++)
                {

                    string s = sDate.AddDays(i-1).ToShortDateString()==DateTime.Today.ToShortDateString()?"<font color=white><b>"+DateTime.Today.ToShortDateString()+"</b></font>":sDate.AddDays(i-1).ToShortDateString();
                    LiteralControl lc = new LiteralControl((i==0)?"<font color=white>&nbsp;&nbsp; ʱ��&nbsp;&nbsp;&nbsp;    ":"<font color=white>"+s+"&nbsp;&nbsp;&nbsp;"+UDS.Components.Tools.ConvertDayOfWeekToZh(sDate.AddDays(i-1).DayOfWeek)+"</font>");
                    if(i==numcells)
                        lc.Text +="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=tasklist.aspx?SchBeginDate="+DateTime.Parse(SchBeginDate).AddDays(-7).ToShortDateString()+"><font color=white size=3><</font></a>&nbsp;&nbsp;&nbsp; <a href=tasklist.aspx?SchBeginDate="+DateTime.Parse(SchBeginDate).AddDays(7).ToShortDateString()+"><font color=white size=3>></font></a>";
                    c = new TableCell();
                    c.CssClass = "top";
                    c.BackColor = Color.FromName("#337FB2");
                    c.Controls.Add(lc);
                    r.Cells.Add(c);
                }
                Table1.Rows.Add(r);
                // ��ʼ����ͷ����

                // ����ʱ��ι�����8��
                for (int j=0; j<numrows; j++)
                {

                    r = new TableRow();

                    // ÿ�и���ѡ�������������
                    for (int i=0; i<dayCount+1; i++)
                    {

                        c = new TableCell();

                        Table newtable = new Table();

                        if (i==0)
                            if(j%2==0)
                            {
                                string []a = period[j].ToString().Split('-');
                                c.Controls.Add(new LiteralControl("<div style='position:absolute; width:86px; height:76px; z-index:1'><font size=3>"+a[0].ToString()+"</font></div>"));
                            }
                            else
                                c.Controls.Add(new LiteralControl("-"));
                        else
                        { //������ǵ�һ��

                            //					newtable.BorderWidth = 0;
                            //newtable.GridLines = System.Web.UI.WebControls .GridLines.Vertical;
                            // ��ij������table���ÿ�ʼ
                            newtable = new Table();
                            TableRow nr = new TableRow();

                            for(int q=0;q<TaskData.Length;q++)
                            {

                                int[][] tmp =  (int[][])DaySch[i];
                                String[] a = (String[])DayTask[i];
                                TableCell nc = new TableCell();

                                bool flag=false;
                            //	string col = "";
                                string taskid = "";

                                //�������������ʱ�����飬����û�б�ռ
                                for(int co=0;co<TaskData.Length;co++)
                                {
                                    if(Int32.Parse(tmp[co][j].ToString())!=0)
                                    {
                                        flag = true;
                                        taskid = a[co].ToString();
                                    }
                                }

                                if(flag)
                                {

                                    nc.Controls.Add(new LiteralControl("<font color=#C597DD>0"+"</font>"));
                                    nc.BackColor=Color.FromName("#C597DD");
                                    nc.Style.Add("cursor","hand");
                                        nc.Attributes.Add("onclick","return dialwinprocess('"+sDate.AddDays(i-1).ToShortDateString()+"','"+(8+j).ToString()+"','2','"+taskid+"')");

                                }
                                else
                                {

                                    nc.Controls.Add(new LiteralControl("<font color=#FFFFFF>0</font>"));

                                }
                                nr.Cells.Add(nc);

                            }

                            newtable.CellPadding = 0;
                            newtable.CellSpacing = 0;
                            newtable.GridLines = System.Web.UI.WebControls .GridLines.Both;
                            newtable.BorderWidth = 0;
                            newtable.Rows.Add(nr);
                            // ��table���ý���

                            c.Controls.Add(newtable);
                        }

                        r.Cells.Add(c);
                    }
                    Table1.CellPadding = 0;
                    Table1.CellSpacing = 0;
                    Table1.GridLines = System.Web.UI.WebControls .GridLines.Horizontal;
                    Table1.BorderWidth = 1;
                    Table1.Rows.Add(r);

                }

            }
        }
Exemplo n.º 4
0
        private void btnSubmit_Click(object sender, System.EventArgs e)
        {
            string info = "<link href=\"../../Css/BasicLayout.css\" rel=\"stylesheet\" type=\"text/css\">";
            info += "<body leftmargin=\"0\" topmargin=\"0\">";
            HttpCookie UserCookie = Request.Cookies["Username"];
            //string Username = UserCookie.Value.ToString();
            string Username = Server.UrlDecode(Request.Cookies["UserName"].Value);
            if (ValidateForm())
            {
                if (this.rbAttribute.SelectedItem.Value.ToString() == "1")
                {
                    ArrayList ExistList = CheckExist();
                    if (ExistList.Count > 0)
                    {
                        info += "<table width=100% height=30 border=0 cellpadding=0 cellspacing=0 class=GbText>";
                        info += "<tr>";
                        info += "<td background=\"../../Images/treetopbg.jpg\">&nbsp;&nbsp;����ʱ�γ�ͻ�����</td>";
                        info += "</tr>";
                        info += "</table>";

                        info += "<table width=100% border=1 cellpadding=0 cellspacing=0 style=BORDER-COLLAPSE: collapse borderColor=93BEE2 class=GbText>";
                        info += " <tr align=center bgcolor=#e8f4ff> ";
                        info += "<td width=30% height=24>�����Ա</td>";
                        info += "<td width=30% height=24>����</td>";
                        info += "<td height=24>ʱ��</td>";
                        info += "</tr>";
                        foreach (TaskConflictRecord conrec in ExistList)
                        {
                            int b = Int32.Parse(conrec.Period);
                            DateTime dt = new DateTime(1999, 1, 1, 8, 0, 0, 0);
                            TimeSpan ts = new TimeSpan(0, 0, (b - 1) * 30, 0, 0);
                            DateTime bt = dt.Add(ts);
                            DateTime et = bt.Add(new TimeSpan(0, 0, 30, 0, 0));

                            info += "<tr align=center><td height=20>" + conrec.Username + "</td>";
                            info += "<td>" + conrec.Date + "</td>";
                            info += "<td>" + bt.ToShortTimeString() + "---" + et.ToShortTimeString() + "</td>";
                            info += "</tr>";

                        }
                        info += "</table>";
                        info += "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
                        info += "<tr><td height=\"36\" align=\"center\"><font color=\"#FF0000\">����ʱ���г�ͻ</font></td></tr></table>";
                        Response.Write("<script language=javascript>var checkwin=window.open('','check','toolbar=no,scrollbars=yes,width=280,height=200,resizable=yes');");
                        Response.Write("checkwin.document.write('" + info + "');checkwin.moveTo(0,0);checkwin.focus();</script>");
                        return;

                    }
                }

                String TaskID = "";
                ArrayList cooperatorList = new ArrayList();
                Task task = new Task();
                TaskID = task.AddTask(ProcessFormPost());

                //�����������
                if (this.cbRemind.Checked == true)
                {
                    SMS sm = new SMS();
                    sm.SendMsg(Username, UnameStr, "���� " + UDS.Components.Staff.GetRealNameByUsername(Username) + " �����յ���һ���µ�����", 1, DateTime.Now, "", 0, 0);
                    sm = null;
                }

                if (this.rbAttribute.SelectedItem.Value.ToString() == "1")
                {

                    if (this.cbNeedCo.Checked)
                    {
                        string[] UnameArr = System.Text.RegularExpressions.Regex.Split(UnameStr, ",");
                        for (int uc = 0; uc < UnameArr.Length; uc++)
                            cooperatorList.Add(UnameArr[uc].ToString());
                    }
                    else
                    {
                        cooperatorList.Add(Username);
                    }

                    foreach (string s in cooperatorList)
                    {
                        // һ������
                        #region ����ǵ��������
                        if (this.txtBeginDate.Text.ToString() == this.txtEndDate.Text.ToString())
                        {
                            // ȫ������
                            if (this.cbIsAllDay.Checked)
                            {
                                SqlDataReader dataReader = task.GetPeriodInfo();
                                while (dataReader.Read())
                                {
                                    task.AddTaskToSchedule(Int32.Parse(TaskID), Int32.Parse(dataReader[0].ToString()), s, this.txtBeginDate.Text.ToString(), s.ToLower() == Username.ToLower() ? true : false);

                                }
                                dataReader = null;
                            }
                            else
                            {
                                for (int t = Int32.Parse(this.listBeginTime.SelectedItem.Value); t < Int32.Parse(this.listEndTime.SelectedItem.Value); t++)
                                    task.AddTaskToSchedule(Int32.Parse(TaskID), t, s, this.txtBeginDate.Text.ToString(), s.ToLower() == Username.ToLower() ? true : false);

                            }

                        }
                        #endregion

                        // ����Ƕ��������
                        #region ����Ƕ��������
                        if (DateTime.Parse(this.txtBeginDate.Text.ToString()) < DateTime.Parse(this.txtEndDate.Text.ToString()))
                        {
                            TimeSpan ts = new TimeSpan();
                            ts = DateTime.Parse(this.txtEndDate.Text.ToString()) - DateTime.Parse(this.txtBeginDate.Text.ToString());
                            for (int t = 0; t < Int32.Parse(ts.Days.ToString()) + 1; t++) //��������ѭ�����
                            {
                                string tmpDate = DateTime.Parse(this.txtBeginDate.Text.ToString()).AddDays(t).ToString("yyyy-MM-dd");

                                #region �����ȫ������
                                if (this.cbIsAllDay.Checked) //�����ȫ������
                                {
                                    SqlDataReader dataReader = task.GetPeriodInfo();
                                    while (dataReader.Read())
                                    {
                                        task.AddTaskToSchedule(Int32.Parse(TaskID), Int32.Parse(dataReader[0].ToString()), s, tmpDate, s.ToLower() == Username.ToLower() ? true : false);

                                    }
                                    dataReader = null;
                                }
                                #endregion

                                #region  �����ʱ������
                                else //�����ʱ������
                                {
                                    if (this.cbIsRepeat.Checked) // �����ʱ���ظ�
                                    {
                                        for (int j = Int32.Parse(this.listBeginTime.SelectedItem.Value.ToString()); j < Int32.Parse(this.listEndTime.SelectedItem.Value.ToString()); j++)
                                            task.AddTaskToSchedule(Int32.Parse(TaskID), j, s, tmpDate, s.ToLower() == Username.ToLower() ? true : false);
                                    }
                                    else   // �����ȫ��ʱ��
                                    {
                                        if (tmpDate == this.txtBeginDate.Text.ToString())// ����ǿ�ʼ��
                                        {

                                            for (int k = Int32.Parse(this.listBeginTime.SelectedItem.Value.ToString()); k <= 20; k++)
                                                task.AddTaskToSchedule(Int32.Parse(TaskID), k, s, tmpDate, s.ToLower() == Username.ToLower() ? true : false);
                                        }
                                        else if (tmpDate == this.txtEndDate.Text.ToString())
                                        {

                                            for (int k = 1; k < Int32.Parse(this.listEndTime.SelectedItem.Value.ToString()); k++)
                                                task.AddTaskToSchedule(Int32.Parse(TaskID), k, s, tmpDate, s.ToLower() == Username.ToLower() ? true : false);
                                        }
                                        else
                                        {
                                            SqlDataReader dataReader = task.GetPeriodInfo();
                                            while (dataReader.Read())
                                            {
                                                task.AddTaskToSchedule(Int32.Parse(TaskID), Int32.Parse(dataReader[0].ToString()), s, tmpDate, s.ToLower() == Username.ToLower() ? true : false);

                                            }
                                            dataReader = null;

                                        }
                                    }
                                }
                                #endregion
                            }

                        }
                        #endregion
                    }

                }

                else if (this.rbAttribute.SelectedItem.Value.ToString() == "0")
                {
                    if (this.cbNeedCo.Checked)
                    {
                        string[] UnameArr = System.Text.RegularExpressions.Regex.Split(UnameStr, ",");
                        for (int uc = 0; uc < UnameArr.Length; uc++)
                            cooperatorList.Add(UnameArr[uc].ToString());
                    }
                    else
                    {
                        cooperatorList.Add(Username);
                    }
                    foreach (string s in cooperatorList)
                    {
                        task.AddTaskToSchedule(Int32.Parse(TaskID), 0, s, this.txtEndDate.Text, s.ToLower() == Username.ToLower() ? true : false);
                    }

                }

                Response.Write("<script language=javascript>alert('��ӳɹ�!');window.opener.location='TaskList.aspx?displayType=1';window.close();</script>");
            }
        }
Exemplo n.º 5
0
        public void PopulateDateToTable(DateTime sDate,int dayCount,string Username)
        {
            string[] UnameStr = System.Text.RegularExpressions.Regex.Split(Username,",");

            Task task = new Task();

            #region ��ʼ���ճ�����
            int[][] TaskData = new int[1][];

            // ��ʼ����������ArrayList
            //			ArrayList demoDayData = new ArrayList();
            //			demoDayData.Add(9);
            //			demoDayData.Add(10);
            //			demoDayData.Add(11);
            //			demoDayData.Add(12);

            //			int[][] TaskData = new int[5][];  //ÿ�յ���������
            //			TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
            //			TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
            //			TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
            //			TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
            //			TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
            //			demoData[5] = new int[]{0,0,0,0,0,0,0,0};
            //			demoData[6] = new int[]{0,0,0,0,0,0,0,0};
            //			demoData[7] = new int[]{0,0,0,0,0,0,0,0};
            // �����к͵�Ԫ��
            ArrayList DaySch = new ArrayList(dayCount+1);//����ѡ��������������� ��1����Ϊ������һ��Ϣ��
            ArrayList DayTask = new ArrayList(dayCount+1); //��¼ÿ���ǰ��������ID
            DaySch.Add(new int[5][]);  //����һ������
            DayTask.Add(new String[5]);
            for(int p=0;p<UnameStr.Length;p++)
            {
                TaskData = new int[5][];
                string tmpDate = sDate.ToShortDateString();
                String[] a = new String[5];
                a = task.GetTop5DayTaskList(tmpDate,UnameStr[p].ToString());

                //	TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
                //				TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
                //				TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
                //				TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
                //				TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
                for(int k=0;k<a.Length;k++)
                {
                    TaskData[k] = task.GetTaskPeriod(tmpDate,UnameStr[p],Int32.Parse(a[k].ToString()));
                }
                DaySch.Add(TaskData);
                DayTask.Add(a);
            }

            #endregion

            int numcells = UnameStr.Length;
            //	int startTimeNo = 8;
            SqlDataReader dataReader = null;
            dataReader =  task.GetPeriodInfo();
            ArrayList period = new ArrayList();
            while(dataReader.Read())
                period.Add(dataReader[1].ToString());
            int numrows = period.Count;

            #region ��ɫ����
            ArrayList colorlist = new ArrayList(5);
            Random ro=new Random();
            string[] colorArray = task.GetTop5ConfirmedTaskList(sDate.ToShortDateString(),Username);
            for(int p=0;p<colorArray.Length;p++)
            {
                int ca = ro.Next(0,255);
                int cb = ro.Next(0,255);
                int cc = ro.Next(0,255);
                colorlist.Add(System.Drawing.Color.FromArgb(ca,cb,cc).ToArgb().ToString("X").Substring(2));
                //							if(colorArray[p].ToString()=="0")
                //								colorlist.Add(Color.FromName("#A692F5"));
                //							else
                //								colorlist.Add(Color.BlanchedAlmond);

            }
                        #endregion

            //  ��ʼ����ͷ
            #region ��ʼ����ͷ
            TableRow r = new TableRow();
            // ����һ����һ�У���ͷΪʱ��
            TableCell c = null;
            c = new TableCell();
            c.CssClass = "top";
            c.Controls.Add(new LiteralControl("<font size=3>"+sDate.ToString("yyyy/MM/dd")+"</font>&nbsp;&nbsp;&nbsp;    "));
            r.Cells.Add(c);

            if(Username!="")
            {

                for (int i=0; i<numcells; i++)
                {
                    string tmp = "";
                    if(UnameStr.Length>1)
                    {
                        for(int cu=0;cu<UnameStr.Length;cu++)
                        {

                            if(cu!=i)
                            {
                                tmp+=UnameStr[cu].ToString()+",";
                            }
                        }
                    }

                    if(tmp.Length!=0)
                        tmp = tmp.Substring(0,tmp.Length-1);

                    string s = "<a href='ViewDayTask.aspx?UnameStr="+tmp+"'>"+UDS.Components .Staff.GetRealNameByUsername(UnameStr[i].ToString())+"</a>";

                    c = new TableCell();
                    c.CssClass = "top";
                    c.Controls.Add(new LiteralControl("&nbsp;"+s+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
                    //c.Controls.Add(new LiteralControl((i==0)?"&nbsp;&nbsp; "+sDate.ToShortDateString()+"&nbsp;&nbsp;&nbsp;    ":s+"&nbsp;&nbsp;&nbsp;"+UDS.Components.Tools.ConvertDayOfWeekToZh(sDate.AddDays(i-1).DayOfWeek)));
                    r.Cells.Add(c);
                }

            #endregion
                //			Table1.CellPadding = 0;
                //			Table1.CellSpacing = 0;
                Table1.Rows.Add(r);
                // ��ʼ����ͷ����

                // ����ʱ��ι�����8��
                for (int j=0; j<numrows; j++)
                {

                    r = new TableRow();

                    // ÿ�и���ѡ�������������
                    for (int i=0; i<UnameStr.Length+1; i++)
                    {

                        c = new TableCell();

                        Table newtable = new Table();

                        if (i==0)
                            if(j%2==0)
                            {
                                string []a = period[j].ToString().Split('-');
                                //c.Controls.Add(new LiteralControl("<div style='position:absolute; width:86px; height:76px; z-index:1'><font size=3>aa"+a[0].ToString()+"</font></div>"));
                                c.Controls.Add(new LiteralControl("<font size=3>"+a[0].ToString()+"</font>"));
                            }
                            else
                                c.Controls.Add(new LiteralControl(""));
                        else
                        { //������ǵ�һ��

                            //					newtable.BorderWidth = 0;
                            //newtable.GridLines = System.Web.UI.WebControls .GridLines.Vertical;
                            // ��ij������table���ÿ�ʼ
                            newtable = new Table();
                            TableRow nr = new TableRow();

                            for(int q=0;q<TaskData.Length;q++)
                            {

                                int[][] tmp =  (int[][])DaySch[i];
                                String[] a = (String[])DayTask[i];
                                TableCell nc = new TableCell();

                                bool flag=false;
                                string col = "";
                                //�������������ʱ�����飬����û�б�ռ
                                for(int co=0;co<TaskData.Length;co++)
                                {
                                    if(Int32.Parse(tmp[co][j].ToString())!=0)
                                    {
                                        flag = true;
                                        col  = colorlist[co].ToString();
                                    }
                                }
                                //	Response.Write(flag.ToString());
                                if(flag)
                                {

                                    nc.Controls.Add(new LiteralControl("<font color="+col+">*"+"</font>"));
                                    nc.BackColor=Color.FromName(col);
                                    nc.Height = 20;
                                    //								nc.BackColor=(System.Drawing.Color)colorlist[q];
                                    //								nc.Attributes.Add("onclick","return dialwinprocess('"+sDate.AddDays(i-1).ToShortDateString()+"','"+(startTimeNo+j).ToString()+"','2','"+a[q]+"')");
                                    //								nc.Style.Add("cursor","hand");

                                }
                                else
                                {

                                    nc.Controls.Add(new LiteralControl("<font color=#FFFFFF>0</font>"));
                                    nc.Height=20;
                                    //		nc.BackColor=Color.FromName("#FFF8F7");
                                    //								nc.Attributes.Add("onclick","return dialwinprocess('"+sDate.AddDays(i-1).ToShortDateString()+"','"+(startTimeNo+j).ToString()+"','1','0')");
                                    //								nc.Attributes.Add("OnMouseOver","return high( this );");
                                    //								nc.Attributes.Add("OnMouseOut","return low( this );");
                                    //nc.Attributes.Add("onclick","return dialwinprocess('"+q.ToString()+j.ToString()+tmp[q][j].ToString()+"')");
                                    //		nc.Style.Add("cursor","hand");
                                    //							System.Drawing.ColorConverter cc=new System.Drawing.ColorConverter();
                                    //							newtable.BackColor=(System.Drawing.Color)cc.ConvertFromString("#FF9900");
                                    //

                                }
                                nr.Cells.Add(nc);

                            }

                            newtable.CellPadding = 0;
                            newtable.CellSpacing = 0;
                            newtable.GridLines = System.Web.UI.WebControls .GridLines.Both;
                            newtable.BorderWidth = 0;
                            newtable.Rows.Add(nr);
                            // ��table���ý���

                            c.Controls.Add(newtable);
                        }

                        r.Cells.Add(c);
                    }
                    Table1.CellPadding = 0;
                    Table1.CellSpacing = 0;
                    Table1.GridLines = System.Web.UI.WebControls .GridLines.Horizontal;
                    Table1.BorderWidth = 1;
                    Table1.Rows.Add(r);

                }

            }
        }