protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        try
        {
            //清除目前選擇DATA            
            this.SelectLabelCode.Text = "";
            this.SelectLabelName.Text = "";

            GridView1.PageSize = Convert.ToInt32(TextBoxPagesize.Text.Trim());
            VDMModel.MaintainVendorAgm bco = new VDMModel.MaintainVendorAgm(ConntionDB);
            firstpage = 0;
            firstindex = -1;

            ParameterList.Clear();
            ParameterList.Add(TextBoxRowCountLimit.Text.Trim());            
            ParameterList.Add("%" + TextBoxCode.Text.Trim() + "%");

            databind(bco.QueryByLikeForSLP(ParameterList));
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }//ButtonQuery_Click
Beispiel #2
0
    //匯出
    protected void btnExport_Click(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage(sender);

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(GetValueSetParameter((this.ddlPAY_TYPE.Text == "" ? "0" : ddlPAY_TYPE.Text), "int", this.CheckBoxLikeSearch.Checked));
            //ParameterList.Add(0); //PAY_TYPE欄位,先放0,待SLP有值後再用上面的Code
            ParameterList.Add(GetValueSetParameter(this.txtCOL_DAYS.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_NO.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_VALID_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_VALID_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_END_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_END_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtSTOP_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtSTOP_DATE.EndDate, "date", false));
            //是否停止往來
            if (this.rdoSTOP_DATE1.Checked == true)
                ParameterList.Add(GetValueSetParameter("1", "string", false));
            else if (this.rdoSTOP_DATE2.Checked == true)
                ParameterList.Add(GetValueSetParameter("2", "string", false));
            else
                ParameterList.Add(GetValueSetParameter("3", "string", false));

            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_B1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_B2.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_E1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_E2.Text, "string", false));
            //是否最新合約
            if (this.rdoIS_NEW1.Checked == true)
                ParameterList.Add(GetValueSetParameter("Y", "string", false));
            else
                ParameterList.Add(GetValueSetParameter("N", "string", false));

            //審核
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_CODE.Text.Trim(), "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtCREATEDATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCREATEDATE.EndDate, "date", false));
            //建立人員
            ParameterList.Add(GetValueSetParameter(this.txtCREATEUID.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            //維護日期
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEDATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEDATE.EndDate, "date", false));
            //維護人員
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEUID.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(TextBoxRowCountLimit.Text.Trim().Length == 0 ? "10" : TextBoxRowCountLimit.Text);
            //廠商名稱
            ParameterList.Add(GetValueSetParameter(this.txtVENDOR_NAME.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));

            DataTable dt_Return = new DataTable();

            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            dt_Return = bco.QueryAgmByALL(ParameterList);

            if (dt_Return.Rows.Count <= 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM021", string.Format("alert('查無資料');", Session["UID"].ToString().Trim()), true);
                return;
            }

            Response.Clear();
            string sFileName = HttpUtility.UrlEncode("VDM02供應商合約_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".xls", System.Text.Encoding.UTF8);
            Response.AddHeader("content-disposition", "attachment;filename=" + sFileName);
            Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
            this.EnableViewState = false;
            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

            GridView1.DataSource = dt_Return;
            GridView1.DataBind();
            GridView1.RenderControl(oHtmlTextWriter);
            Response.Write(oStringWriter.ToString());
            Response.Flush();
            Response.End();
        }
        catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }
    }
Beispiel #3
0
    }//page_load

    protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage(sender);

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(GetValueSetParameter((this.ddlPAY_TYPE.Text == "" ? "0" : ddlPAY_TYPE.Text), "int", this.CheckBoxLikeSearch.Checked));
            //ParameterList.Add(0); //PAY_TYPE欄位,先放0,待SLP有值後再用上面的Code
            ParameterList.Add(GetValueSetParameter(this.txtCOL_DAYS.Text.Trim(), "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_NO.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_VALID_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_VALID_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_END_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_END_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_DATE.EndDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtSTOP_DATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtSTOP_DATE.EndDate, "date", false));
            //是否停止往來
            if (this.rdoSTOP_DATE1.Checked == true)
                ParameterList.Add(GetValueSetParameter("1", "string", false));
            else if (this.rdoSTOP_DATE2.Checked == true)
                ParameterList.Add(GetValueSetParameter("2", "string", false));
            else
                ParameterList.Add(GetValueSetParameter("3", "string", false));

            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_B1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_B2.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_E1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtTRACE_DATE_E2.Text, "string", false));
            //是否最新合約
            if (this.rdoIS_NEW1.Checked == true)
                ParameterList.Add(GetValueSetParameter("Y", "string", false));
            else
                ParameterList.Add(GetValueSetParameter("N", "string", false));

            //審核
            ParameterList.Add(GetValueSetParameter(this.txtCNT_CONFIRM_CODE.Text.Trim(), "string", false));
            ParameterList.Add(GetValueSetParameter(this.txtCREATEDATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtCREATEDATE.EndDate, "date", false));
            //建立人員
            ParameterList.Add(GetValueSetParameter(this.txtCREATEUID.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            //維護日期
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEDATE.StartDate, "date", false));
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEDATE.EndDate, "date", false));
            //維護人員
            ParameterList.Add(GetValueSetParameter(this.txtUPDATEUID.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(TextBoxRowCountLimit.Text.Trim().Length == 0 ? "10" : TextBoxRowCountLimit.Text);

            //廠商名稱
            ParameterList.Add(GetValueSetParameter(this.txtVENDOR_NAME.Text.Trim(), "string", this.CheckBoxLikeSearch.Checked));

            DataTable dt_Return = new DataTable();

            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            dt_Return = bco.QueryAgmByALL(ParameterList);

            if (dt_Return.Rows.Count <= 0)
            {
                //btnExport.Visible = false;
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM021", string.Format("alert('查無資料');", Session["UID"].ToString().Trim()), true);
                gv_VDM021.DataSource = dt_Return;
                gv_VDM021.DataBind();
                return;
            }
            string SessionIDName = "VDM021_gv_ItemInfo" + PageTimeStamp.Value;

            gv_VDM021.Visible = true;
            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dt_Return;
            gv_VDM021.DataSource = dt_Return;
            if (TextBoxPagesize.Text == "")
                gv_VDM021.PageSize = 10;
            else
                gv_VDM021.PageSize = Convert.ToInt32(TextBoxPagesize.Text);
            gv_VDM021.PageIndex = 0;
            gv_VDM021.DataBind();

            //btnExport.Visible = true;
            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "VDM021.aspx?Code=VDM02", null, WUI_GMToolbarV.ClickAction.LinkURL);
            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, true, "", btnExport, WUI_GMToolbarV.ClickAction.ButtonClick);
            #region 將Key值存到Session中

            ArrayList arl_Key = new ArrayList();
            foreach (DataRow drRow in dt_Return.Rows)
            { arl_Key.Add(drRow["CNT_NO"].ToString() + "|" + drRow["EDIT_NO"].ToString()); }

            Session["VDM021_SortKey" + PageTimeStamp.Value] = arl_Key;

            #endregion
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.ToString();
        }
        finally { }
    }
Beispiel #4
0
    protected void btnAdd_Mode_Command(object sender, CommandEventArgs e)
    {
        btnDel.Visible = false;

        if (e.CommandName == "btnAdd_Mode")
        {
            ClearAllField();
            slpRESUME_DATE_B.Text = slpCNT_VALID_DATE.Text;
            slpRESUME_DATE_E.Text = slpCNT_END_DATE.Text;
            txtEDIT_NO.Text = "1";
            this.SLP_SLPDate1.Text = System.DateTime.Now.ToShortDateString();
            this.SLP_User1.Text = Session["UID"].ToString();
            this.SLP_SLPDate2.Text = System.DateTime.Now.ToShortDateString();
            this.SLP_User2.Text = Session["UID"].ToString();
        }
        else if (e.CommandName == "btnCopy_Mode")
        {
            ClearCopyField();
            slpRESUME_DATE_B.Text = slpCNT_VALID_DATE.Text;
            slpRESUME_DATE_E.Text = slpCNT_END_DATE.Text;
            txtEDIT_NO.Text = "1";
            this.SLP_SLPDate1.Text = System.DateTime.Now.ToShortDateString();
            this.SLP_User1.Text = Session["UID"].ToString();
            this.SLP_SLPDate2.Text = System.DateTime.Now.ToShortDateString();
            this.SLP_User2.Text = Session["UID"].ToString();        
        }
        else if (e.CommandName == "btnModify_Mode")
        {
            btnAdd.CommandName = "確定修改";
        }

        if (slpCNT_CONFIRM_CODE.Text == "1") //已審核
        {
            DisableForm(true);//true 不可修改
            SpecCalc(true);//false 不可修改 -> 特殊計算處理            
            btnAdd.Enabled = false;
            slpRESUME_DATE_B.ReadOnly = true;
            if (Request["VDM021"].ToString() != "ADD")
            {
                GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.UpdateEdit;
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "VDM021.aspx?Code=VDM02", null, WUI_GMToolbarV.ClickAction.LinkURL);
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", btnAdd, WUI_GMToolbarV.ClickAction.ButtonClick);
            }

            //最新合約資料才可新增履歷
            ParameterList.Clear();
            ParameterList.Add(txtVENDOR_CODE.Text); //廠商統編
            ParameterList.Add(txtCNT_NO.Text); //合約編號
            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            string Dt = bco.QueryMaxEditNo(ParameterList);
            if (txtEDIT_NO.Text != Dt)
            {
                slpRESUME_DATE_E.ReadOnly = true;
                btnADD_RESUME.Enabled = false;
                btnExtendDate.Enabled = false;
            }
            else
            {
                slpRESUME_DATE_E.ReadOnly = false;
                btnADD_RESUME.Enabled = true;
                btnExtendDate.Enabled = true;
            }
        }
        else //未審核
        {
            DisableForm(false);//true 不可修改
            if (txtEDIT_NO.Text.Trim() != "1") //只有異動序號在1的時候才可以修改
            {
                slpCNT_VALID_DATE.ReadOnly = true;
                slpCNT_END_DATE.ReadOnly = true;
            }
            SpecCalc(false);//false 不可修改 -> 特殊計算處理
            btnAdd.Enabled = true;
            //slpCNT_CONFIRM_DATE.Text = DateTime.Today.ToString();
            if (Request["VDM021"].ToString() != "ADD")
            {
                GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.UpdateEdit;
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "VDM021.aspx?Code=VDM02", null, WUI_GMToolbarV.ClickAction.LinkURL);
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", btnAdd, WUI_GMToolbarV.ClickAction.ButtonClick);
            }
        }
        btnAdd_Mode.Visible = false;
        btnModify_Mode.Visible = false;
        btnCopy_Mode.Visible = false;
        btnAdd.Visible = true;
        slpACCEPT_RATE.ReadOnly = true;
        slpRETURN_RATE.ReadOnly = true;

        radFixAmt.Checked = true;
        radFixPercent.Checked = false;
        slpPAY_TYPE.Text = "";
        slpPAY_TYPE.ReadOnly = true;

        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, false, "", btnDel, WUI_GMToolbarV.ClickAction.ButtonClick);

        UpdatePanel1.Update();
        UpdatePanel2.Update();
        UpdatePanel3.Update();
        UpdatePanel4.Update();
        UpdatePanel4_1.Update();
        UpdatePanel5.Update();
        UpdatePanel6.Update();
        UpdatePanel_SUBSIDY2.Update();
        UpdatePanel9.Update();
        UpdatePanel7.Update();
    }
Beispiel #5
0
    //新增履歷(Confirm確認後的處理)
    //strExtend 0:新增履歷 1:延長結束日履歷
    private void AddResume(string strExtend)
    {
        DataSet ds = new DataSet();
        string SessionIDName = "VDM022_" + PageTimeStamp.Value;
        ds = (DataSet)Session[SessionIDName];
        try
        {
            #region 異動合約主檔履歷結束日
            ParameterList.Clear();
            ParameterList.Add(txtVENDOR_CODE.Text);
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["CNT_NO"].ToString());//V_OLD_CNT_NO
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString());//N_EDIT_NO
            ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID
            ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID

            ParameterList.Add(slpRESUME_DATE_E.Text);//N_RESUME_DATE_E 履歷迄日
            ParameterList.Add(System.DateTime.Now);//D_NEW_UPDATEDATE
            ParameterList.Add(Session["UID"].ToString());//V_NEW_UPDATEUID

            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            bco.UpdateResumeEDate(ParameterList, null);
            #endregion

            //把所有資料存到DataSet後傳給VDM101
            DataTable dt = ds.Tables["Table_0"];

            dt.Rows[0]["EDIT_NO"] = Int16.Parse(dt.Rows[0]["EDIT_NO"].ToString()) + 1;
            dt.Rows[0]["VENDOR_CODE"] = txtVENDOR_CODE.Text;
            dt.Rows[0]["PAY_TYPE"] = ddlPAY_TYPE.Text;
            dt.Rows[0]["COL_DAYS"] = txtCOL_DAYS.Text;
            dt.Rows[0]["CNT_VALID_DATE"] = slpCNT_VALID_DATE.Text;
            dt.Rows[0]["CNT_END_DATE"] = slpCNT_END_DATE.Text;
            dt.Rows[0]["CNT_CONFIRM_CODE"] = slpCNT_CONFIRM_CODE.Text;
            dt.Rows[0]["CNT_CONFIRM_DATE"] = System.DBNull.Value;
            dt.Rows[0]["CNT_NO"] = txtCNT_NO.Text;
            dt.Rows[0]["TRACE_DATE_B"] = System.DBNull.Value;//VARCHAR2(6)型態
            dt.Rows[0]["TRACE_DATE_E"] = System.DBNull.Value;//VARCHAR2(6)型態
            dt.Rows[0]["STOP_DATE"] = System.DBNull.Value;
            dt.Rows[0]["RESUME_DATE_B"] = DateTime.Parse(slpRESUME_DATE_E.Text).AddDays(1).ToShortDateString();//履歷迄日+1
            dt.Rows[0]["RESUME_DATE_E"] = slpCNT_END_DATE.Text;//合約迄日
            if (slpBELOW_SUBVEN.Text.Trim().Length == 0) dt.Rows[0]["BELOW_SUBVEN"] = System.DBNull.Value;
            else dt.Rows[0]["BELOW_SUBVEN"] = slpBELOW_SUBVEN.Text;
            if (slpBELOW_SUBVEN_PAY_TYPE.Text.Trim().Length == 0) dt.Rows[0]["BELOW_SUBVEN_PAY_TYPE"] = System.DBNull.Value;
            else dt.Rows[0]["BELOW_SUBVEN_PAY_TYPE"] = slpBELOW_SUBVEN_PAY_TYPE.Text;
            if (slpBELOW_SUBVEN_TYPE.Text.Trim().Length == 0) dt.Rows[0]["BELOW_SUBVEN_TYPE"] = System.DBNull.Value;
            else dt.Rows[0]["BELOW_SUBVEN_TYPE"] = slpBELOW_SUBVEN_TYPE.Text;
            if (slpBELOW_SUBVEN_RATE.Text.Trim().Length == 0) dt.Rows[0]["BELOW_SUBVEN_RATE"] = System.DBNull.Value;
            else dt.Rows[0]["BELOW_SUBVEN_RATE"] = slpBELOW_SUBVEN_RATE.Text;

            ds.Tables["Table_7"].Rows[0]["COUNT_TYPE"] = rdoCOUNT_TYPE1.Checked == true ? "1" : "2";
            ds.Tables["Table_7"].Rows[0]["PAY_TYPE"] = SLP_CodeFile4.Text;
            ds.Tables["Table_7"].Rows[0]["ANNUAL_RULE"] = SLP_CodeFile3.SelectedValue;

            foreach (DataRow dr in ds.Tables["Table_1"].Rows) //店群門市
                dr["EDIT_NO"] = dt.Rows[0]["EDIT_NO"];

            foreach (DataRow dr in ds.Tables["Table_2"].Rows) //單品
                dr["EDIT_NO"] = dt.Rows[0]["EDIT_NO"];

            foreach (DataRow dr in ds.Tables["Table_3"].Rows) //獎勵金
                dr["EDIT_NO"] = dt.Rows[0]["EDIT_NO"];

            ds.AcceptChanges();
            Session[SessionIDName] = ds;
            string strUrl = string.Format("location.replace('VDM101.aspx?Code=VDM10&arl_Key=" + Request.QueryString["arl_Key"] + "&SessionIDName=" + SessionIDName + "&ROWNUM=" + ViewState["ROWNUM"].ToString() + "&EXTEND=" + strExtend + "');", Session["UID"].ToString().Trim());
            ScriptManager.RegisterStartupScript(Page, GetType(), "AddResume", strUrl, true);
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("資料已被他人異動") >= 0)
                ScriptManager.RegisterStartupScript(this, this.GetType(), "DelComplete", "alert('履歷異動失敗,此資料已被其他使用者異動,請重新查詢!');", true);
            else
            {
                lblErrMsg1.Text = ex.Message;
                UpdatePanel2.Update();
            }
        }
    }
Beispiel #6
0
    //停止往來計算
    protected void STOP_COUNT()
    {
        try
        {
            ParameterList.Clear();
            ParameterList.Add(slpSTOP_DATE.Text);//V_TRACE_YM_S 0
            ParameterList.Add(txtVENDOR_CODE.Text);//V_VENDOR_CODE 1
            ParameterList.Add(txtCNT_NO.Text);//V_CNT_NO 2
            ParameterList.Add(ViewState["EDIT_NO"].ToString());//N_EDIT_NO 3
            ParameterList.Add(Session["UID"].ToString());//V_USER_ID 4

            //異動合約主檔資料的PK欄位
            string SessionIDName = "VDM022_" + PageTimeStamp.Value;
            DataSet ds = (DataSet)Session[SessionIDName];

            ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE 5
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID 6
            ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE 7
            ParameterList.Add(ds.Tables["Table_0"].Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID 8
            ParameterList.Add(System.DateTime.Now);//D_NEW_UPDATEDATE 9
            ParameterList.Add(Session["UID"].ToString());//V_NEW_UPDATEUID 10

            string V_MSG, V_STATUS_CREATEUID;
            DateTime D_STATUS_CREATEDATE;

            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            //((ScriptManager)Page.Controls[0].Controls[3].FindControl("ScriptManager1")).AsyncPostBackTimeout = 1800;
            bco.StopCloseMonth(ParameterList, null, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);

            if (V_MSG != "")
            {
                lblErrMsg1.Text = V_MSG + ",結帳人員:" + V_STATUS_CREATEUID + ",結帳時間:" + D_STATUS_CREATEDATE.ToString() + "。";
            }
            else
            {
                ds.AcceptChanges();
                Session[SessionIDName] = ds;
                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "btnSTOP_COUNT", "if (confirm('停止往來帳款試算成功,查詢 【供應商各項扣款表】?')){document.location.replace('../VAM/VAM134R.aspx');}else {document.location.replace('VDM021.aspx');}", true);"VDM022.aspx?arl_Key=VDM021_SortKey" + PageTimeStamp.Value + "&VDM021=EDIT&CNT_NO=" + e.Row.Cells[2].Text + "&EDIT_NO=" + e.Row.Cells[7].Text
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "btnSTOP_COUNT", "if (confirm('停止往來帳款試算成功,查詢 【供應商各項扣款表】?')){document.location.replace('../VAM/VAM131.aspx?Code=VAM13');} else {document.location.replace('VDM022.aspx?arl_Key=" + Request.QueryString["arl_Key"] + "&isToolBar=N&Code=VDM02&VDM021=EDIT&CNT_NO=" + txtCNT_NO.Text + "&EDIT_NO=" + txtEDIT_NO.Text + "');}", true);
            }
            UpdatePanel2.Update();
        }
        catch (Exception ex)
        {
            lblErrMsg1.Text = "帳款往來計算不成功 !! " + ex.Message;
            UpdatePanel2.Update();
        }
    }
Beispiel #7
0
    //停止往來計算(檢核)
    protected void STOP_COUNT_Check()
    {
        try
        {
            TextBox tb = (TextBox)slpSTOP_DATE.FindControl("TextBoxCode");
            if (slpSTOP_DATE.Text.Trim().Length == 0)
            {
                string sc = "alert('請輸入停止往來日');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) < DateTime.Parse(slpRESUME_DATE_B.Text) || DateTime.Parse(slpSTOP_DATE.Text) > DateTime.Parse(slpRESUME_DATE_E.Text))
            {
                string sc = "alert('停止往來日必須介於履歷起始日與履歷結束日中間');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }

            //找出最大的結帳年月
            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            string maxYM = bco.QueryMaxYM();
            if (maxYM == "")
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('無結帳年月,請重新輸入');", true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) <= DateTime.Parse(maxYM.Substring(0, 4) + "/" + maxYM.Substring(4, 2) + "/26"))
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('輸入的日期已結過帳,請重新輸入');", true);
                return;
            }
            if (DateTime.Parse(slpSTOP_DATE.Text) < DateTime.Today)
            {
                string sc = "if(confirm('您所輸入的停止往來日小於系統日期,是否仍確定更新?')){this.disabled=true;__doPostBack('STOP_COUNT','');} else {";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);}";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            STOP_COUNT();
            UpdatePanel2.Update();
        }
        catch (Exception ex)
        {
            lblErrMsg1.Text = "帳款往來計算不成功 !! " + ex.Message;
            UpdatePanel2.Update();
        }
    }
Beispiel #8
0
    //追溯計算(檢核)
    protected void RE_COUNT_Check()
    {
        try
        {
            if (slpTRACE_DATE_B.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (slpTRACE_DATE_B.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯年月(起)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (slpTRACE_DATE_E.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (slpTRACE_DATE_E.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯年月(迄)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            string trace1 = slpTRACE_DATE_B.Text.Substring(0, 4) + "/" + slpTRACE_DATE_B.Text.Substring(4, 2) + "/01";
            string trace2 = slpTRACE_DATE_E.Text.Substring(0, 4) + "/" + slpTRACE_DATE_E.Text.Substring(4, 2) + "/01";
            DateTime dt;
            if (!DateTime.TryParse(trace1, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (!DateTime.TryParse(trace2, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace1) > DateTime.Parse(trace2))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_B.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(起)不可大於追溯年月(迄)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace2).Year > DateTime.Today.Year)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(迄)不可大於系統年月,請重新設定');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (DateTime.Parse(trace2).Year == DateTime.Today.Year && DateTime.Parse(trace2).Month > DateTime.Today.Month)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)slpTRACE_DATE_E.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('追溯年月(迄)不可大於系統年月,請重新設定');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            if (txtYEAR_MONTH.Text.Trim().Length < 6)
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                if (txtYEAR_MONTH.Text.Trim().Length == 0)
                    sc = "alert('請輸入追溯掛帳年月');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }
            string trace3 = txtYEAR_MONTH.Text.Substring(0, 4) + "/" + txtYEAR_MONTH.Text.Substring(4, 2) + "/01";
            if (!DateTime.TryParse(trace3, out dt))
            {
                TextBox tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
                string sc = "alert('請輸入正確之日期格式(YYYY/MM)');";
                sc += @"window.setTimeout(function set_focus(){document.all['" + tb.ClientID + "'].focus();document.all['" + tb.ClientID + "'].select();}, 1800);";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", sc, true);
                return;
            }

            //找出最大的結帳年月
            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            string maxYM = bco.QueryMaxYM();
            if (!(string.Compare(txtYEAR_MONTH.Text, maxYM) > 0))
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", "alert('該合約已結帳至" + maxYM + "月,請重新輸入掛帳年月');", true);
                return;
            }

            TextBox Tb = (TextBox)((ASP.wui_slp_slp_numberupdown_ascx)txtYEAR_MONTH.FindControl("SLP_NumberUpDown1")).FindControl("TextBoxCode");
            string Sc = @"if(confirm('避免供應商追溯金額為負值,請再度確認掛帳年月,以免產生負值的各項扣款報表,是否確定進行追溯?')){this.disabled=true;__doPostBack('RE_COUNT','');} else {";
            Sc += @"window.setTimeout(function set_focus(){document.all['" + Tb.ClientID + "'].focus();document.all['" + Tb.ClientID + "'].select();}, 1800);}";
            //string Sc = @"if(confirm('避免供應商追溯金額為負值,請再度確認掛帳年月,以免產生負值的各項扣款報表,是否確定進行追溯?')){this.disabled=true;__doPostBack('RE_COUNT','');}";
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022.aspx", Sc, true);
            UpdatePanel2.Update();
        }
        catch (Exception ex)
        {
            lblErrMsg1.Text = "帳款追溯不成功 !! " + ex.Message;
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "btnSTOP_COUNT_fail", "alert('帳款追溯不成功 !! " + ex.Message + "');", true);
            UpdatePanel2.Update();
        }
    }
Beispiel #9
0
    protected void btnExtendDate_Click(object sender, EventArgs e)
    {
        BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
        string strLastMonth = bco.GetLastCheckMonth();
        slpRESUME_DATE_E.Text = strLastMonth.Substring(0, 4) + "/" + strLastMonth.Substring(4, 2) + "/25";
        UpdatePanel2.Update();

        if (DateTime.Parse(slpRESUME_DATE_B.Text) >= DateTime.Parse(slpRESUME_DATE_E.Text))
        {
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('履歷結束日須大於履歷起始日');", true);
            return;
        }
        //if (DateTime.Parse(slpCNT_END_DATE.Text) <= DateTime.Parse(slpRESUME_DATE_E.Text))
        //{
        //    ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('履歷結束日須小於合約結束日');", true);
        //    return;
        //}
        if (ViewState["STOP_DATE"].ToString() != "")
        {
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClientScript", "alert('該份合約已終止往來,無法新增履歷');", true);
            return;
        }
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "if (confirm('確定執行後舊合約的【履歷結束日】將無法還原,是否確定新增履歷')){this.disabled=true;__doPostBack('AddResume2','');}", true);


    }
Beispiel #10
0
    //刪除
    protected void btnDel_Click(object sender, EventArgs e)
    {
        if (slpCNT_CONFIRM_CODE.SelectedValue == "1")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022_alert", "alert('請先進行合約解除再刪除');", true);
            return;
        }
        try
        {
            DataSet ds = new DataSet();
            DateTime DTime = DateTime.Now;
            ds = (DataSet)Session["VDM022_" + PageTimeStamp.Value];

            ArrayList ArrList1 = new ArrayList();
            ArrList1.Add(ds.Tables["Table_0"].Rows[0]["VENDOR_CODE"].ToString());//V_OLD_VENDOR_CODE
            ArrList1.Add(ds.Tables["Table_0"].Rows[0]["CNT_NO"].ToString());//V_OLD_CNT_NO
            ArrList1.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString(), "int", false));//N_OLD_EDIT_NO
            ArrList1.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE
            ArrList1.Add(ds.Tables["Table_0"].Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID
            ArrList1.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE
            ArrList1.Add(ds.Tables["Table_0"].Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID
            ArrList1.Add(DTime);//D_NEW_UPDATEDATE
            ArrList1.Add(Session["UID"].ToString());//V_NEW_UPDATEUID

            BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
            bco.DeleteVDM022(ArrList1, null);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "DelComplete", "alert('刪除完成!');location.replace('VDM021.aspx?Code=VDM02');", true);
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("資料已被他人異動") >= 0)
                ScriptManager.RegisterStartupScript(this, this.GetType(), "DelComplete", "alert('刪除失敗,此資料已被其他使用者異動,請重新查詢!');", true);
            else
            {
                ErrorMsgLabel.Text = ex.Message;
                UpdatePanel6.Update();
            }
        }
    }
Beispiel #11
0
    private void Bind_CODE_FILE_Control()
    {
        BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
        DataTable dtResult = new DataTable();

        #region 油價補貼/離島配送費的收取方式選項資料載入
        ParameterList.Clear();
        ParameterList.Add("I3"); //CATEGORY
        ParameterList.Add("2"); //SCODE        
        dtResult = bco.Query_SYS_CODE_DETL(ParameterList);

        ParameterList.Clear();
        ParameterList.Add("I3"); //CATEGORY
        ParameterList.Add("4"); //SCODE                
        dtResult.Merge(bco.Query_SYS_CODE_DETL(ParameterList));

        ddlSUBSIDY2_PAY_TYPE.Items.Clear();
        ddlSUBSIDY1_PAY_TYPE.Items.Clear();
        for (int i = 0; i < dtResult.Rows.Count; i++)
        {
            ddlSUBSIDY2_PAY_TYPE.Items.Add(new ListItem(dtResult.Rows[i]["EXPLAIN"].ToString(), dtResult.Rows[i]["SCODE"].ToString().Trim()));
            ddlSUBSIDY1_PAY_TYPE.Items.Add(new ListItem(dtResult.Rows[i]["EXPLAIN"].ToString(), dtResult.Rows[i]["SCODE"].ToString().Trim()));
        }
        ddlSUBSIDY2_PAY_TYPE.SelectedValue = "4"; //"牌價"
        ddlSUBSIDY1_PAY_TYPE.SelectedValue = "4"; //"牌價"
        #endregion

        #region 油價補貼 補貼規則選項載入
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("2"); //SCODE                
        dtResult = bco.Query_SYS_CODE_DETL(ParameterList);
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("3"); //SCODE                
        dtResult.Merge(bco.Query_SYS_CODE_DETL(ParameterList));
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("6"); //SCODE                
        dtResult.Merge(bco.Query_SYS_CODE_DETL(ParameterList));
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("7"); //SCODE                
        dtResult.Merge(bco.Query_SYS_CODE_DETL(ParameterList));
        ddlSUBSIDY2_RULE.Items.Clear();
        for (int i = 0; i < dtResult.Rows.Count; i++)
        {
            ddlSUBSIDY2_RULE.Items.Add(new ListItem(dtResult.Rows[i]["EXPLAIN"].ToString(), dtResult.Rows[i]["SCODE"].ToString().Trim()));
        }
        ddlSUBSIDY2_RULE.SelectedValue = "6"; //店進-店退
        ViewState["Temp_SUBSIDY2_RULE_Selected_OLD"] = ddlSUBSIDY2_RULE.SelectedValue;
        #endregion

        #region 離島配送費 補貼規則選項載入
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("6"); //SCODE                
        dtResult = bco.Query_SYS_CODE_DETL(ParameterList);
        ParameterList.Clear();
        ParameterList.Add("I4"); //CATEGORY
        ParameterList.Add("7"); //SCODE                
        dtResult.Merge(bco.Query_SYS_CODE_DETL(ParameterList));
        ddlSUBSIDY1_RULE.Items.Clear();
        for (int i = 0; i < dtResult.Rows.Count; i++)
        {
            ddlSUBSIDY1_RULE.Items.Add(new ListItem(dtResult.Rows[i]["EXPLAIN"].ToString(), dtResult.Rows[i]["SCODE"].ToString().Trim()));
        }
        ddlSUBSIDY1_RULE.SelectedValue = "6"; //店進-店退
        #endregion

    }
Beispiel #12
0
    //確定新增 / 確定修改
    protected void btnAdd_Command(object sender, CommandEventArgs e)
    {
        string strScript;
        if (((DropDownList)SLP_CodeFile4.FindControl("D1")).SelectedItem.Text == "冊")
        {
            strScript = "alert('年度獎勵金〔收取方式=冊〕 暫不提供使用,請重新選擇');";
            strScript += "try { document.getElementById('" + ((DropDownList)SLP_CodeFile4.FindControl("D1")).ClientID + "').focus();}catch(e){}";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", strScript, true);
            return;
        }

      
        DataSet ds = new DataSet();
        ds = (DataSet)Session["VDM022_" + PageTimeStamp.Value];


        //牌價檢核 -- 獎勵金
        foreach (GridViewRow ddr in GridView_3.Rows)
        {
            if (((Label)ddr.FindControl("lblPAY_TYPE_Name")).Text == "牌價")
                foreach (DataRow dr in ds.Tables["Table_3"].Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        if (dr["PAY_TYPE"].ToString() == "4")
                        {
                            DataRow[] drs = ds.Tables["Table_4"].Select("PID='" + dr["ID"].ToString() + "'");
                            if (drs.Length == 0)
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('" + TargetType[Int16.Parse(dr["TARGET_TYPE"].ToString())] + "沒有設定店群,收取方式不能選擇牌價,請重新設定');", true);
                                return;
                            }
                        }
                    }
                }
        }

        //牌價檢核 -- 年度獎勵金
        if (((DropDownList)SLP_CodeFile4.FindControl("D1")).SelectedItem.Text == "牌價")
        {
            if (ds.Tables["Table_6"].Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('年度獎勵金沒有設定店群,收取方式不能選擇牌價,請重新設定');", true);
                return;
            }
        }

        if (rdoCOUNT_TYPE2.Checked)
        {
            if (GridView_6.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('年度獎勵金設定[計算方式]=部份店群,請設定店群、門市資料');", true);
                return;
            }
        }


        #region 油價補貼 資料檢核
        //收取方式的規則-成本
        if (ddlSUBSIDY2_PAY_TYPE.SelectedValue == "2")
        {
            //if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "2")
            //{
            //    ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為成本時,計算方式不能選擇部份店群,請重新設定');", true);
            //    return;
            //}

            if (!((ddlSUBSIDY2_RULE.SelectedValue == "2") || (ddlSUBSIDY2_RULE.SelectedValue == "3")))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為成本時,只允許選取[廠進-廠退]或[廠進]規則,請重新設定');", true);
                return;
            }

        }
        //收取方式的規則-牌價
        if (ddlSUBSIDY2_PAY_TYPE.SelectedValue == "4")
        {
            if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "1")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為牌價時,計算方式不能選擇全店群,請重新設定');", true);
                return;
            }

            if (!((ddlSUBSIDY2_RULE.SelectedValue == "6") || (ddlSUBSIDY2_RULE.SelectedValue == "7")))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為牌價時,只允許選取[店進-店退]或[店進]規則,請重新設定');", true);
                return;
            }
        
        }
        if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "2")
        {
            if (this.GridView_SUBSIDY2.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼計算方式選擇部分店群,但是尚未設定計算店群');", true);
                return;
            }
        }

        //檢查油價補貼設定,若計算方式非不計算,則費率%必須要輸入
        if (rblSUBSIDY2_COUNT_TYPE.SelectedValue != "0")
        {
            if (slpSUBSIDY2_RATE.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼若計算方式非不計算,則費率%必須要輸入');", true);
                return;
            }
        }

        #endregion

        //檢查離島配送設定,若計算方式非不計算,則費率%必須要輸入
        if (rblSUBSIDY1_COUNT_TYPE.SelectedValue != "0")
        {
            if (slpSUBSIDY1_RATE.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('離島配送若計算方式非不計算,則費率%必須要輸入');", true);
                return;
            }
        }

        //檢查離島配送費設定,收取方式只能設定為牌價
        if (ddlSUBSIDY1_PAY_TYPE.SelectedValue != "4")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('離島配送費的收取方式只能設定為牌價');", true);
            return;
        }

        string s_CheckPage = CheckPage(sender, ds);

        if (s_CheckPage != string.Empty)
        {
            this.ErrorMsgLabel.Text = s_CheckPage;
            ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "document.getElementById('" + VDM022_txtFocus.ClientID + "').focus();document.getElementById('" + VDM022_txtFocus.ClientID + "').select();", true);
            return;
        }
        try
        {
            DateTime DTime = DateTime.Now;
            if (e.CommandName == "確定新增")
            {
                //檢核合約期間是否重複
                ParameterList.Clear();
                ParameterList.Add(txtVENDOR_CODE.Text); //廠商統編
                ParameterList.Add(DateTime.Parse(slpCNT_END_DATE.Text).ToString("yyyy/MM/dd")); //合約結束日
                ParameterList.Add(DateTime.Parse(slpCNT_VALID_DATE.Text).ToString("yyyy/MM/dd")); //合約生效日
                BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
                int dupRec = bco.CheckContDup(ParameterList);
                if (dupRec != 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('合約期間重複,請重新設定');", true);
                    return;
                }

                ParameterList.Clear();
                ParameterList.Add(txtVENDOR_CODE.Text);  //0.
                ParameterList.Add(1);//1.N_EDIT_NO
                ParameterList.Add(GetValueSetParameter(this.slpCNT_VALID_DATE.Text.Trim(), "date", false)); //2.
                ParameterList.Add(0);//3.N_CNT_CONFIRM_CODE(1=已審核,0=未審核)
                ParameterList.Add(System.DBNull.Value);//4.D_CNT_CONFIRM_DATE
                ParameterList.Add(GetValueSetParameter(this.slpCNT_END_DATE.Text.Trim(), "date", false));//5.D_CNT_END_DATE
                ParameterList.Add(GetValueSetParameter(this.slpBELOW_SUBVEN.Text.Trim(), "float", false));//6.N_BELOW_SUBVEN
                ParameterList.Add(txtCOL_DAYS.Text);//7.N_COL_DAYS
                ParameterList.Add(GetValueSetParameter(this.ddlPAY_TYPE.Text.Trim(), "int", false));//8.N_PAY_TYPE結帳方式 1:月結,2:期別結
                ParameterList.Add(System.DBNull.Value);//9.D_STOP_DATE
                ParameterList.Add(System.DBNull.Value);//10.V_TRACE_DATE_B
                ParameterList.Add(System.DBNull.Value);//11.V_TRACE_DATE_E
                ParameterList.Add(slpCNT_VALID_DATE.Text);//12.D_RESUME_DATE_B=合約起日
                ParameterList.Add(slpCNT_END_DATE.Text);//13.D_RESUME_DATE_E=合約迄日
                ParameterList.Add(slpBELOW_SUBVEN_TYPE.Text); //14.
                ParameterList.Add(GetValueSetParameter(this.slpBELOW_SUBVEN_RATE.Text.Trim(), "float", false));//15.N_BELOW_SUBVEN_RATE
                ParameterList.Add(slpBELOW_SUBVEN_PAY_TYPE.Text); //16.
                ParameterList.Add((GetRowCount(ds.Tables["Table_2"]) == 0 ? 0 : 1));//17.N_BELOW_SUBVEN_ITEM_FLAG 單品FLAG(0:無設定單品1:有設定單品)
                ParameterList.Add((GetRowCount(ds.Tables["Table_1"]) == 0 ? 0 : 1));//18.N_BELOW_SUBVEN_STORE_FLAG 排除店群門市FLAG(0:無設定1:有設定)
                ParameterList.Add(System.DBNull.Value); //19.V_TRACING_CHECK_MONTH
                ParameterList.Add(Session["UID"].ToString());//20.V_CREATEUID
                ParameterList.Add(DTime);                    //21.D_CREATEDATE
                ParameterList.Add(Session["UID"].ToString());//22.V_UPDATEUID
                ParameterList.Add(DTime);                    //23.D_UPDATEDATE
                ParameterList.Add("");                       //24.V_CNT_NO 履歷使用(這邊沒用到)

                ParameterList.Add(rblSUBSIDY2_TYPE.SelectedValue);      //25.油價補貼 補貼類別
                ParameterList.Add(rblSUBSIDY2_COUNT_TYPE.SelectedValue);//26.油價補貼 計算方式
                ParameterList.Add(slpSUBSIDY2_RATE.Text.Trim());        //27.油價補貼 費率
                ParameterList.Add(ddlSUBSIDY2_PAY_TYPE.SelectedValue);  //28.油價補貼 收取方式
                ParameterList.Add(ddlSUBSIDY2_RULE.SelectedValue);      //29.油價補貼 規則

                ParameterList.Add(rblSUBSIDY1_COUNT_TYPE.SelectedValue);//30.離島配送費 計算方式
                ParameterList.Add(slpSUBSIDY1_RATE.Text.Trim());        //31.離島配送費 費率
                ParameterList.Add(ddlSUBSIDY1_PAY_TYPE.SelectedValue);  //32.離島配送費 收取方式
                ParameterList.Add(ddlSUBSIDY1_RULE.SelectedValue);      //33.離島配送費 規則

                ParameterList.Add(rblSUBSIDY4_COUNT_TYPE.SelectedValue);//34.轉運費 計算方式

                //新增年度獎勵金
                ArrayList ArrList = new ArrayList();
                ArrList.Add(1);//N_EDIT_NO
                ArrList.Add(1);//ANNUAL_TYPE 固定給1
                ArrList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", false));
                ArrList.Add(GetValueSetParameter((rdoCOUNT_TYPE1.Checked ? "1" : "2"), "int", false));//COUNT_TYPE計算方式,1.全店群2.部份店群
                ArrList.Add(GetValueSetParameter(SLP_CodeFile4.Text.Trim(), "int", false));//PAY_TYPE收取方式(1:冊,2:成本,3:零售價,4:牌價,5:本體價)
                ArrList.Add(GetValueSetParameter(SLP_CodeFile3.SelectedValue, "int", false));//ANNUAL_RULE規則(廠商進+廠商退、廠商進-廠商退、廠商進、廠商退  、店群進+店群退、店群進-店群退、店群進、店群退) 
                ArrList.Add(Session["UID"].ToString());//V_CREATEUID
                ArrList.Add(DTime);//D_CREATEDATE
                ArrList.Add(Session["UID"].ToString());//V_UPDATEUID
                ArrList.Add(DTime);//D_UPDATEDATE             

                string V_CNT_NO = "";

                //給店群門市的TARGET_NO值
                foreach (DataRow dr in ds.Tables["Table_3"].Rows)
                    foreach (DataRow Dr in ds.Tables["Table_4"].Rows)
                        if (Dr["PID"].ToString() == dr["ID"].ToString())
                            Dr["TARGET_NO"] = dr["TARGET_TYPE"];

                //BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
                bco.CreateVendorAgm(ParameterList, ArrList, ds, null, false, out V_CNT_NO);
                txtCNT_NO.Text = V_CNT_NO;

                ArrayList arl_Key = new ArrayList();
                arl_Key.Add(V_CNT_NO + "|" + "1");//新增的Edit_No = 1

                Session["VDM021_SortKey" + PageTimeStamp.Value] = arl_Key;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", "alert('新增完成');location.replace('VDM022.aspx?arl_Key=VDM021_SortKey" + PageTimeStamp.Value + "&isToolBar=N&Code=VDM02&VDM021=EDIT&CNT_NO=" + V_CNT_NO + "&EDIT_NO=1');", true);
            }
            else //確定修改
            {
                ParameterList.Clear();
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["VENDOR_CODE"].ToString());                                          //0.V_OLD_VENDOR_CODE
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["CNT_NO"].ToString());                                               //1.V_OLD_CNT_NO
                ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString(), "int", false));          //2.N_OLD_EDIT_NO
                ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));  //3.D_OLD_CREATEDATE
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["CREATEUID"].ToString());                                            //4.V_OLD_CREATEUID
                ParameterList.Add(GetValueSetParameter(ds.Tables["Table_0"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));  //5.D_OLD_UPDATEDATE
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["UPDATEUID"].ToString());                                            //6.V_OLD_UPDATEUID
                ParameterList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", false));                          //7.V_NEW_VENDOR_CODE
                ParameterList.Add(txtCNT_NO.Text);                                                                                  //8.V_NEW_CNT_NO
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString());                                              //9.N_NEW_EDIT_NO(因畫面上無此欄位可供變更)
                ParameterList.Add(GetValueSetParameter(this.slpCNT_VALID_DATE.Text.Trim(), "date", false));                         //10.D_NEW_CNT_VALID_DATE
                ParameterList.Add(slpCNT_CONFIRM_CODE.SelectedValue);                                                               //11.N_NEW_CNT_CONFIRM_CODE(1=已審核,0=未審核) -- 應該是不能修改的                
                ParameterList.Add(GetValueSetParameter(slpCNT_CONFIRM_DATE.Text.Trim(), "date", false));                            //12.D_NEW_CNT_CONFIRM_DATE
                ParameterList.Add(GetValueSetParameter(slpCNT_END_DATE.Text.Trim(), "date", false));                                //13.D_NEW_CNT_END_DATE
                ParameterList.Add(GetValueSetParameter(slpBELOW_SUBVEN.Text.Trim(), "float", false));                               //14.N_NEW_BELOW_SUBVEN
                ParameterList.Add(txtCOL_DAYS.Text);                                                                                //15.N_NEW_COL_DAYS
                ParameterList.Add(GetValueSetParameter(ddlPAY_TYPE.Text, "int", false));                                            //16.N_NEW_PAY_TYPE結帳方式 1:月結,2:期別結
                ParameterList.Add(System.DBNull.Value);                                                                             //17.D_NEW_STOP_DATE
                ParameterList.Add(System.DBNull.Value);                                                                             //18.V_NEW_TRACE_DATE_B
                ParameterList.Add(System.DBNull.Value);                                                                             //19.V_NEW_TRACE_DATE_E
                if (txtEDIT_NO.Text.Trim() == "1")
                {
                    ParameterList.Add(slpCNT_VALID_DATE.Text);  //20.D_NEW_RESUME_DATE_B=合約生效日(2009/7/23修改)
                    ParameterList.Add(slpCNT_END_DATE.Text);    //21.D_NEW_RESUME_DATE_E=合約終止日(2009/7/23修改)
                }
                else
                {
                    ParameterList.Add(slpRESUME_DATE_B.Text);   //20.D_NEW_RESUME_DATE_B=合約生效日
                    ParameterList.Add(slpRESUME_DATE_E.Text);   //21.D_NEW_RESUME_DATE_E=合約終止日
                }
                ParameterList.Add(GetValueSetParameter(slpBELOW_SUBVEN_TYPE.Text, "int", false));               //22.N_NEW_BELOW_SUBVEN_TYPE
                ParameterList.Add(GetValueSetParameter(this.slpBELOW_SUBVEN_RATE.Text.Trim(), "float", false)); //23.N_NEW_BELOW_SUBVEN_RATE
                ParameterList.Add(GetValueSetParameter(slpBELOW_SUBVEN_PAY_TYPE.Text, "int", false));           //24.N_NEW_BELOW_SUBVEN_PAY_TYPE
                ParameterList.Add((GetRowCount(ds.Tables["Table_2"]) == 0 ? 0 : 1));    //25.N_NEW_BELOW_SUBVEN_ITEM_FLAG 單品FLAG(0:無設定單品1:有設定單品)
                ParameterList.Add((GetRowCount(ds.Tables["Table_1"]) == 0 ? 0 : 1));    //26.N_NEW_BELOW_SUBVEN_STORE_FLAG 排除店群門市FLAG(0:無設定1:有設定)
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["TRACING_CHECK_MONTH"].ToString());  //27.V_NEW_TRACING_CHECK_MONTH
                ParameterList.Add(DTime);                    //28.D_NEW_UPDATEDATE
                ParameterList.Add(Session["UID"].ToString());//29.V_NEW_UPDATEUID

                ParameterList.Add(rblSUBSIDY2_TYPE.SelectedValue);      //30.油價補貼 補貼類別
                ParameterList.Add(rblSUBSIDY2_COUNT_TYPE.SelectedValue);//31.油價補貼 計算方式
                ParameterList.Add(slpSUBSIDY2_RATE.Text.Trim());        //32.油價補貼 費率
                ParameterList.Add(ddlSUBSIDY2_PAY_TYPE.SelectedValue);  //33.油價補貼 收取方式
                ParameterList.Add(ddlSUBSIDY2_RULE.SelectedValue);      //34.油價補貼 規則

                ParameterList.Add(rblSUBSIDY1_COUNT_TYPE.SelectedValue);//35.離島配送費 計算方式
                ParameterList.Add(slpSUBSIDY1_RATE.Text.Trim());        //36.離島配送費 費率
                ParameterList.Add(ddlSUBSIDY1_PAY_TYPE.SelectedValue);  //37.離島配送費 收取方式
                ParameterList.Add(ddlSUBSIDY1_RULE.SelectedValue);      //38.離島配送費 規則

                ParameterList.Add(rblSUBSIDY4_COUNT_TYPE.SelectedValue);//39.轉運費 計算方式

                //新增年度獎勵金
                ArrayList ArrList = new ArrayList();
                ArrList.Add(ds.Tables["Table_7"].Rows[0]["CNT_NO"].ToString());//V_OLD_CNT_NO
                ArrList.Add(GetValueSetParameter(ds.Tables["Table_7"].Rows[0]["EDIT_NO"].ToString(), "int", false));//N_OLD_EDIT_NO
                ArrList.Add(1);//N_OLD_ANNUAL_TYPE 固定給1
                ArrList.Add(ds.Tables["Table_7"].Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID
                ArrList.Add(GetValueSetParameter(ds.Tables["Table_7"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE
                ArrList.Add(ds.Tables["Table_7"].Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID
                ArrList.Add(GetValueSetParameter(ds.Tables["Table_7"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE

                ArrList.Add(txtCNT_NO.Text);//V_NEW_CNT_NO
                ArrList.Add(ds.Tables["Table_7"].Rows[0]["EDIT_NO"].ToString());//N_NEW_EDIT_NO(因畫面上無此欄位可供變更)
                ArrList.Add(1);//ANNUAL_TYPE 固定給1
                ArrList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", false));
                ArrList.Add(GetValueSetParameter((rdoCOUNT_TYPE1.Checked ? "1" : "2"), "int", false));//COUNT_TYPE計算方式,1.全店群2.部份店群
                ArrList.Add(GetValueSetParameter(SLP_CodeFile4.Text.Trim(), "int", false));//PAY_TYPE收取方式(1:冊,2:成本,3:零售價,4:牌價,5:本體價)
                ArrList.Add(GetValueSetParameter(SLP_CodeFile3.SelectedValue, "int", false));//ANNUAL_RULE規則(廠商進+廠商退、廠商進-廠商退、廠商進、廠商退  、店群進+店群退、店群進-店群退、店群進、店群退) 
                ArrList.Add(DTime);//D_UPDATEDATE
                ArrList.Add(Session["UID"].ToString());//V_UPDATEUID

                //int N_ID;
                //string V_CODE;
                //string V_CNT_NO = "";

                //給店群門市的TARGET_NO值
                foreach (DataRow dr in ds.Tables["Table_3"].Rows)
                    if (dr.RowState != DataRowState.Deleted)
                        foreach (DataRow Dr in ds.Tables["Table_4"].Rows)
                            if (Dr.RowState != DataRowState.Deleted)
                                if (Dr["PID"].ToString() == dr["ID"].ToString())
                                    Dr["TARGET_NO"] = dr["TARGET_TYPE"];

                BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
                bco.UpdateVDM_Contract(ParameterList, ArrList, ds, null);

                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('修改完成');", true);
                //資料要重新查詢,因為已異動過,若不重查,使用者於檢視頁按下編輯鈕後,再按修改審核、解除等按鈕時會產生資料已異動的錯誤
                Session.Remove("VDM022_" + PageTimeStamp.Value);
                BuildDataSet(); //建立DATATABLE架構
                ds.AcceptChanges();
                ds = QueryData(ViewState["CNT_NO"].ToString(), ViewState["EDIT_NO"].ToString(), false);

                //獎勵金的預設值
                btnCancel_1_Command(null, new CommandEventArgs("btnCancel_3", null));
                ReadOnlyMode();

                btnAdd_Mode.Visible = true;
                btnModify_Mode.Visible = true;
                btnCopy_Mode.Visible = true;
                btnDel.Visible = true;
                Session["VDM022_" + PageTimeStamp.Value] = ds;
                Cruise(txtCNT_NO.Text, ViewState["EDIT_NO"].ToString());//檢視模式的巡航鈕
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, true, "", btnDel, WUI_GMToolbarV.ClickAction.ButtonClick);
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", btnAdd, WUI_GMToolbarV.ClickAction.ButtonClick);


                UpdatePanel1.Update();
                UpdatePanel2.Update();
                UpdatePanel3.Update();
                UpdatePanel4.Update();
                UpdatePanel4_1.Update();
                UpdatePanel5.Update();
                UpdatePanel6.Update();
                UpdatePanel_SUBSIDY2.Update();
                UpdatePanel9.Update();
                UpdatePanel7.Update();
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("資料已被他人異動,資料更新失敗") != -1)
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", "alert('更新失敗,此資料已被其他使用者異動,請重新查詢再進行儲存');", true);
            else
            {
                ErrorMsgLabel.Text = ex.Message;
                UpdatePanel6.Update();
            }
        }
    }
Beispiel #13
0
    private DataSet QueryData(string CNT_NO, string EDIT_NO, bool isToolBar)
    {
        //處理若使用者刪除資料,於另一Tab頁按上、下筆時會查不到資料,此時將以下按鈕Disable
        btnAdd_Mode.Enabled = true;
        btnDel.Enabled = true;
        btnModify_Mode.Enabled = true;
        btnCopy_Mode.Enabled = true;
        btnStoreGroup.Enabled = true;
        btnSingleBook.Enabled = true;
        btnSetLvel.Enabled = true;
        ClearAllField();
        ParameterList.Clear();
        ParameterList.Add(CNT_NO);
        ParameterList.Add(Int16.Parse(EDIT_NO));

        DataSet ds = new DataSet();
        string SessionIDName = "VDM022_" + PageTimeStamp.Value;
        ds = (DataSet)Session[SessionIDName];
        DataTable dt = new DataTable();
        BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
        dt = bco.QueryAgmByEdit(ParameterList);
        dt.TableName = "Table_0"; //VDS_VDM_CONTRACT_MST
        ds.Tables.Add(dt.Copy());
        if (dt.Rows.Count > 0)
        {
            txtVENDOR_CODE.Text = dt.Rows[0]["VENDOR_CODE"].ToString();
            txtEDIT_NO.Text = dt.Rows[0]["EDIT_NO"].ToString();
            ddlPAY_TYPE.Text = dt.Rows[0]["PAY_TYPE"].ToString();
            txtCOL_DAYS.Text = dt.Rows[0]["COL_DAYS"].ToString();
            slpCNT_VALID_DATE.Text = dt.Rows[0]["CNT_VALID_DATE"].ToString();
            slpCNT_END_DATE.Text = dt.Rows[0]["CNT_END_DATE"].ToString();
            foreach (ListItem li in slpCNT_CONFIRM_CODE.Items)
                li.Selected = (li.Value == dt.Rows[0]["CNT_CONFIRM_CODE"].ToString() ? true : false);
            slpCNT_CONFIRM_DATE.Text = dt.Rows[0]["CNT_CONFIRM_DATE"].ToString();
            txtCNT_NO.Text = dt.Rows[0]["CNT_NO"].ToString();
            slpTRACE_DATE_B.Text = dt.Rows[0]["TRACE_DATE_B"].ToString();
            slpTRACE_DATE_E.Text = dt.Rows[0]["TRACE_DATE_E"].ToString();
            txtYEAR_MONTH.Text = dt.Rows[0]["TRACING_CHECK_MONTH"].ToString();
            slpSTOP_DATE.Text = dt.Rows[0]["STOP_DATE"].ToString();
            slpRESUME_DATE_B.Text = dt.Rows[0]["RESUME_DATE_B"].ToString();
            slpRESUME_DATE_E.Text = dt.Rows[0]["RESUME_DATE_E"].ToString();
            slpBELOW_SUBVEN.Text = dt.Rows[0]["BELOW_SUBVEN"].ToString();
            slpBELOW_SUBVEN_PAY_TYPE.Text = dt.Rows[0]["BELOW_SUBVEN_PAY_TYPE"].ToString();
            slpBELOW_SUBVEN_TYPE.Text = dt.Rows[0]["BELOW_SUBVEN_TYPE"].ToString();
            slpBELOW_SUBVEN_RATE.Text = dt.Rows[0]["BELOW_SUBVEN_RATE"].ToString();
            SLP_SLPDate1.Text = dt.Rows[0]["CREATEDATE"].ToString();//建立日期
            SLP_User1.Text = dt.Rows[0]["CREATEUID"].ToString();//建立人員
            SLP_SLPDate2.Text = dt.Rows[0]["UPDATEDATE"].ToString();//異動日期
            SLP_User2.Text = dt.Rows[0]["UPDATEUID"].ToString();//異動人員
            ViewState["EDIT_NO"] = dt.Rows[0]["EDIT_NO"].ToString();
            ViewState["STOP_DATE"] = dt.Rows[0]["STOP_DATE"].ToString(); //該份合約已終止往來,無法新增履歷

            dt = bco.QueryAnnualByEdit(ParameterList);
            dt.TableName = "Table_7"; //VDS_VDM_CONTRACT_ANNUAL
            ds.Tables.Add(dt.Copy());
            if (dt.Rows.Count > 0)
            {
                rdoCOUNT_TYPE1.Checked = dt.Rows[0]["COUNT_TYPE"].ToString() == "1" ? true : false;
                rdoCOUNT_TYPE2.Checked = dt.Rows[0]["COUNT_TYPE"].ToString() == "2" ? true : false;
                SLP_CodeFile4.Text = dt.Rows[0]["PAY_TYPE"].ToString();
                foreach (ListItem li in SLP_CodeFile3.Items)
                    li.Selected = (li.Value == dt.Rows[0]["ANNUAL_RULE"].ToString() ? true : false);
                //部分店群
                if (rdoCOUNT_TYPE1.Checked)
                {
                    btnSetCountStore.Enabled = false;
                }
                else
                {
                    if (((DropDownList)SLP_CodeFile4.FindControl("D1")).SelectedValue != "1")
                    {
                        btnSetCountStore.Enabled = true;
                    }
                    else
                    {
                        btnSetCountStore.Enabled = false;
                    }

                }
            }

            dt = bco.QueryTargetByEdit(ParameterList);
            if (dt.Rows.Count > 0)
            {
                if (ViewState["ROWNUM"] != null)//取得最大筆數值,以便以後可以新增Detail資料
                    ViewState["ROWNUM"] = Int32.Parse(ViewState["ROWNUM"].ToString()) + dt.Rows.Count;
                else
                    ViewState["ROWNUM"] = dt.Rows.Count;

                //DataRow[] drs = dt.Select("VENDOR_CODE like '%'", "ROW_ID desc");
                //ViewState["ROW_ID"] = drs[0]["ROW_ID"];
                ds = FillDataSet(ds, null, dt, "Table_3");
                Session["VDM022_" + PageTimeStamp.Value] = ds;
                GridView_3.DataSource = ds.Tables["Table_3"];
                g = 1;
                GridView_3.DataBind();
            }

            dt = bco.QueryStoreByEdit(ParameterList);
            if (dt.Rows.Count > 0)
            {
                ViewState["ROWNUM"] = dt.Rows.Count;

                DataRow[] drs = dt.Select("COUNT_TYPE='1'"); //COUNT_TYPE 設定類別:1.未達銷售補貼(排除)2.獎勵金(排除)3.年度獎勵金 4.油價補貼
                if (drs.Length > 0)
                    ds = FillDataSet(ds, drs, null, "Table_1");
                GridView_1.DataSource = ds.Tables["Table_1"];
                g = 1;
                GridView_1.DataBind();

                drs = dt.Select("COUNT_TYPE='2'");
                if (drs.Length > 0)
                    ds = FillDataSet(ds, drs, null, "Table_4");
                //GridView_4.DataSource = ds.Tables["Table_4"];
                GridView_4.DataSource = null;
                g = 1;
                GridView_4.DataBind();

                drs = dt.Select("COUNT_TYPE='3'");
                if (drs.Length > 0)
                    ds = FillDataSet(ds, drs, null, "Table_6");
                GridView_6.DataSource = ds.Tables["Table_6"];
                g = 1;
                GridView_6.DataBind();

                //油價補貼
                drs = dt.Select("COUNT_TYPE='4'");
                if (drs.Length > 0)
                    ds = FillDataSet(ds, drs, null, "Table_SUBSIDY2");
                GridView_SUBSIDY2.DataSource = ds.Tables["Table_SUBSIDY2"];
                g = 1;
                GridView_SUBSIDY2.DataBind();
            }

            dt = bco.QueryItemByEdit(ParameterList);
            if (dt.Rows.Count > 0)
            {
                if (ViewState["ROWNUM"] != null)
                    ViewState["ROWNUM"] = Int32.Parse(ViewState["ROWNUM"].ToString()) + dt.Rows.Count;
                else
                    ViewState["ROWNUM"] = dt.Rows.Count;

                ds = FillDataSet(ds, null, dt, "Table_2");
                GridView_2.DataSource = ds.Tables["Table_2"];
                g = 1;
                GridView_2.DataBind();
            }

            ParameterList.Clear();
            if (ds.Tables["Table_7"].Rows.Count > 0)
            {
                ParameterList.Add(ds.Tables["Table_7"].Rows[0]["ID"].ToString());
                dt = bco.QueryRangeByEdit(ParameterList);
                if (dt.Rows.Count > 0)
                {
                    if (ViewState["ROWNUM"] != null)
                        ViewState["ROWNUM"] = Int32.Parse(ViewState["ROWNUM"].ToString()) + dt.Rows.Count;
                    else
                        ViewState["ROWNUM"] = dt.Rows.Count;

                    ds = FillDataSet(ds, null, dt, "Table_5");
                    //    GridView_5.DataSource = ds.Tables["Table_5"];

                    DataView dv_Table_5 = ds.Tables["Table_5"].DefaultView;
                    dv_Table_5.Sort = "TARGET_AMT";
                    GridView_5.DataSource = dv_Table_5;

                    g = 1;
                    GridView_5.DataBind();
                }
            }

            //載入預設值
            //油價補貼
            rblSUBSIDY2_TYPE.SelectedValue = "2";
            rblSUBSIDY2_COUNT_TYPE.SelectedValue = "0";
            ddlSUBSIDY2_PAY_TYPE.SelectedValue = "4";
            ddlSUBSIDY2_RULE.SelectedValue = "6";
            ViewState["Temp_SUBSIDY2_RULE_Selected_OLD"] = ddlSUBSIDY2_RULE.SelectedValue;
            slpSUBSIDY2_RATE.Text = "";
            btnSUBSIDY2_StoreGroup.Enabled = false;

            //離島配送費
            rblSUBSIDY1_COUNT_TYPE.SelectedValue = "0";
            ddlSUBSIDY1_PAY_TYPE.SelectedValue = "4";
            ddlSUBSIDY1_RULE.SelectedValue = "6";
            slpSUBSIDY1_RATE.Text = "";

            //轉運費
            rblSUBSIDY4_COUNT_TYPE.SelectedValue = "0";

            #region 油價補貼
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(2);
            dt = bco.QuerySUBSIDYByEdit(ParameterList);
            ds = FillDataSet(ds, null, dt, "Table_SUBSIDY_DATA_2");
            if (dt.Rows.Count > 0)
            {
                rblSUBSIDY2_TYPE.SelectedValue = "2";
                rblSUBSIDY2_COUNT_TYPE.SelectedValue = dt.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY2_RATE.Text = dt.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY2_PAY_TYPE.SelectedValue = dt.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY2_RULE.SelectedValue = dt.Rows[0]["SUBSIDY_RULE"].ToString();
                ViewState["Temp_SUBSIDY2_RULE_Selected_OLD"] = ddlSUBSIDY2_RULE.SelectedValue;
            }

            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(3);
            dt = bco.QuerySUBSIDYByEdit(ParameterList);
            ds = FillDataSet(ds, null, dt, "Table_SUBSIDY_DATA_3");
            if (dt.Rows.Count > 0)
            {
                rblSUBSIDY2_TYPE.SelectedValue = "3";
                rblSUBSIDY2_COUNT_TYPE.SelectedValue = dt.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY2_RATE.Text = dt.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY2_PAY_TYPE.SelectedValue = dt.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY2_RULE.SelectedValue = dt.Rows[0]["SUBSIDY_RULE"].ToString();
                ViewState["Temp_SUBSIDY2_RULE_Selected_OLD"] = ddlSUBSIDY2_RULE.SelectedValue;
                //油價補貼的店群設定讀取在上方已先執行
            }


            if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "2")
            {
                btnSUBSIDY2_StoreGroup.Enabled = true;
            }
            else
            {
                btnSUBSIDY2_StoreGroup.Enabled = false;
            }
            #endregion

            #region 離島配送費
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(1);
            dt = bco.QuerySUBSIDYByEdit(ParameterList);
            ds = FillDataSet(ds, null, dt, "Table_SUBSIDY_DATA_1");
            if (dt.Rows.Count > 0)
            {
                rblSUBSIDY1_COUNT_TYPE.SelectedValue = dt.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY1_RATE.Text = dt.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY1_PAY_TYPE.SelectedValue = dt.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY1_RULE.SelectedValue = dt.Rows[0]["SUBSIDY_RULE"].ToString();
            }
            #endregion

            #region 轉運費
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(4);
            dt = bco.QuerySUBSIDYByEdit(ParameterList);
            ds = FillDataSet(ds, null, dt, "Table_SUBSIDY_DATA_4");
            if (dt.Rows.Count > 0)
            {
                rblSUBSIDY4_COUNT_TYPE.SelectedValue = dt.Rows[0]["COUNT_TYPE"].ToString();
            }
            #endregion

            ds.AcceptChanges();
            Session["VDM022_" + PageTimeStamp.Value] = ds;
            return ds;
        }
        else
        {
            if (isToolBar)
                //lblErrMsg.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022_alert", "alert('此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢');", true);
            else
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "VDM022_alert", "alert('無法取得資料');", true);
            //lblErrMsg.Text = "無法取得資料";
            ClearAllField();
            ReadOnlyMode();
            DisableForm(true);
            btnAdd_Mode.Enabled = false;
            btnDel.Enabled = false;
            btnModify_Mode.Enabled = false;
            btnCopy_Mode.Enabled = false;
            btnStoreGroup.Enabled = false;
            btnSingleBook.Enabled = false;
            btnSetLvel.Enabled = false;
            return null;
        }
    }
Beispiel #14
0
    //確定新增 / 確定修改
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        this.ErrorMsgLabel.Text = "";
        DataSet ds = new DataSet();
        ds = (DataSet)Session[Request.QueryString["SessionIDName"]];
        ds.AcceptChanges();

        if (slpCNT_END_DATE.Text.Trim().Length == 0)
        {
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", "alert('請輸入合約結束日');", true);
            return;
        }
        if (DateTime.Parse(slpRESUME_DATE_B.Text) >= DateTime.Parse(slpCNT_END_DATE.Text))
        {
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", "alert('合約結束日須大於履歷起始日');", true);
            return;
        }

        string strScript;
        if (((DropDownList)SLP_CodeFile4.FindControl("D1")).SelectedItem.Text == "冊")
        {
            strScript = "alert('年度獎勵金〔收取方式=冊〕 暫不提供使用,請重新選擇');";
            strScript += "try { document.getElementById('" + ((DropDownList)SLP_CodeFile4.FindControl("D1")).ClientID + "').focus();}catch(e){}";
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", strScript, true);
            return;
        }


        //牌價檢核 -- 獎勵金
        if (((DropDownList)slpPAY_TYPE.FindControl("D1")).SelectedItem.Text == "牌價")
        {
            foreach (DataRow dr in ds.Tables["Table_3"].Rows)
            {
                if (dr["PAY_TYPE"].ToString() == "4")
                {
                    DataRow[] drs = ds.Tables["Table_4"].Select("PID='" + dr["ID"].ToString());
                    if (drs.Length == 0)
                    {
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", "alert('" + TargetType[Int16.Parse(dr["TARGET_TYPE"].ToString())] + "沒有設定店群,收取方式不能選擇牌價,請重新設定');", true);
                        return;
                    }
                }
            }
        }

        //牌價檢核 -- 年度獎勵金
        if (((DropDownList)SLP_CodeFile4.FindControl("D1")).SelectedItem.Text == "牌價")
        {
            if (ds.Tables["Table_6"].Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", "alert('年度獎勵金沒有設定店群,收取方式不能選擇牌價,請重新設定');", true);
                return;
            }
        }

        if (rdoCOUNT_TYPE2.Checked)
        {
            if (GridView_6.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM022", "alert('年度獎勵金設定[計算方式]=部份店群,請設定店群、門市資料');", true);
                return;
            }
        }

        #region 油價補貼 資料檢核
        //收取方式的規則-成本
        if (ddlSUBSIDY2_PAY_TYPE.SelectedValue == "2")
        {
            //if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "2")
            //{
            //    ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為成本時,計算方式不能選擇部份店群,請重新設定');", true);
            //    return;
            //}

            if (!((ddlSUBSIDY2_RULE.SelectedValue == "2") || (ddlSUBSIDY2_RULE.SelectedValue == "3")))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為成本時,只允許選取[廠進-廠退]或[廠進]規則,請重新設定');", true);
                return;
            }
        }
        //收取方式的規則-牌價
        if (ddlSUBSIDY2_PAY_TYPE.SelectedValue == "4")
        {
            if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "1")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為牌價時,計算方式不能選擇全店群,請重新設定');", true);
                return;
            }

            if (!((ddlSUBSIDY2_RULE.SelectedValue == "6") || (ddlSUBSIDY2_RULE.SelectedValue == "7")))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼的收取方式為牌價時,只允許選取[店進-店退]或[店進]規則,請重新設定');", true);
                return;
            }


        }
        
        if (rblSUBSIDY2_COUNT_TYPE.SelectedValue == "2")
        {
            if (this.GridView_SUBSIDY2.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼計算方式選擇部分店群,但是尚未設定計算店群');", true);
                return;
            }
        }

        //檢查油價補貼設定,若計算方式非不計算,則費率%必須要輸入
        if (rblSUBSIDY2_COUNT_TYPE.SelectedValue != "0")
        {
            if (slpSUBSIDY2_RATE.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('油價補貼若計算方式非不計算,則費率%必須要輸入');", true);
                return;
            }
        }

        #endregion

        //檢查離島配送設定,若計算方式非不計算,則費率%必須要輸入
        if (rblSUBSIDY1_COUNT_TYPE.SelectedValue != "0")
        {
            if (slpSUBSIDY1_RATE.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "VDM022", "alert('離島配送若計算方式非不計算,則費率%必須要輸入');", true);
                return;
            }
        }

        string s_CheckPage = CheckPage(sender, ds);

        if (s_CheckPage != string.Empty)
        {
            this.ErrorMsgLabel.Text = s_CheckPage;
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "VDM101", "document.getElementById('" + VDM101_txtFocus.ClientID + "').focus();", true);
            return;
        }
        try
        {
            if (btnAdd.Text == "確定新增")
            {
                ParameterList.Clear();
                ParameterList.Add(txtVENDOR_CODE.Text); //0.
                ParameterList.Add(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString());//1.N_EDIT_NO
                ParameterList.Add(GetValueSetParameter(this.slpCNT_VALID_DATE.Text.Trim(), "date", false)); //2.
                ParameterList.Add(0);//3.N_CNT_CONFIRM_CODE(1=已審核,0=未審核)
                ParameterList.Add(System.DBNull.Value);//4.D_CNT_CONFIRM_DATE
                ParameterList.Add(GetValueSetParameter(this.slpCNT_END_DATE.Text.Trim(), "date", false));//5.D_CNT_END_DATE
                ParameterList.Add(GetValueSetParameter(this.slpBELOW_SUBVEN.Text.Trim(), "float", false));//65.N_BELOW_SUBVEN
                ParameterList.Add(txtCOL_DAYS.Text);//7.N_COL_DAYS
                ParameterList.Add(GetValueSetParameter(this.ddlPAY_TYPE.Text.Trim(), "int", false));//8.N_PAY_TYPE結帳方式 1:月結,2:期別結
                ParameterList.Add(System.DBNull.Value);  //9.D_STOP_DATE
                ParameterList.Add(System.DBNull.Value);  //10.V_TRACE_DATE_B
                ParameterList.Add(System.DBNull.Value);  //11.V_TRACE_DATE_E
                ParameterList.Add(slpRESUME_DATE_B.Text);//12.D_RESUME_DATE_B
                if (Request["EXTEND"].ToString() == "1")
                    ParameterList.Add(slpCNT_END_DATE.Text);//13.D_RESUME_DATE_E
                else
                    ParameterList.Add(slpRESUME_DATE_E.Text);//13.D_RESUME_DATE_E
                ParameterList.Add(slpBELOW_SUBVEN_TYPE.Text); //14.
                ParameterList.Add(GetValueSetParameter(this.slpBELOW_SUBVEN_RATE.Text.Trim(), "float", false));//15.N_BELOW_SUBVEN_RATE
                ParameterList.Add(slpBELOW_SUBVEN_PAY_TYPE.Text);//16.
                ParameterList.Add((ds.Tables["Table_2"].Rows.Count == 0 ? 0 : 1));//17.N_BELOW_SUBVEN_ITEM_FLAG 單品FLAG(0:無設定單品1:有設定單品)
                ParameterList.Add((ds.Tables["Table_1"].Rows.Count == 0 ? 0 : 1));//18.N_BELOW_SUBVEN_STORE_FLAG 排除店群門市FLAG(0:無設定1:有設定)
                ParameterList.Add(System.DBNull.Value);      //19.V_TRACING_CHECK_MONTH
                ParameterList.Add(Session["UID"].ToString());//20.V_CREATEUID
                ParameterList.Add(System.DateTime.Now);      //21.D_CREATEDATE
                ParameterList.Add(Session["UID"].ToString());//22.V_UPDATEUID
                ParameterList.Add(System.DateTime.Now);      //23.D_UPDATEDATE
                ParameterList.Add(txtCNT_NO.Text);           //24.V_CNT_NO

                ParameterList.Add(rblSUBSIDY2_TYPE.SelectedValue);      //25.油價補貼 補貼類別
                ParameterList.Add(rblSUBSIDY2_COUNT_TYPE.SelectedValue);//26.油價補貼 計算方式
                ParameterList.Add(slpSUBSIDY2_RATE.Text.Trim());        //27.油價補貼 費率
                ParameterList.Add(ddlSUBSIDY2_PAY_TYPE.SelectedValue);  //28.油價補貼 收取方式
                ParameterList.Add(ddlSUBSIDY2_RULE.SelectedValue);      //29.油價補貼 規則

                ParameterList.Add(rblSUBSIDY1_COUNT_TYPE.SelectedValue);//30.離島配送費 計算方式
                ParameterList.Add(slpSUBSIDY1_RATE.Text.Trim());        //31.離島配送費 費率
                ParameterList.Add(ddlSUBSIDY1_PAY_TYPE.SelectedValue);  //32.離島配送費 收取方式
                ParameterList.Add(ddlSUBSIDY1_RULE.SelectedValue);      //33.離島配送費 規則

                ParameterList.Add(rblSUBSIDY4_COUNT_TYPE.SelectedValue);//34.轉運費 計算方式

                //新增年度獎勵金
                ArrayList ArrList = new ArrayList();
                ArrList.Add(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString());//N_EDIT_NO 年度獎勵金的EDIT_NO以合約主檔的為主,就不再另外處理
                ArrList.Add(1);//ANNUAL_TYPE 固定給1
                ArrList.Add(GetValueSetParameter(this.txtVENDOR_CODE.Text.Trim(), "string", false));
                ArrList.Add(GetValueSetParameter((rdoCOUNT_TYPE1.Checked ? "1" : "2"), "int", false));//COUNT_TYPE計算方式,1.全店群2.部份店群
                ArrList.Add(GetValueSetParameter(SLP_CodeFile4.Text.Trim(), "int", false));//PAY_TYPE收取方式(1:冊,2:成本,3:零售價,4:牌價,5:本體價)
                ArrList.Add(GetValueSetParameter(SLP_CodeFile3.SelectedValue, "int", false));//ANNUAL_RULE規則(廠商進+廠商退、廠商進-廠商退、廠商進、廠商退  、店群進+店群退、店群進-店群退、店群進、店群退) 
                ArrList.Add(Session["UID"].ToString());//V_CREATEUID
                ArrList.Add(System.DateTime.Now);//D_CREATEDATE
                ArrList.Add(Session["UID"].ToString());//V_UPDATEUID
                ArrList.Add(System.DateTime.Now);//D_UPDATEDATE


                int N_ID;
                string V_CODE;
                string V_CNT_NO = "";

                //給店群門市的TARGET_NO值
                foreach (DataRow dr in ds.Tables["Table_3"].Rows)
                    foreach (DataRow Dr in ds.Tables["Table_4"].Rows)
                        if (Dr["PID"].ToString() == dr["ID"].ToString())
                            Dr["TARGET_NO"] = dr["TARGET_TYPE"];

                BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
                bco.CreateVendorAgm(ParameterList, ArrList, ds, null, true);

                ds.AcceptChanges();
                Session[Request.QueryString["SessionIDName"]] = ds;

                ArrayList arl_Key = new ArrayList();
                arl_Key = (ArrayList)Session[Request.QueryString["arl_Key"]];
                arl_Key.Add(txtCNT_NO.Text + "|" + txtEDIT_NO.Text);

                Session[Request.QueryString["arl_Key"]] = arl_Key;

                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增完成');location.replace('VDM022.aspx?Code=VDM02&arl_Key={0}&VDM021=EDIT&CNT_NO={1}&EDIT_NO={2}');", Request.QueryString["arl_Key"], txtCNT_NO.Text, txtEDIT_NO.Text), true);
                //Response.Redirect("VDM022.aspx?arl_Key=" + Request.QueryString["arl_Key"] + "&VDM021=EDIT&CNT_NO=" + txtCNT_NO.Text + "&EDIT_NO=" + txtEDIT_NO.Text);
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("資料已被他人異動") >= 0)
                ScriptManager.RegisterStartupScript(this, this.GetType(), "DelComplete", "alert('新增失敗,此資料已被其他使用者新增,請重新查詢!');", true);
            else
                lblErrMsg.Text = ex.Message;
        }
    }
Beispiel #15
0
    private void QueryData(string CNT_NO, string EDIT_NO, bool isToolBar)
    {
        DataTable dtTemp;

        ClearAllField();
        ParameterList.Clear();
        ParameterList.Add(CNT_NO);
        ParameterList.Add(Int16.Parse(EDIT_NO));

        string SessionIDName = "VDM081_" + PageTimeStamp.Value;

        BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
        DataTable dt1 = bco.QueryAgmByEdit(ParameterList);

        if (dt1.Rows.Count > 0)
        {
            Panel2.Visible = false;
            Panel3.Visible = false;
            Panel4.Visible = false;
            Panel5.Visible = false;
            Panel6.Visible = false;
            Panel7.Visible = false;
            Panel8.Visible = false;
            Panel9.Visible = false;
            Panel10.Visible = false;
            Panel11.Visible = false;
            Panel12.Visible = false;

            //1.
            Session["VDM081_DT1_" + PageTimeStamp.Value] = dt1;
            txtVENDOR_CODE.Text = dt1.Rows[0]["VENDOR_CODE"].ToString();
            txtEDIT_NO.Text = dt1.Rows[0]["EDIT_NO"].ToString();
            ddlPAY_TYPE.Text = dt1.Rows[0]["PAY_TYPE"].ToString();
            txtCOL_DAYS.Text = dt1.Rows[0]["COL_DAYS"].ToString();
            slpCNT_VALID_DATE.Text = dt1.Rows[0]["CNT_VALID_DATE"].ToString();
            slpCNT_END_DATE.Text = dt1.Rows[0]["CNT_END_DATE"].ToString();
            foreach (ListItem li in slpCNT_CONFIRM_CODE.Items)
                li.Selected = (li.Value == dt1.Rows[0]["CNT_CONFIRM_CODE"].ToString() ? true : false);
            slpCNT_CONFIRM_DATE.Text = dt1.Rows[0]["CNT_CONFIRM_DATE"].ToString();
            txtCNT_NO.Text = dt1.Rows[0]["CNT_NO"].ToString();

            //2. BELOW_SUBVEN  is not null  AND ! =  0 才顯示
            if ((dt1.Rows[0]["BELOW_SUBVEN"].ToString() != "0") && (dt1.Rows[0]["BELOW_SUBVEN"].ToString() != ""))
            {
                Panel2.Visible = true;
                slpBELOW_SUBVEN.Text = dt1.Rows[0]["BELOW_SUBVEN"].ToString();
                slpBELOW_SUBVEN_PAY_TYPE.Text = dt1.Rows[0]["BELOW_SUBVEN_PAY_TYPE"].ToString();
                slpBELOW_SUBVEN_TYPE.Text = dt1.Rows[0]["BELOW_SUBVEN_TYPE"].ToString();
                slpBELOW_SUBVEN_RATE.Text = dt1.Rows[0]["BELOW_SUBVEN_RATE"].ToString();
            }


            //3 & 7            
            DataTable dt2 = bco.QueryStoreByEdit(ParameterList);
            if (dt2.Rows.Count > 0)
            {
                Session["VDM081_DT2_" + PageTimeStamp.Value] = dt2;
                dtTemp = Fill_DataTable(dt2, "COUNT_TYPE='1'");
                GridView_1.DataSource = dtTemp; ////COUNT_TYPE 設定類別:1.未達銷售補貼(排除)2.獎勵金(排除)3.年度獎勵金                
                GridView_1.DataBind();
                if (dtTemp.Rows.Count > 0)
                    Panel3.Visible = true;

                dtTemp = Fill_DataTable(dt2, "COUNT_TYPE='3'");
                GridView_6.DataSource = dtTemp;
                GridView_6.DataBind();
                if (dtTemp.Rows.Count > 0)
                    Panel7.Visible = true;
            }


            //4
            DataTable dt3 = bco.QueryItemByEdit(ParameterList);
            if (dt3.Rows.Count > 0)
            {
                Session["VDM081_DT3_" + PageTimeStamp.Value] = dt3;
                GridView_2.DataSource = dt3;
                GridView_2.DataBind();

                if (dt3.Rows.Count > 0)
                    Panel4.Visible = true;
            }


            //5.1
            DataTable dt4 = bco.QueryTargetByEdit(ParameterList);
            if (dt4.Rows.Count > 0)
            {
                iGV3_NO = 0;
                Session["VDM081_DT4_" + PageTimeStamp.Value] = dt4;
                Repeater1.DataSource = dt4;
                Repeater1.DataBind();

                if (dt4.Rows.Count > 0)
                    Panel5.Visible = true;

            }

            //6 & 8
            DataTable dt5 = bco.QueryAnnualByEdit(ParameterList);
            if (dt5.Rows.Count > 0)
            {
                Session["VDM081_DT5_" + PageTimeStamp.Value] = dt5;
                rdoCOUNT_TYPE1.Checked = dt5.Rows[0]["COUNT_TYPE"].ToString() == "1" ? true : false;
                rdoCOUNT_TYPE2.Checked = dt5.Rows[0]["COUNT_TYPE"].ToString() == "2" ? true : false;
                SLP_CodeFile4.Text = dt5.Rows[0]["PAY_TYPE"].ToString();
                foreach (ListItem li in SLP_CodeFile3.Items)
                    li.Selected = (li.Value == dt5.Rows[0]["ANNUAL_RULE"].ToString() ? true : false);

                ParameterList.Clear();
                ParameterList.Add(dt5.Rows[0]["ID"].ToString());

                DataTable dt6 = bco.QueryRangeByEdit(ParameterList);
                if (dt6.Rows.Count > 0)
                {
                    Panel6.Visible = true;
                    Session["VDM081_DT6_" + PageTimeStamp.Value] = dt6;
                    DataView dv6 = dt6.DefaultView;
                    dv6.Sort = "TARGET_AMT";
                    GridView_5.DataSource = dv6;
                    GridView_5.DataBind();
                    if (dt6.Rows.Count > 0)
                        Panel8.Visible = true;
                }
            }

            #region 油價補貼
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(2);
            DataTable dt7 = bco.QuerySUBSIDYByEdit(ParameterList);
            if (dt7.Rows.Count > 0)
            {
                Panel9.Visible = true;
                Session["VDM081_DT7_" + PageTimeStamp.Value] = dt7;
                rblSUBSIDY2_TYPE.SelectedValue = "2";
                rblSUBSIDY2_COUNT_TYPE.SelectedValue = dt7.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY2_RATE.Text = dt7.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY2_PAY_TYPE.SelectedValue = dt7.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY2_RULE.SelectedValue = dt7.Rows[0]["SUBSIDY_RULE"].ToString();
            }

            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(3);
            dt7 = bco.QuerySUBSIDYByEdit(ParameterList);
            if (dt7.Rows.Count > 0)
            {
                Panel9.Visible = true;
                Session["VDM081_DT7_" + PageTimeStamp.Value] = dt7;
                rblSUBSIDY2_TYPE.SelectedValue = "3";
                rblSUBSIDY2_COUNT_TYPE.SelectedValue = dt7.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY2_RATE.Text = dt7.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY2_PAY_TYPE.SelectedValue = dt7.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY2_RULE.SelectedValue = dt7.Rows[0]["SUBSIDY_RULE"].ToString();
            }

            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            DataTable dt8 = bco.QueryStoreByEdit(ParameterList);
            if (dt8.Rows.Count > 0)
            {
                Session["VDM081_DT8_" + PageTimeStamp.Value] = dt8;
                dtTemp = Fill_DataTable(dt8, "COUNT_TYPE='4'");
                GridView_7.DataSource = dtTemp;
                GridView_7.DataBind();
                if (dtTemp.Rows.Count > 0)
                    Panel10.Visible = true;
            }
            #endregion

            #region 離島配送費
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(1);
            DataTable dt9 = bco.QuerySUBSIDYByEdit(ParameterList);
            if (dt9.Rows.Count > 0)
            {
                Panel11.Visible = true;
                Session["VDM081_DT9_" + PageTimeStamp.Value] = dt9;
                rblSUBSIDY1_COUNT_TYPE.SelectedValue = dt9.Rows[0]["COUNT_TYPE"].ToString();
                slpSUBSIDY1_RATE.Text = dt9.Rows[0]["SUBSIDY_RATE"].ToString();
                ddlSUBSIDY1_PAY_TYPE.SelectedValue = dt9.Rows[0]["PAY_TYPE"].ToString();
                ddlSUBSIDY1_RULE.SelectedValue = dt9.Rows[0]["SUBSIDY_RULE"].ToString();
            }
            #endregion

            #region 轉運費
            ParameterList.Clear();
            ParameterList.Add(CNT_NO);
            ParameterList.Add(Int16.Parse(EDIT_NO));
            ParameterList.Add(4);
            DataTable dt10 = bco.QuerySUBSIDYByEdit(ParameterList);
            if (dt10.Rows.Count > 0)
            {
                Panel12.Visible = true;
                Session["VDM081_DT10_" + PageTimeStamp.Value] = dt10;
                rblSUBSIDY4_COUNT_TYPE.SelectedValue = dt10.Rows[0]["COUNT_TYPE"].ToString();
            }
            #endregion

        }

        if (slpCNT_CONFIRM_CODE.Text == "1") //已審核
        {
            btnUpdate.Enabled = false;
            btnDelete.Enabled = true;
        }
        else
        {
            btnUpdate.Enabled = true;
            btnDelete.Enabled = false;
        }
    }
Beispiel #16
0
    //確認審核、合約解除
    protected void btnUpdate_Command(object sender, CommandEventArgs e)
    {
        try
        {
            DataSet ds1 = new DataSet();

            DataTable dt1 = (DataTable)Session["VDM081_DT1_" + PageTimeStamp.Value];

            if (e.CommandName == "btnUpdate")//審核確認
            {
                ParameterList.Clear();
                ParameterList.Add(txtVENDOR_CODE.Text);
                ParameterList.Add(dt1.Rows[0]["CNT_NO"].ToString());//V_OLD_CNT_NO
                ParameterList.Add(dt1.Rows[0]["EDIT_NO"].ToString());//N_EDIT_NO
                ParameterList.Add(GetValueSetParameter(dt1.Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE
                ParameterList.Add(dt1.Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID
                ParameterList.Add(GetValueSetParameter(dt1.Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE
                ParameterList.Add(dt1.Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID

                ParameterList.Add(1);//N_NEW_CNT_CONFIRM_CODE(1=已審核,0=未審核) -- 應該是不能修改的
                ParameterList.Add(System.DateTime.Now);//D_NEW_CNT_CONFIRM_DATE
                ParameterList.Add(System.DateTime.Now);//D_NEW_UPDATEDATE
                ParameterList.Add(Session["UID"].ToString());//V_NEW_UPDATEUID

                BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);
                bco.UpdateVDM_Contract_Confirm(ParameterList, null);

                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "CompleteMSG", string.Format("alert('審核確認完成');", Session["UID"].ToString().Trim()), true);

            }
            else if (e.CommandName == "btnDelete")//合約解除
            {
                ParameterList.Clear();
                ParameterList.Add(txtVENDOR_CODE.Text);
                ParameterList.Add(dt1.Rows[0]["CNT_NO"].ToString());//V_OLD_CNT_NO
                ParameterList.Add(dt1.Rows[0]["EDIT_NO"].ToString());//N_EDIT_NO
                ParameterList.Add(GetValueSetParameter(dt1.Rows[0]["CREATEDATE"].ToString(), "datetime", false));//D_OLD_CREATEDATE
                ParameterList.Add(dt1.Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID
                ParameterList.Add(GetValueSetParameter(dt1.Rows[0]["UPDATEDATE"].ToString(), "datetime", false));//D_OLD_UPDATEDATE
                ParameterList.Add(dt1.Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID

                ParameterList.Add(0);//N_NEW_CNT_CONFIRM_CODE(1=已審核,0=未審核) -- 應該是不能修改的
                ParameterList.Add(System.DBNull.Value);//D_NEW_CNT_CONFIRM_DATE
                ParameterList.Add(System.DateTime.Now);//D_NEW_UPDATEDATE
                ParameterList.Add(Session["UID"].ToString());//V_NEW_UPDATEUID

                BCO.MaintainVendorAgm bco = new BCO.MaintainVendorAgm(ConntionDB);

                if (bco.QueryisCheckOut(ParameterList) > 0)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientScript", "alert('此合約已經做過月結,無法解除');", true);
                    return;
                }

                bco.UpdateVDM_Contract_Confirm(ParameterList, null);

                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "CompleteMSG", string.Format("alert('合約解除完成');", Session["UID"].ToString().Trim()), true);
            }

        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("資料已被他人異動") >= 0)
            {
                if (e.CommandName == "btnUpdate")
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CompleteMSG", "alert('審核確認失敗,此資料已被其他使用者異動,請重新查詢!');", true);
                else
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CompleteMSG", "alert('合約解除失敗,此資料已被其他使用者異動,請重新查詢!');", true);
            }
            else
            {
                ErrorMsgLabel.Text = ex.Message;
            }
        }
    }