Exemple #1
0
    private void bindMain()
    {
        try
        {
            if (this.hid_Page_Status.Value == "VIEW")//Model:檢視
            {
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                //將報表列印所需要的報表欄位參數加入HiddenField
                DataTable dtHidField = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString());

                if (dtHidField.Rows.Count > 0)
                {
                    this.hidContract.Value=dtHidField.Rows[0]["Business_Contact"].ToString();
                    this.hidFax.Value = dtHidField.Rows[0]["Business_Fax"].ToString();
                    this.hidReturnDate.Value = dtHidField.Rows[0]["Return_Date"].ToString();
                    this.hid_Tax_Total_Amt.Value = dtHidField.Rows[0]["Tax_Total_Amt"].ToString();
                    this.hid_UnTax_Total_Amt.Value = dtHidField.Rows[0]["UnTax_Total_Amt"].ToString();
                    this.hid_Tax_Amt.Value = dtHidField.Rows[0]["Tax_Amt"].ToString();
                }

                DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString());

                if (dtResult.Rows.Count == 1)
                {
                    this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString();
                    this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString();
                    this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString();
                    this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();
                    this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString();
                    this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString();
                    this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString();
                    this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString();
                    this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString();
                    VGRModel.GetSysData BCOSysData = new VGRModel.GetSysData(ConntionDB);

                    string Apl_Date = BCOSysData.GetBUSDate();

                    if (Apl_Date == string.Empty)
                    {
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('未取得檢核日期 ');", true);
                        return;
                    }

                    string VAMClosed = BCOSysData.CheckVAMClosedYN(Apl_Date);

                    this.btnEdit.Enabled = VAMClosed == "N";
                    this.btnSave.Enabled = false;
                    this.btnCancel.Enabled = false;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VGR01", "alert('無資料可供查詢 ');", true);
                    return;
                }
            }
            else if (this.hid_Page_Status.Value == "UPDATE")//Model:編輯(更新)
            {
                //取得TARGET LOCATE SECTION

                ParameterList.Clear();
                ParameterList.Add("B");
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                string strReturnLocateNo = "";

                string strReturnLocateSection = "";

                BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection);

                ReturnLocateNo = strReturnLocateNo;

                ReturnLocateSection = strReturnLocateSection;

                hid_LocateSection.Value = ReturnLocateSection;

                if (ReturnLocateSection == string.Empty)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true);
                }

                DataTable dtResult = BCOVGR.QueryMainByID(Request.QueryString["ID"].ToString());

                if (dtResult.Rows.Count == 1)
                {
                    this.txtRemoveNo.Text = dtResult.Rows[0]["return_no"].ToString();
                    this.txtAdjNo.Text = dtResult.Rows[0]["adjust_no"].ToString();
                    this.txtSum.Text = dtResult.Rows[0]["sum_qty"].ToString();
                    this.SLP_Date.Text = dtResult.Rows[0]["return_date"].ToString();
                    this.SLP_Vendor.Text = dtResult.Rows[0]["vendor"].ToString();
                    this.lblCretaeDate.Text = dtResult.Rows[0]["createdate"].ToString();
                    this.SLP_CUser.Text = dtResult.Rows[0]["createuid"].ToString();
                    this.lblMaintainDate.Text = dtResult.Rows[0]["UpdateDate"].ToString();
                    this.SLP_MUser.Text = dtResult.Rows[0]["updateuid"].ToString();
                    this.hid_UpdateTime.Value = dtResult.Rows[0]["UpdateTime"].ToString();
                    this.btnEdit.Visible = false;
                    this.btnAddDetail.Enabled = false;
                }
            }
            else if (this.hid_Page_Status.Value == "INSERT")//Model:新增
            {
                //取得TARGET LOCATE SECTION

                ParameterList.Clear();
                ParameterList.Add("B");
                VGRModel.MaintainReturnData BCOVGR = new VGRModel.MaintainReturnData(ConntionDB);

                string strReturnLocateNo = "";

                string strReturnLocateSection = "";

                BCOVGR.QueryTargetLocate(ParameterList, out strReturnLocateNo, out strReturnLocateSection);

                ReturnLocateNo = strReturnLocateNo;

                ReturnLocateSection = strReturnLocateSection;

                hid_LocateSection.Value = ReturnLocateSection;

                if (ReturnLocateSection == string.Empty)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "alert('廠退作業尚未設定對應儲格'); window.location.href = 'VGR011.aspx';", true);
                }

                this.SLP_Date.Text = strToday;

                this.SLP_CDate.Text = strToday;
                this.SLP_CUser.Text = Session["UID"].ToString();
                this.SLP_MDate.Text = strToday;
                this.SLP_MUser.Text = Session["UID"].ToString();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }