예제 #1
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            string strResult = NowUpdateDate(Request.QueryString["ACCEPT_RETURN_NO"]);

            if (strResult != "")
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('" + strResult + "');document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').focus();document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').select();", true);
                return;
            }
            this.btnUpdate.Enabled = false;
            TextBox tex_aaa = (TextBox)((ASP.vdm_slp_slp_vendorbase_ascx)SLP_VENDOR_NEW).FindControl("TextBoxName");
            string strVENDOR_CODE = Request[tex_aaa.UniqueID].ToString();

            if (SLP_VENDOR_NEW.Text.Trim() != string.Empty)
                if (strVENDOR_CODE == "查無資料")
                {
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('請輸入正確之「更新廠商統編」');document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').focus();document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').select();", true);
                    this.btnUpdate.Enabled = true;
                    return;
                }
            string SessionIDName = "VAM082_" + PageTimeStamp.Value;
            DataTable dt = (DataTable)Session[SessionIDName];
            dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
            DataRow Dr;
            bool Upd = false;
            foreach (GridViewRow dr in GridView1.Rows)
            {
                if (((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).Text.Trim().Length == 0) ((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).Text = "0";
                if (((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).Text.Trim().Length != 0)
                {
                    int i = 0;
                    if (Int32.TryParse(((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).Text, out i))
                    {
                        if (i != Int32.Parse(dr.Cells[3].Text))
                        {
                            Dr = dt.Rows.Find(((TextBox)dr.FindControl("txtID")).Text);
                            Dr["ACCEPT_RETURN_QTY"] = Int32.Parse(((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).Text);
                            Upd = true;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('請輸入正確之「更新數量」');document.getElementById('" + ((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).ClientID + "').focus();document.getElementById('" + ((TextBox)dr.FindControl("txtACCEPT_RETURN_QTY")).ClientID + "').select();", true);
                        this.btnUpdate.Enabled = true;
                        return;
                    }
                }
                if (((TextBox)dr.FindControl("txtCOST")).Text.Trim().Length == 0) ((TextBox)dr.FindControl("txtCOST")).Text = "0";
                if (((TextBox)dr.FindControl("txtCOST")).Text.Trim().Length != 0)
                {
                    Decimal d = 0;
                    if (Decimal.TryParse(((TextBox)dr.FindControl("txtCOST")).Text, out d))
                    {
                        if (d != Decimal.Parse(dr.Cells[4].Text))
                        {
                            Dr = dt.Rows.Find(((TextBox)dr.FindControl("txtID")).Text);
                            Dr["COST"] = Decimal.Parse(((TextBox)dr.FindControl("txtCOST")).Text).ToString("0.00");
                            Upd = true;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('請輸入正確之「更新成本」');document.getElementById('" + ((TextBox)dr.FindControl("txtCOST")).ClientID + "').focus();document.getElementById('" + ((TextBox)dr.FindControl("txtCOST")).ClientID + "').select();", true);
                        this.btnUpdate.Enabled = true;
                        return;
                    }
                }
            }
            if (!Upd && SLP_VENDOR_NEW.Text == SLP_VENDOR.Text)
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('您尚未修正任何資料,請重新確認');document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').focus();document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').select();", true);
                this.btnUpdate.Enabled = true;
                return;
            }
            ParameterList.Clear();
            ParameterList.Add(txtACCEPT_RETURN_NO.Text.Trim()); //貨號 0
            ParameterList.Add(Session["UID"].ToString()); // 1
            ParameterList.Add(DateTime.Now); // 2
            ParameterList.Add(SLP_VENDOR_NEW.Text.Trim()); //廠商統編 3
            BCO.MaintainVAMUpdateOrder bco = new BCO.MaintainVAMUpdateOrder(ConntionDB);
            string Msg = string.Empty;
            bco.VAMUpdateOrder((SLP_VENDOR_NEW.Text == SLP_VENDOR.Text ? null : SLP_VENDOR_NEW.Text), ParameterList, dt.GetChanges(DataRowState.Modified), null, out Msg);
            if (Msg != "")
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('" + Msg + "');document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').focus();document.getElementById('" + SLP_VENDOR_NEW.FindControl("TextBoxCode").ClientID + "').select();", true);
                this.btnUpdate.Enabled = true;
                return;
            }
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('更新成功');location.replace('VAM081.aspx?Code=VAM08&ACCEPT_RETURN_NO=" + txtACCEPT_RETURN_NO.Text.Trim() + "');", true);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            this.btnUpdate.Enabled = true;
        }
    }
예제 #2
0
 protected void QueryITEM(string accept_return_no)
 {
     try
     {
         string errMsg = string.Empty;
         ParameterList.Clear();
         ParameterList.Add(accept_return_no);
         BCO.MaintainVAMUpdateOrder bco = new BCO.MaintainVAMUpdateOrder(ConntionDB);
         DataTable dt = bco.QueryVAMUpdateItem(ParameterList);
         if (dt.Rows.Count == 0)
         {
             ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM082.aspx", "alert('查無資料');", true);
             GridView1.Visible = false;
             return;
         }
         GridView1.Visible = true;
         GridView1.DataSource = dt;
         GridView1.DataBind();
         string SessionIDName = "VAM082_" + PageTimeStamp.Value;
         Session[SessionIDName] = dt;
         txtACCEPT_RETURN_NO.Text = dt.Rows[0]["ACCEPT_RETURN_NO"].ToString();
         SLP_VENDOR.Text = dt.Rows[0]["VENDOR"].ToString();
         SLP_VENDOR_NEW.Text = dt.Rows[0]["VENDOR"].ToString();
         if (accept_return_no.Substring(0, 1) == "C")
             lblACCEPT_RETURN_NO.Text = "進貨單號";
         else
             lblACCEPT_RETURN_NO.Text = "退貨單號";
         this.hid_UpdateDate.Value = dt.Rows[0]["Updatedate"].ToString(); //取得資料的更新時間作為比較之用,
     }
     catch (Exception ex)
     {
         ErrorMsgLabel.Text = ex.Message;
     }
 }
예제 #3
0
    protected string NowUpdateDate(string accept_return_no)
    {
        string errMsg = string.Empty;
        ParameterList.Clear();
        ParameterList.Add(accept_return_no);
        BCO.MaintainVAMUpdateOrder bco = new BCO.MaintainVAMUpdateOrder(ConntionDB);
        DataTable dt = bco.QueryVAMUpdateItem(ParameterList);
        if (dt.Rows.Count == 0)
        {
            return "查無資料";
        }
        string NowUpdateTime = dt.Rows[0]["Updatedate"].ToString();

        if (NowUpdateTime != hid_UpdateDate.Value)
        {
            return "更新失敗,此資料已被其他使用者異動,請重新查詢";
        }
        else
        {
            return "";
        }
    }
예제 #4
0
    private void LoadData()
    {
        try
        {
            string errMsg = string.Empty;
            if (SLP_VENDOR_S.Text.Trim().Length == 0 && SLP_VENDOR_E.Text.Trim().Length == 0 && txtACCEPT_RETURN_NO_S.Text.Trim().Length == 0 && txtACCEPT_RETURN_NO_E.Text.Trim().Length == 0)
            {
                //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM081.aspx", "alert('進/退貨號或廠商統編資料必填一欄為查詢條件,請重新輸入');document.getElementById('" + txtACCEPT_RETURN_NO_S.ClientID + "').focus();document.getElementById('" + txtACCEPT_RETURN_NO_S.ClientID + "').select();", true);
                this.ErrorMsgLabel.Text = "進/退貨號或廠商統編資料必填一欄為查詢條件,請重新輸入";
                GridView1.Visible = false;
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM081.aspx", "window.setTimeout(function set_focus(){document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].focus(); document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].select();}, 800);", true);
                return;
            }
            #region 檢查條件
            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage();
            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;

                //this.SetClinetFocus(this.txtACCEPT_RETURN_NO_S.ClientID);
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM081.aspx", "window.setTimeout(function set_focus(){document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].focus(); document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].select();}, 800);", true);
                return;
            }
            #endregion
            ParameterList.Clear();
            ParameterList.Add(SLP_VENDOR_S.Text.Trim());
            ParameterList.Add(SLP_VENDOR_E.Text.Trim());
            ParameterList.Add(txtACCEPT_RETURN_NO_S.Text.Trim());
            ParameterList.Add(txtACCEPT_RETURN_NO_E.Text.Trim());
            ParameterList.Add(TextBoxRowCountLimit.Text.Trim());
            BCO.MaintainVAMUpdateOrder bco = new BCO.MaintainVAMUpdateOrder(ConntionDB);
            DataTable dt = bco.QueryVAMUpdateOrder(ParameterList);
            if (dt.Rows.Count == 0)
            {
                this.ErrorMsgLabel.Text = "查無資料";
                //ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM081.aspx", "alert('查無資料');document.getElementById('" + txtACCEPT_RETURN_NO_S.ClientID + "').focus();document.getElementById('" + txtACCEPT_RETURN_NO_S.ClientID + "').select();", true);
                GridView1.Visible = false;
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "VAM081.aspx", "window.setTimeout(function set_focus(){document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].focus(); document.all['" + txtACCEPT_RETURN_NO_S.ClientID + "'].select();}, 800);", true);
                return;
            }
            GridView1.Visible = true;
            GridView1.DataSource = dt;
            if (TextBoxPagesize.Text == "")
                GridView1.PageSize = 10;
            else
                GridView1.PageSize = Convert.ToInt32(TextBoxPagesize.Text);
            GridView1.PageIndex = 0;
            GridView1.DataBind();
            string SessionIDName = "VAM081_" + PageTimeStamp.Value;
            Session[SessionIDName] = dt;

            #region 將Key值存到Session中

            ArrayList arl_Key = new ArrayList();
            foreach (DataRow drRow in dt.Rows)
            { arl_Key.Add(drRow["ACCEPT_RETURN_NO"].ToString()); }

            Session["VAM081_SortKey" + this.PageTimeStamp.Value] = arl_Key;

            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }