Example #1
0
        public void Make_result_row_with_data(string ActivityNum, string Item, int Duration, int ES, int EE, int LS, int LE, bool CP, string StartD, string EndD)
        {
            TableRow TR = new TableRow();

            TableCell cell1 = new TableCell();
            Label     lbl_1 = new Label();

            lbl_1.ID   = "Lbl_" + ActivityNum;
            lbl_1.Text = ActivityNum;
            cell1.Controls.Add(lbl_1);
            TR.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            Label     lbl_2 = new Label();

            lbl_2.Text = Item;
            cell2.Controls.Add(lbl_2);
            TR.Cells.Add(cell2);

            TableCell cell3 = new TableCell();
            Label     lbl_3 = new Label();

            lbl_3.Text = Duration.ToString();
            cell3.Controls.Add(lbl_3);
            TR.Cells.Add(cell3);

            TableCell cell4 = new TableCell();
            Label     lbl_9 = new Label();
            DateTime  DT;
            var       isDate = DateTime.TryParse(TB_RSdate.Text, out DT);

            if (isDate)
            {
                lbl_9.Text = DT.AddDays(ES).ToString("yyyy/MM/dd");
            }

            cell4.Controls.Add(lbl_9);
            TR.Cells.Add(cell4);

            TableCell cell5  = new TableCell();
            Label     lbl_92 = new Label();

            if (isDate)
            {
                lbl_92.Text = DT.AddDays(LS).ToString("yyyy/MM/dd");
            }
            cell5.Controls.Add(lbl_92);
            TR.Cells.Add(cell5);

            TableCell cell6  = new TableCell();
            Label     lbl_91 = new Label();

            if (isDate)
            {
                lbl_91.Text = DT.AddDays(EE).ToString("yyyy/MM/dd");
            }
            cell6.Controls.Add(lbl_91);
            TR.Cells.Add(cell6);

            TableCell cell7  = new TableCell();
            Label     lbl_10 = new Label();

            if (isDate)
            {
                lbl_10.Text = DT.AddDays(LE).ToString("yyyy/MM/dd");
            }

            cell7.Controls.Add(lbl_10);
            TR.Cells.Add(cell7);

            TableCell cell75 = new TableCell();
            Label     lbl_75 = new Label();

            lbl_75.Text = (LE - EE).ToString();
            cell75.Controls.Add(lbl_75);
            TR.Cells.Add(cell75);

            TableCell cell8 = new TableCell();
            Label     lbl_8 = new Label();

            if (CP)
            {
                lbl_8.Text = "*";
            }
            else
            {
                lbl_8.Text = "";
            }
            cell8.Controls.Add(lbl_8);
            TR.Cells.Add(cell8);

            TableCell cell11 = new TableCell();
            TextBox   TB_11  = new TextBox();

            TB_11.ID = "TB_SD_" + ActivityNum;
            if (StartD != "")
            {
                TB_11.Text = StartD;
            }
            else
            {
                TB_11.Text = lbl_9.Text;
            }

            if (lbl_8.Text == "*")
            {
                TB_11.ReadOnly = true;
            }
            else
            {
                //TB_11.ReadOnly = true;
                TB_11.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                TB_11.Attributes.Add("onchange", "alerttime(this.value,'" + lbl_9.Text + "','" + lbl_91.Text + "');");
            }

            cell11.Controls.Add(TB_11);
            TR.Cells.Add(cell11);

            TableCell cell12 = new TableCell();
            TextBox   TB_12  = new TextBox();

            TB_12.ID = "TB_ED_" + ActivityNum;
            if (EndD != "")
            {
                TB_12.Text = EndD;
            }
            else
            {
                TB_12.Text = lbl_10.Text;
            }

            if (lbl_8.Text == "*")
            {
                TB_12.ReadOnly = true;
            }
            else
            {
                //TB_12.ReadOnly = true;
                TB_12.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                TB_12.Attributes.Add("onchange", "alerttime(this.value,'" + lbl_92.Text + "','" + lbl_10.Text + "');");
            }

            cell12.Controls.Add(TB_12);
            TR.Cells.Add(cell12);

            TR.Cells[0].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[1].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[2].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[3].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[4].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[5].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[6].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[7].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[8].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[9].HorizontalAlign = HorizontalAlign.Center;

            //產生表格
            Tbl_Output.Rows.Add(TR);
        }
Example #2
0
        public static DateTime GetThousandDay(string datefield)
        {
            bool tt = DateTime.TryParse(datefield, out DateTime DT);

            return(DT.AddDays(10000));
        }
Example #3
0
        public void Make_result_row(Activity list, int nowindex)
        {
            TableRow TR = new TableRow();

            TableCell cell1 = new TableCell();
            Label     lbl_1 = new Label();

            lbl_1.Text = list.Id;
            cell1.Controls.Add(lbl_1);
            TR.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            Label     lbl_2 = new Label();

            lbl_2.Text = list.Description;
            cell2.Controls.Add(lbl_2);
            TR.Cells.Add(cell2);

            TableCell cell3 = new TableCell();
            Label     lbl_3 = new Label();

            lbl_3.Text = list.Duration.ToString();
            cell3.Controls.Add(lbl_3);
            TR.Cells.Add(cell3);

            TableCell cell4 = new TableCell();
            Label     lbl_4 = new Label();

            lbl_4.Text = list.Est.ToString();
            cell4.Controls.Add(lbl_4);
            TR.Cells.Add(cell4);

            TableCell cell5 = new TableCell();
            Label     lbl_5 = new Label();

            lbl_5.Text = list.Eet.ToString();
            cell5.Controls.Add(lbl_5);
            TR.Cells.Add(cell5);

            TableCell cell6 = new TableCell();
            Label     lbl_6 = new Label();

            lbl_6.Text = list.Lst.ToString();
            cell6.Controls.Add(lbl_6);
            TR.Cells.Add(cell6);

            TableCell cell7 = new TableCell();
            Label     lbl_7 = new Label();

            lbl_7.Text = list.Let.ToString();
            cell7.Controls.Add(lbl_7);
            TR.Cells.Add(cell7);

            TableCell cell8 = new TableCell();
            Label     lbl_8 = new Label();

            if ((list.Eet - list.Let == 0) && (list.Est - list.Lst == 0))
            {
                lbl_8.Text = "*";
            }
            else
            {
                lbl_8.Text = "";
            }
            cell8.Controls.Add(lbl_8);
            TR.Cells.Add(cell8);

            TableCell cell9 = new TableCell();
            Label     lbl_9 = new Label();
            DateTime  DT;
            var       isDate = DateTime.TryParse(TB_StartDay.Text, out DT);

            if (isDate)
            {
                lbl_9.Text = DT.AddDays(list.Est).ToString("yyyy/MM/dd");
            }

            cell9.Controls.Add(lbl_9);
            TR.Cells.Add(cell9);

            TableCell cell91 = new TableCell();
            Label     lbl_91 = new Label();

            if (isDate)
            {
                lbl_91.Text = DT.AddDays(list.Eet).ToString("yyyy/MM/dd");
            }
            cell91.Controls.Add(lbl_91);
            TR.Cells.Add(cell91);

            TableCell cell92 = new TableCell();
            Label     lbl_92 = new Label();

            if (isDate)
            {
                lbl_92.Text = DT.AddDays(list.Lst).ToString("yyyy/MM/dd");
            }
            cell92.Controls.Add(lbl_92);
            TR.Cells.Add(cell92);

            TableCell cell10 = new TableCell();
            Label     lbl_10 = new Label();

            if (isDate)
            {
                lbl_10.Text = DT.AddDays(list.Let).ToString("yyyy/MM/dd");
            }


            cell10.Controls.Add(lbl_10);
            TR.Cells.Add(cell10);

            TableCell cell11 = new TableCell();
            TextBox   TB_11  = new TextBox();

            TB_11.ID       = "TB_" + nowindex.ToString() + "_startdate";
            TB_11.Text     = lbl_9.Text;
            TB_11.TextMode = TextBoxMode.Date;
            if (lbl_8.Text == "*")
            {
                TB_11.ReadOnly = true;
            }
            else
            {
                TB_11.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                TB_11.Attributes.Add("onchange", "alerttime(this.value,'" + lbl_9.Text + "','" + lbl_91.Text + "');");
            }

            cell11.Controls.Add(TB_11);
            TR.Cells.Add(cell11);

            TableCell cell12 = new TableCell();
            TextBox   TB_12  = new TextBox();

            TB_12.ID       = "TB_" + nowindex.ToString() + "_enddate";
            TB_12.Text     = lbl_10.Text;
            TB_12.TextMode = TextBoxMode.Date;
            if (lbl_8.Text == "*")
            {
                TB_12.ReadOnly = true;
            }
            else
            {
                TB_12.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                TB_12.Attributes.Add("onchange", "alerttime(this.value,'" + lbl_92.Text + "','" + lbl_10.Text + "');");
            }

            cell12.Controls.Add(TB_12);
            TR.Cells.Add(cell12);

            TR.Cells[0].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[1].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[2].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[3].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[4].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[5].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[6].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[7].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[8].HorizontalAlign = HorizontalAlign.Center;
            TR.Cells[9].HorizontalAlign = HorizontalAlign.Center;
            //產生表格
            Tbl_Output.Rows.Add(TR);
        }
Example #4
0
        protected void SetDate_Click(object sender, EventArgs e)
        {
            //Tbl_Output.Rows.Clear();
            //make_tableheader();
            if (AllEmptyCheck())
            {
                string[] data     = new string[10];
                int      temp_ver = 1;
                //if (!int.TryParse(DDL_version.SelectedValue, out temp_ver))
                temp_ver = 1;
                bool getdata = DAL.ProgressMode.Get_Progress_AllData(Session["DatabaseName"].ToString(), Session["ProjectCode"].ToString(), out data, temp_ver);
                if (getdata)
                {
                    string[] ActivityNo = data[0].Split(',');
                    string[] Item       = data[1].Split(',');
                    string[] temp       = data[2].Split(',');
                    int[]    Duration   = new int[temp.Length];
                    for (int i = 0; i < temp.Length; i++)
                    {
                        Duration[i] = int.Parse(temp[i]);
                    }
                    string[] temp3 = data[3].Split(',');
                    string[] temp4 = data[4].Split(',');
                    string[] temp5 = data[5].Split(',');
                    string[] temp6 = data[6].Split(',');
                    string[] temp7 = data[7].Split(',');
                    int[]    ES    = new int[temp3.Length];
                    int[]    EE    = new int[temp4.Length];
                    int[]    LS    = new int[temp5.Length];
                    int[]    LE    = new int[temp6.Length];
                    bool[]   CP    = new bool[temp7.Length];
                    for (int i = 0; i < temp3.Length; i++)
                    {
                        ES[i] = int.Parse(temp3[i]);
                        EE[i] = int.Parse(temp4[i]);
                        LS[i] = int.Parse(temp5[i]);
                        LE[i] = int.Parse(temp6[i]);
                        CP[i] = bool.Parse(temp7[i]);
                    }
                    string[] SD    = data[8].Split(',');
                    string[] ED    = data[9].Split(',');
                    int      AllNo = ActivityNo.Length;
                    for (int i = 0; i < AllNo; i++)
                    {
                        //Make_result_row_with_data(ActivityNo[i], Item[i], Duration[i], ES[i], EE[i], LS[i], LE[i], CP[i], "", "");
                        Label    LbWBSID   = Repeater1.Items[i].FindControl("LbWBSID") as Label;
                        Label    LbWIID    = Repeater1.Items[i].FindControl("LbWIID") as Label;
                        Label    LbWIName  = Repeater1.Items[i].FindControl("LbWIName") as Label;
                        Label    LbWBSName = Repeater1.Items[i].FindControl("LbWBSName") as Label;
                        Label    LbRate    = Repeater1.Items[i].FindControl("LbRate") as Label;
                        Label    LbFTime   = Repeater1.Items[i].FindControl("LbFTime") as Label;
                        Label    LbCP      = Repeater1.Items[i].FindControl("LbCP") as Label;
                        Label    LbES      = Repeater1.Items[i].FindControl("LbES") as Label;
                        Label    LbLS      = Repeater1.Items[i].FindControl("LbLS") as Label;
                        Label    LbEF      = Repeater1.Items[i].FindControl("LbEF") as Label;
                        Label    LbLF      = Repeater1.Items[i].FindControl("LbLF") as Label;
                        TextBox  TB_S1     = Repeater1.Items[i].FindControl("TB_S1") as TextBox;
                        TextBox  TB_E1     = Repeater1.Items[i].FindControl("TB_E1") as TextBox;
                        DateTime DT;
                        var      isDate = DateTime.TryParse(TB_RSdate.Text, out DT);
                        string   StartD = "";
                        string   EndD   = "";
                        if (isDate)
                        {
                            LbES.Text = DT.AddDays(ES[i]).ToString("yy/MM/dd");
                            LbEF.Text = DT.AddDays(EE[i]).ToString("yy/MM/dd");
                            LbLS.Text = DT.AddDays(LS[i]).ToString("yy/MM/dd");
                            LbLF.Text = DT.AddDays(LE[i]).ToString("yy/MM/dd");
                            if (StartD != "")
                            {
                                TB_S1.Text = StartD;
                            }
                            else
                            {
                                TB_S1.Text = LbES.Text;
                            }

                            if (LbCP.Text == "是")
                            {
                                TB_S1.ReadOnly = true;
                            }
                            else
                            {
                                //TB_11.ReadOnly = true;
                                TB_S1.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                                TB_S1.Attributes.Add("onchange", "alerttime(this.value,'" + LbLS.Text + "','" + LbEF.Text + "');");
                            }

                            if (EndD != "")
                            {
                                TB_E1.Text = EndD;
                            }
                            else
                            {
                                TB_E1.Text = LbLF.Text;
                            }

                            if (LbCP.Text == "是")
                            {
                                TB_E1.ReadOnly = true;
                            }
                            else
                            {
                                //TB_12.ReadOnly = true;
                                TB_E1.Attributes.Add("onclick", "WdatePicker(({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy/MM/dd',alwaysUseStartDate:true}));");
                                TB_E1.Attributes.Add("onchange", "alerttime(this.value,'" + LbLS.Text + "','" + LbLF.Text + "');");
                            }
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script language='javascript'>alert('請先填入工期、前置時間,並先以要徑法計算並儲存計算結果!')</script>");
            }
        }
Example #5
0
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRow vsDr = (DataRow)((DataRowView)e.Item.DataItem).Row;
                Label   LbCP = (Label)e.Item.FindControl("LbCP");
                Label   LbLS = (Label)e.Item.FindControl("LbLS");
                Label   LbES = (Label)e.Item.FindControl("LbES");
                Label   LbEF = (Label)e.Item.FindControl("LbEF");
                Label   LbLF = (Label)e.Item.FindControl("LbLF");

                Label   LbFTime = (Label)e.Item.FindControl("LbFTime");
                Label   LbRate  = (Label)e.Item.FindControl("LbRate");
                TextBox TB_D1   = (TextBox)e.Item.FindControl("TB_D1");
                TextBox TB_F1   = (TextBox)e.Item.FindControl("TB_F1");
                TextBox TB_T1   = (TextBox)e.Item.FindControl("TB_T1");
                TextBox TB_S1   = (TextBox)e.Item.FindControl("TB_S1");
                TextBox TB_E1   = (TextBox)e.Item.FindControl("TB_E1");

                TB_S1.Text = TB_S1.Text != ""?DateTime.Parse(TB_S1.Text).ToShortDateString():"";
                TB_E1.Text = TB_E1.Text != ""? DateTime.Parse(TB_E1.Text).ToShortDateString():"";

                double value = double.Parse(LbRate.Text);
                LbRate.Text = (Math.Round(value, 0)).ToString();
                if (LbCP.Text == "True")
                {
                    LbCP.Text = "是";
                }
                else
                {
                    LbCP.Text = "否";
                }
                if (LbLS.Text != "" && LbES.Text != "")
                {
                    LbFTime.Text = (decimal.Parse(LbLS.Text) - decimal.Parse(LbES.Text)).ToString();
                }
                if (ViewState["Lock"].ToString() == "1")
                {
                    TB_D1.Enabled = false;
                    TB_F1.Enabled = false;
                    TB_T1.Enabled = false;
                    TB_S1.Enabled = false;
                    TB_E1.Enabled = false;
                }
                else
                {
                    TB_D1.Enabled = true;
                    TB_F1.Enabled = true;
                    TB_T1.Enabled = true;
                    TB_S1.Enabled = true;
                    TB_E1.Enabled = true;
                }
                //LbFTime.Text = (DateTime.Parse(LbLS.Text) - DateTime.Parse(LbES.Text)).ToString();
                DateTime DT;
                var      isDate = DateTime.TryParse(TB_RSdate.Text, out DT);

                if (isDate)
                {
                    LbES.Text = LbES.Text != ""? DT.AddDays(int.Parse(LbES.Text)).ToString("yy/MM/dd"):"";
                    LbEF.Text = LbEF.Text != ""?DT.AddDays(int.Parse(LbEF.Text)).ToString("yy/MM/dd"):"";
                    LbLS.Text = LbLS.Text != ""?DT.AddDays(int.Parse(LbLS.Text)).ToString("yy/MM/dd"):"";
                    LbLF.Text = LbLF.Text != ""?DT.AddDays(int.Parse(LbLF.Text)).ToString("yy/MM/dd"):"";
                }
            }
        }
Example #6
0
 public KDateTime AddDays(int days)
 {
     return(new KDateTime(DT.AddDays(days)));
 }