Ejemplo n.º 1
0
        private void LoadInfoByDate(string projectNo)
        {
            //今日開始追加工期
            int       accuextendduration = 0;
            ArrayList extendDate         = new ArrayList();

            string[] extendDates = SQL.Read1DArray_SQL_Data("extendstartdate", "extendduration", "project_no ='" + projectNo + "'");
            this.textBoxExtendToday.Text = "0";
            for (int i = 0; i < extendDates.Length; i++)
            {
                DateTime extDate = Functions.TransferSQLDateToDateTime(extendDates[i]);
                if (extDate.Date.CompareTo(dateToday.Value.Date) == 0)//為追加起始日
                {
                    this.textBoxExtendToday.Text = SQL.Read_SQL_data("extendduration", "extendduration", "project_no ='" + projectNo + "' AND extendstartdate = '" + Functions.TransferDateTimeToSQL(dateToday.Value) + "'");
                }

                if ((extDate.Date.CompareTo(dateToday.Value.Date) == 0 || extDate.Date.CompareTo(dateToday.Value.Date) == -1) && extDate.Date.CompareTo(Functions.TransferSQLDateToDateTime(g_StartDate)) != -1)//0為追加起始日   -1為開始日比今日日期早
                {
                    int extendDuration = Convert.ToInt32(SQL.Read_SQL_data("extendduration", "extendduration", "project_no = '" + projectNo + "' AND extendstartdate = '" + Functions.TransferDateTimeToSQL(extDate) + "'"));
                    accuextendduration += extendDuration;
                }
            }
            //累計追加工期
            this.textBoxAccumulateExtend.Text = accuextendduration.ToString();
            //工期總計
            this.textBoxTotalDuration.Text = Convert.ToString(Convert.ToSingle(SQL.Read_SQL_data("contractduration", "project_info", "project_no ='" + projectNo + "'")) + accuextendduration);
        }
Ejemplo n.º 2
0
 private void comboBoxCity_SelectedIndexChanged(object sender, EventArgs e)
 {
     string[] districts = SQL.Read1DArray_SQL_Data("district", "city", "city = '" + comboBoxCity.SelectedItem + "'");
     comboBoxDistrict.Items.Clear();
     for (int i = 0; i < districts.Length; i++)
     {
         comboBoxDistrict.Items.Add(districts[i]);
     }
     comboBoxDistrict.SelectedIndex = 0;
 }
Ejemplo n.º 3
0
        protected virtual void btnSave_Click(object sender, EventArgs e)
        {
            label28.Visible = false;
            label29.Visible = false;
            label30.Visible = false;

            if (textBoxProjectNo.Text == string.Empty)
            {
                label28.Visible = true;
            }

            if (textBoxProjectName.Text == string.Empty)
            {
                label29.Visible = true;
            }

            if (textBoxContractNo.Text == string.Empty)
            {
                label30.Visible = true;
            }

            if (textBoxProjectNo.Text == string.Empty)
            {
                return;
            }
            if (textBoxProjectName.Text == string.Empty)
            {
                return;
            }
            if (textBoxContractNo.Text == string.Empty)
            {
                return;
            }

            string[] sameNo = SQL.Read1DArray_SQL_Data("project_no", "project_info", "project_no = '" + textBoxProjectNo.Text + "'");
            if (sameNo.Length != 0)
            {
                label28.Text    = "已存在相同工程編號";
                label28.Visible = true;
                return;
            }

            sameNo = SQL.Read1DArray_SQL_Data("contract_no", "project_info", "contract_no = '" + textBoxContractNo.Text + "'");
            if (sameNo.Length != 0)
            {
                label30.Text    = "已存在相同契約號";
                label30.Visible = true;
                return;
            }


            InsertIntoDB();//插入資料進SQL
            this.Close();
        }
Ejemplo n.º 4
0
 private void MenuItemDailyReportEdit_Click(object sender, EventArgs e)
 {
     string[] reportDates = SQL.Read1DArray_SQL_Data("date", "dailyreport", "project_no ='" + g_ProjectNo + "' ORDER BY date DESC");
     if (reportDates.Length == 0)//表示這個工程目前並沒有輸入任何日報表
     {
         MessageBox.Show("此工程目前並沒有任何已存在的日報表,\r\n請重新選擇工程或建立日報表", "無法編輯", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         DailyReportEditForm reportEditForm = new DailyReportEditForm(g_ProjectNo);
         reportEditForm.ShowDialog();
     }
 }
Ejemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int holidayYear  = dateTimeHoliday.Value.Year;
            int holidayMonth = dateTimeHoliday.Value.Month;
            int holidayDay   = dateTimeHoliday.Value.Day;

            string[] duplicateDates = SQL.Read1DArray_SQL_Data("date", "holiday", "date = '" + holidayYear.ToString() + "-" + holidayMonth.ToString() + "-" + holidayDay.ToString() + "'");
            if (duplicateDates.Length != 0)
            {
                DialogResult result = MessageBox.Show("此日期已存在,確定要修改?", "確定", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (result == DialogResult.Yes)
                {
                    EditExistDB();
                    RefreshDatagridview();
                    this.textBoxReason.Clear();
                    this.radioButton1.Checked = true;
                    this.radioButton2.Checked = false;
                }
            }
            else
            {
                InsertIntoDB();
                RefreshDatagridview();
                this.textBoxReason.Clear();
                this.radioButton1.Checked = true;
                this.radioButton2.Checked = false;
            }
        }
        protected virtual void btnOK_Click(object sender, EventArgs e)
        {
            label12.Visible = false;

            if (textBoxGrantNumber.Text == string.Empty)
            {
                label12.Visible = true;
            }

            if (textBoxGrantNumber.Text == string.Empty)
            {
                return;
            }

            string[] sameNo = SQL.Read1DArray_SQL_Data("grantnumber", "extendduration", "project_no = '" + ProjectNumber + "' AND grantnumber = '" + textBoxGrantNumber.Text + "'");
            if (sameNo.Length != 0)
            {
                label12.Text    = "已存在相同核准文號";
                label12.Visible = true;
                return;
            }


            InsertIntoDB();
            this.Close();
        }
        ////////////////////////
        //Event Handler
        ////////////////////////
        protected virtual void btnSave_Click(object sender, EventArgs e)
        {
            label18.Visible = false;
            label19.Visible = false;
            label20.Visible = false;

            if (textBoxVendor_No.Text == string.Empty)
            {
                label18.Text    = "廠商編號不可為空白";
                label18.Visible = true;
            }


            if (textBoxVendor_Name.Text == string.Empty)
            {
                label19.Visible = true;
            }

            if (textBoxVendor_No.Text == string.Empty)
            {
                return;
            }
            if (textBoxVendor_Name.Text == string.Empty)
            {
                return;
            }

            string[] sameNo = SQL.Read1DArray_SQL_Data("vendor_no", "vendor", "vendor_no = '" + textBoxVendor_No.Text + "'");
            if (sameNo.Length != 0)
            {
                label18.Text    = "已存在相同廠商編號";
                label18.Visible = true;
                return;
            }

            if (textBoxEmail.Text != string.Empty)
            {
                if (!textBoxEmail.Text.Contains("@"))
                {
                    label20.Visible = true;
                    return;
                }
            }

            InsertIntoDB();
            Clear();
        }
Ejemplo n.º 8
0
        public DayCompute()
        {
            dbHost = AppSetting.LoadInitialSetting("DB_IP", "127.0.0.1");
            dbUser = AppSetting.LoadInitialSetting("DB_USER", "root");
            dbPass = AppSetting.LoadInitialSetting("DB_PASSWORD", "123");
            dbName = AppSetting.LoadInitialSetting("DB_NAME", "huachun");
            SQL    = new MySQL(dbHost, dbUser, dbPass, dbName);

            string[] holidays        = SQL.Read1DArray_SQL_Data("date", "holiday", "working = '1'");
            string[] extraWorkingday = SQL.Read1DArray_SQL_Data("date", "holiday", "working = '2'");
            for (int i = 0; i < holidays.Length; i++)
            {
                DateTime holiday = Functions.TransferSQLDateToDateTime(holidays[i]);
                arrayHoliday.Add(holiday);
            }

            for (int i = 0; i < extraWorkingday.Length; i++)
            {
                DateTime workingDay = Functions.TransferSQLDateToDateTime(extraWorkingday[i]);
                arrayWorking.Add(workingDay);
            }
        }
        public void LoadProjectInfo(string number)
        {
            g_ProjectNo = number;
            dataTableStatistic.Clear();


            DayCompute dayCompute = new DayCompute();
            string computeType = SQL.Read_SQL_data("computetype", "project_info", "project_no = '" + g_ProjectNo + "'");
            string countHoliday = SQL.Read_SQL_data("holiday", "project_info", "project_no = '" + g_ProjectNo + "'");


            if (computeType == "1")//限期完工  日曆天
            {
                this.label1.Text = "工期計算方式為限期完工";
            }
            else if (computeType == "2")
            {
                this.label1.Text = "工期計算方式為日曆天";
            }
            else if (computeType == "3")//工作天 無休
            {
                dayCompute.restOnSaturday = false;
                dayCompute.restOnSunday = false;
                this.label1.Text = "工期計算方式為工作工,無週休二日";
            }
            else if (computeType == "4")//工作天 周休一日
            {
                dayCompute.restOnSaturday = false;
                dayCompute.restOnSunday = true;
                this.label1.Text = "工期計算方式為工作工,週休一日";
            }
            else if (computeType == "5")//工作天 周休二日
            {
                dayCompute.restOnSaturday = true;
                dayCompute.restOnSunday = true;
                this.label1.Text = "工期計算方式為工作工,週休二日";
            }

            if (countHoliday == "1")
            {
                dayCompute.restOnHoliday = true;
                this.label1.Text += ",國定假日不施工";
            }
            else if (countHoliday == "0")
            {
                dayCompute.restOnHoliday = false;
                this.label1.Text += ",國定假日照常施工";
            }

            string rainyDayCountType = SQL.Read_SQL_data("rainyday", "project_info", "project_no = '" + g_ProjectNo + "'");
            if (rainyDayCountType == "1")
            {
                this.label3.Text += "需豪雨才不計工期";
            }
            else if (rainyDayCountType == "0")
            {
                this.label3.Text += "下雨即不計工期";
            }

            float originalTotalDuration = Convert.ToSingle(SQL.Read_SQL_data("contractduration", "project_info", "project_no = '" + g_ProjectNo + "'"));
            float originalTotalDays = Convert.ToSingle(SQL.Read_SQL_data("contractdays", "project_info", "project_no = '" + g_ProjectNo + "'"));
            DateTime originalFinishDate = Functions.TransferSQLDateToDateTime(SQL.Read_SQL_data("contract_finishdate", "project_info", "project_no = '" + g_ProjectNo + "'"));
            string[] extendDurationStartDates = SQL.Read1DArray_SQL_Data("extendstartdate", "extendduration", "project_no = '" + g_ProjectNo + "'");
            float accumulateExtendDurations = 0;

            string startDate = SQL.Read_SQL_data("startdate", "project_info", "project_no = '" + g_ProjectNo + "'");
            DTStartDate = Functions.TransferSQLDateToDateTime(startDate);
            DataRow dataRow;

            int i = 0;
            bool stop = false;
            while (!stop)
            {

                DateTime dateToday = DTStartDate.AddDays(i);

                dataRow = dataTableStatistic.NewRow();


                dataRow["日期"] = dateToday.ToString("yyyy/MM/dd");
                dataRow["開工迄今"] = (i + 1).ToString();
                dataRow["星期"] = Functions.ComputeDayOfWeek(dateToday);
                //Image img = Image.FromFile("D:\\12Small.jpg");
                //dataRow["農曆"] = imageToByteArray(img);
                dataRow["節日"] = dayCompute.GetCondition(dateToday);
                string morningWeather = SQL.Read_SQL_data("morning_weather", "dailyreport", "project_no = '" + g_ProjectNo + "' AND date = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");
                dataRow["上午天氣"] = (morningWeather == string.Empty) ? "無資料" : morningWeather;
                string afternoonWeather = SQL.Read_SQL_data("afternoon_weather", "dailyreport", "project_no = '" + g_ProjectNo + "' AND date = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");
                dataRow["下午天氣"] = (afternoonWeather == string.Empty) ? "無資料" : afternoonWeather;
                string morningCondition = SQL.Read_SQL_data("morning_condition", "dailyreport", "project_no = '" + g_ProjectNo + "' AND date = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");
                dataRow["上午人為因素"] = (morningCondition == string.Empty) ? "無資料" : morningCondition;
                string afternoonCondition = SQL.Read_SQL_data("afternoon_condition", "dailyreport", "project_no = '" + g_ProjectNo + "' AND date = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");
                dataRow["下午人為因素"] = (afternoonCondition == string.Empty) ? "無資料" : afternoonCondition;
                
                
                string nonCountingToday = SQL.Read_SQL_data("nonecounting", "dailyreport", "project_no = '" + g_ProjectNo + "' AND date = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");



                if (nonCountingToday == "0.5")
                    dayCompute.AddNotWorking(dateToday, 0);
                else if (nonCountingToday == "1")
                {
                    dayCompute.AddNotWorking(dateToday, 0);
                    dayCompute.AddNotWorking(dateToday, 1);
                }

                dataRow["本日不計工期"] = dayCompute.GetWorkingDayNonCounting(dateToday);

                float nonCountingTotal = dayCompute.CountTotalNotWorkingDay(DTStartDate, dateToday);

                dataRow["累計不計工期"] = nonCountingTotal;
                dataRow["累計工期"] = i + 1 - nonCountingTotal;


                dataRow["原剩餘工期"] = originalTotalDuration - 1 - i + dayCompute.CountNotWorkingDayWithoutEverydayCondition(DTStartDate, dateToday);
                dataRow["原剩餘天數"] = originalTotalDays - 1 - i;
                dataRow["原完工日"] = originalFinishDate.ToString("yyyy/MM/dd");


                string extendDuration = SQL.Read_SQL_data("extendduration", "extendduration", "project_no = '" + g_ProjectNo + "' AND extendstartdate = '" + Functions.TransferDateTimeToSQL(dateToday) + "'");
                if (extendDuration != string.Empty)
                {
                    accumulateExtendDurations += Convert.ToSingle(extendDuration);
                    dataRow["追加工期"] = extendDuration;
                }

                float modifiedRestDuration = originalTotalDuration - 1 - i + nonCountingTotal + accumulateExtendDurations;
                dataRow["變動剩餘工期"] = modifiedRestDuration;


                DateTime modifiedFinishDate = dayCompute.CountByDuration(dateToday.AddDays(1), modifiedRestDuration);
                dataRow["變動完工日"] = modifiedFinishDate.ToString("yyyy/MM/dd");
                if (dateToday.CompareTo(modifiedFinishDate) == 0)
                    stop = true;
                dataRow["變動剩餘天數"] = modifiedFinishDate.Subtract(dateToday).Days;

                dataRow["原百分比"] = "";
                dataTableStatistic.Rows.Add(dataRow);
                i++;
            }
            //dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Red;
        }