Exemple #1
0
        /// <summary>
        /// 1.註解加上人話。
        /// 2.人話變成function
        /// 3.找出人話中的主詞與動詞
        /// 4.主詞變成類別(也就是物件)
        /// 5.動詞變成方法 (也就是行為)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCalculate_Click(object sender, EventArgs e)
        {
            //若頁面通過驗證
            if (this.IsValid)
            {
                //取得畫面資料
                var product = this.GetProduct();

                var    companyName = "";
                double fee         = 0;

                //ILogistics logistics = this.GetILogistics(this.drpCompany.SelectedValue, product);
                ILogistics logistics = FactoryRepository.GetILogistics(this.drpCompany.SelectedValue, product);

                if (logistics != null)
                {
                    logistics.Calculate();
                    companyName = logistics.GetsComapanyName();
                    fee         = logistics.GetsFee();

                    //呈現結果
                    this.SetResult(companyName, fee);
                }
                else
                {
                    var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true);
                }
            }
        }
Exemple #2
0
        protected void btnCalculate_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                //get the Product information from the webpages
                var product = this.GetProduct();

                var    companyName = "";
                double fee         = 0;

                ILogistics logistics = FactoryRepository.GetILogistics(this.drpCompany.SelectedValue, product);

                /**
                 *
                 * if (this.drpCompany.SelectedValue == "1")
                 * {
                 *
                 *  ILogistics logistics = new BlackCat() { ShipProduct = product };
                 *  logistics.Calculate();
                 *  companyName = logistics.GetsCompanyName();
                 *  fee = logistics.GetsFee();
                 * }
                 * else if (this.drpCompany.SelectedValue == "2")
                 * {
                 *  ILogistics logistics = new Hsinchu() { ShipProduct = product };
                 *  logistics.Calculate();
                 *  companyName = logistics.GetsCompanyName();
                 *  fee = logistics.GetsFee();
                 * }
                 * else if (this.drpCompany.SelectedValue == "3")
                 * {
                 *  ILogistics logistics = new PostOffice() { ShipProduct = product };
                 *  logistics.Calculate();
                 *  companyName = logistics.GetsCompanyName();
                 *  fee = logistics.GetsFee();
                 * }
                 *
                 **/

                if (logistics != null)
                {
                    logistics.Calculate();
                    companyName = logistics.GetsCompanyName();
                    fee         = logistics.GetsFee();

                    this.SetResult(companyName, fee);
                }
                else
                {
                    var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';";
                    this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true);
                }
            }
        }
Exemple #3
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //取得畫面資料
            Product product = this.GetProduct();

            var    companyName = "";
            double fee         = 0;

            ////選黑貓,計算出運費,呈現物流商名稱與運費
            //if (this.drpCompany.SelectedValue.ToString() == "1")
            //{
            //    //CalculatedByBlackCat();
            //    //取得畫面資料

            //    //計算
            //    //BlackCat blackCat = new BlackCat() { ShipProduct = product };
            //    //blackCat.Calculate();

            //    //companyName = blackCat.GetsComapanyName();
            //    //fee = blackCat.GetsFee();

            //    ILogistics logistics = new BlackCat() { ShipProduct = product };
            //    logistics.Calculate();
            //    companyName = logistics.GetsComapanyName();
            //    fee = logistics.GetsFee();
            //}
            ////選新竹貨運,計算出運費,呈現物流商名稱與運費
            //else if (this.drpCompany.SelectedValue.ToString() == "2")
            //{
            //    //CalculatedByHsinchu();
            //    //取得畫面資料

            //    //計算
            //    //Hsinchu hsinchu = new Hsinchu() { ShipProduct = product };
            //    //hsinchu.Calculate();

            //    //companyName = hsinchu.GetsComapanyName();
            //    //fee = hsinchu.GetsFee();

            //    ILogistics logistics = new Hsinchu() { ShipProduct = product };
            //    logistics.Calculate();
            //    companyName = logistics.GetsComapanyName();
            //    fee = logistics.GetsFee();
            //}
            ////選郵局,計算出運費,呈現物流商名稱與運費
            //else if (this.drpCompany.SelectedValue.ToString() == "3")
            //{
            //    //CalculatedByPostOffice();
            //    //取得畫面資料

            //    //計算
            //    //PostOffice postOffice = new PostOffice() { ShipProduct = product };
            //    //postOffice.Calculate();

            //    //companyName = postOffice.GetsComapanyName();
            //    //fee = postOffice.GetsFee();

            //    ILogistics logistics = new PostOffice() { ShipProduct = product };
            //    logistics.Calculate();
            //    companyName = logistics.GetsComapanyName();
            //    fee = logistics.GetsFee();
            //}

            //ILogistics logistics = this.GetILogistics(this.drpCompany.SelectedValue.ToString(), product);

            ILogistics logistics = FactoryRepository.GetILogistics(this.drpCompany.SelectedValue.ToString(), product);

            if (logistics != null)
            {
                logistics.Calculate();
                companyName = logistics.GetsComapanyName();
                fee         = logistics.GetsFee();

                //呈現結果
                this.SetResult(companyName, fee);
            }
            //發生預期以外的狀況,呈現警告訊息,回首頁
            else
            {
                var js = "alert('發生不預期錯誤,請洽系統管理者');location.href='http://tw.yahoo.com/';";
                // this.ClientScript.RegisterStartupScript(this.GetType(), "back", js, true);
            }

            //呈現結果
            this.SetResult(companyName, fee);
        }