Ejemplo n.º 1
0
        private void EditExistDB()
        {
            int holidayYear  = dateTimeHoliday.Value.Year;
            int holidayMonth = dateTimeHoliday.Value.Month;
            int holidayDay   = dateTimeHoliday.Value.Day;

            SQL.Set_SQL_data("reason", "holiday", "date = '" + holidayYear.ToString() + "-" + holidayMonth.ToString() + "-" + holidayDay.ToString() + "'", textBoxReason.Text);
            if (radioButton1.Checked)
            {
                SQL.Set_SQL_data("working", "holiday", "date = '" + holidayYear.ToString() + "-" + holidayMonth.ToString() + "-" + holidayDay.ToString() + "'", "1");//放假
            }
            else
            {
                SQL.Set_SQL_data("working", "holiday", "date = '" + holidayYear.ToString() + "-" + holidayMonth.ToString() + "-" + holidayDay.ToString() + "'", "2");//補班
            }
        }
Ejemplo n.º 2
0
        protected void Compute(string projectNo, string computeType, string countHoliday, string startDate)
        {
            DayCompute dayCompute = new DayCompute();

            comboBoxNoCountByType.Text = "0";

            if (computeType == "1")//限期完工  日曆天
            {
                //追加工期後總計天數
                this.textBoxTotalDays.Text = this.textBoxTotalDuration.Text;
                this.label29.Text          = "工期計算方式為限期完工";
            }
            else if (computeType == "2")
            {
                //追加工期後總計天數
                this.textBoxTotalDays.Text = this.textBoxTotalDuration.Text;
                this.label29.Text          = "工期計算方式為日曆天";
            }
            else
            {
                if (computeType == "3")//工作天 無休
                {
                    dayCompute.restOnSaturday = false;
                    dayCompute.restOnSunday   = false;
                    this.label29.Text         = "工期計算方式為工作工,無週休二日";
                }
                else if (computeType == "4")//工作天 周休一日
                {
                    dayCompute.restOnSaturday = false;
                    dayCompute.restOnSunday   = true;
                    this.label29.Text         = "工期計算方式為工作工,週休一日";
                    if (dateToday.Value.DayOfWeek == DayOfWeek.Sunday)
                    {
                        comboBoxNoCountByType.Text = "1";
                    }
                }
                else if (computeType == "5")//工作天 周休二日
                {
                    dayCompute.restOnSaturday = true;
                    dayCompute.restOnSunday   = true;
                    this.label29.Text         = "工期計算方式為工作工,週休二日";
                    if (dateToday.Value.DayOfWeek == DayOfWeek.Sunday)
                    {
                        comboBoxNoCountByType.Text = "1";
                    }
                    else if (dateToday.Value.DayOfWeek == DayOfWeek.Saturday)
                    {
                        string extraDay = SQL.Read_SQL_data("working", "holiday", "date = '" + Functions.TransferDateTimeToSQL(dateToday.Value) + "'");
                        if (extraDay == string.Empty || extraDay == "1")
                        {
                            comboBoxNoCountByType.Text = "1";
                        }
                    }
                }

                if (countHoliday == "1")
                {
                    dayCompute.restOnHoliday = true;
                    this.label29.Text       += ",國定假日不施工";
                    string holiday = SQL.Read_SQL_data("working", "holiday", "date = '" + Functions.TransferDateTimeToSQL(dateToday.Value) + "'");
                    if (holiday == "1")
                    {
                        comboBoxNoCountByType.Text = "1";
                    }
                }
                else if (countHoliday == "0")
                {
                    dayCompute.restOnHoliday = false;
                    this.label29.Text       += ",國定假日照常施工";
                }


                DateTime FinishDateAfterExtention = dayCompute.CountByDuration(Functions.TransferSQLDateToDateTime(startDate), Convert.ToSingle(this.textBoxTotalDuration.Text));
                //DateTime FinishDateContract = dayCompute.CountByDuration(Functions.TransferSQLDateToDateTime(startDate), Convert.ToSingle(this.textBoxContractDuration.Text));
                //追加工期後總計天數
                this.textBoxTotalDays.Text = Convert.ToString(FinishDateAfterExtention.Subtract(dateStart.Value).Days + 1);
                ////契約天數
                //this.textBoxContractDays.Text = Convert.ToString(FinishDateContract.Subtract(dateStart.Value).Days + 1);
            }


            //開工迄今天數 = 今日日期 - 開工日期 + 1
            if (this.dateToday.Value.Date.Subtract(this.dateStart.Value.Date).Days + 1 < 0)
            {
                this.dateToday.Value = this.dateStart.Value;
            }
            else
            {
                this.textBoxDaysStartToCurrent.Text = Convert.ToString(this.dateToday.Value.Date.Subtract(this.dateStart.Value.Date).Days + 1);
            }

            //不計工期
            string[] reportDates = SQL.Read1DArray_SQL_Data("date", "dailyreport", "project_no = '" + projectNo + "'");
            for (int i = 0; i < reportDates.Length; i++)
            {
                if (Functions.TransferSQLDateToDateTime(reportDates[i]).CompareTo(dateToday.Value) == -1)//發生早於今日日期
                {
                    float nonCountingDays = Convert.ToSingle(SQL.Read_SQL_data("nonecounting", "dailyreport", "project_no = '" + projectNo + "' AND date = '" + Functions.TransferSQLDateToDateOnly(reportDates[i]) + "'"));
                    if (nonCountingDays == 0.5)
                    {
                        dayCompute.AddNotWorking(Functions.TransferSQLDateToDateTime(reportDates[i]), 0);
                    }
                    else if (nonCountingDays == 1)
                    {
                        dayCompute.AddNotWorking(Functions.TransferSQLDateToDateTime(reportDates[i]), 0);
                        dayCompute.AddNotWorking(Functions.TransferSQLDateToDateTime(reportDates[i]), 1);
                    }
                }
            }
            if (comboBoxNoCount.Text == "0.5")
            {
                dayCompute.AddNotWorking(dateToday.Value, 0);
            }
            else if (comboBoxNoCount.Text == "1")
            {
                dayCompute.AddNotWorking(dateToday.Value, 0);
                dayCompute.AddNotWorking(dateToday.Value, 1);
            }
            this.textBoxDurationNotCount.Text = Convert.ToString(dayCompute.CountTotalNotWorkingDay(dateStart.Value, dateToday.Value));
            //實際工期 = 開工迄今天數 - 不計工期
            this.textBoxRealDuration.Text = Convert.ToString(Convert.ToDecimal(this.textBoxDaysStartToCurrent.Text) - Convert.ToDecimal(this.textBoxDurationNotCount.Text));
            //剩餘工期 = 工期總計 - 實際工期
            this.textBoxRestDuration.Text = Convert.ToString(Convert.ToDecimal(this.textBoxTotalDuration.Text) - Convert.ToDecimal(this.textBoxRealDuration.Text));
            //契約完工日
            this.dateProjectEnd_Contract.Value = Functions.TransferSQLDateToDateTime(SQL.Read_SQL_data("contract_finishdate", "project_info", "project_no ='" + projectNo + "'"));

            if (Convert.ToSingle(this.textBoxRestDuration.Text) < 0)
            {
                //變動完工日從SQL讀出來
                this.dateProjectEnd_Modify.Value = Functions.TransferSQLDateToDateTime(SQL.Read_SQL_data("modified_finishdate", "project_info", "project_no = '" + g_ProjectNumber + "'"));
                //剩餘天數 = 變動完工日 - 今日日期
                this.textBoxRestDays.Text = Convert.ToString(this.dateProjectEnd_Modify.Value.Subtract(dateToday.Value).Days);

                //逾期天數
                this.textBoxOverDays.Text = Convert.ToString(dateToday.Value.Subtract(dateProjectEnd_Modify.Value).Days);
            }
            else
            {
                //變動完工日
                this.dateProjectEnd_Modify.Value = dayCompute.CountByDuration(dateToday.Value.AddDays(1), Convert.ToSingle(this.textBoxRestDuration.Text));
                //把變動完工日寫進SQL
                SQL.Set_SQL_data("modified_finishdate", "project_info", "project_no = '" + g_ProjectNumber + "'", Functions.TransferDateTimeToSQL(this.dateProjectEnd_Modify.Value));


                //剩餘天數 = 變動完工日 - 今日日期
                this.textBoxRestDays.Text = Convert.ToString(this.dateProjectEnd_Modify.Value.Subtract(dateToday.Value).Days);
                //逾期天數
                this.textBoxOverDays.Text = "0";
            }
        }