コード例 #1
0
ファイル: PUR022.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    //刪除主檔 事件
    protected void BtnDelMain_Click(object sender, EventArgs e)
    {
        ErrorMsgLabel.Text = "";
        if (this.hid_PageStatus.Value == "VIEW")
        {
            try
            {
                if (this.hiddenIsClose.Value == "1")
                {
                    //判斷採購單是否有"在途單"內
                    MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                    bool IsOK = bco.CheckPurchaseIsOnWay(this.tbxPUR_No.Text);

                    if (IsOK)
                    {
                        this.hid_PageStatus.Value = "VIEW";
                        this.txt_PageStatus.Text = "VIEW";
                        ErrorMsgLabel.Text = "該採購單有在途單,不可進行刪除!!";
                    }
                    else
                    {
                        //如驗收單已有資料時,不得刪除資料。
                        bool IsAcceptOK = bco.CheckPurchaseIsACCEPT(this.tbxPUR_No.Text);
                        if (IsAcceptOK)
                        {
                            this.hid_PageStatus.Value = "VIEW";
                            this.txt_PageStatus.Text = "VIEW";
                            ErrorMsgLabel.Text = "該採購單已有驗收單資料,不可進行刪除!!";
                        }
                        else
                        {
                            ////判斷採購單的採購日是否己日結
                            //VGIModel.CheckVendorAccountClose dbo = new PIC.VDS2G.LGT.VGI.CheckVendorAccountClose(ConntionDB);
                            //string IsClosed = dbo.CheckVendorCloseStaus(DateTime.Parse(this.PUR_PURDate.Text).ToString("yyyyMMdd"));
                            //if (IsClosed == "1")
                            //{
                            //    ErrorMsgLabel.Text = "該採購單日已日結,不可進行修改!!";
                            //}
                            //else
                            //{
                            DataTable dtMasterOLD = (DataTable)ViewState["MasterOLDData"];
                            DataTable dtDetailOLD = (DataTable)ViewState["DetailOLDData"];
                            DataTable dtGiftOLD = (DataTable)ViewState["GiftOLDData"];

                            #region 刪除主檔時,相關動作
                            bco.DeteleMain_DetailData(this.tbxPUR_No.Text, Session["UID"].ToString(), null);
                            ShowErrorMessage("刪除完成!!");
                            Response.Redirect("PUR021.aspx?Code=PUR02");
                            #endregion
                            //}
                        }
                    }
                }
                else
                {
                    ShowErrorMessage("該採購單已結案,不可刪除!!");
                }
            }
            catch (Exception ex)
            {
                this.ErrorMsgLabel.Text = ex.Message;
            }
            finally
            {

            }
        }
    }