public string VendorBaseName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainVendorBase co_main = new MaintainVendorBase(ConnectionDBStr);

        if (Code != "")
        {
            ArrayList ParameterList = new ArrayList();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.VENDOR", Code, "=", "and");//TextBoxCode.Text

            DataTable dt = co_main.QueryVendorBaseByFind_1(ParameterList); //查詢寫在DBO
            if (dt.Rows.Count > 0)
            { Name = dt.Rows[0]["VENDOR_NAME"].ToString().Trim(); }
            else
            { Name = "查無資料"; }
        }

        return Name;
    }
Exemple #2
0
    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        int res = 0;
        int v_ID = 0;
        DateTime UpTime = DateTime.Now;
        DbTransaction DBT = null;
        try
        {
            #region 檢查[供應商][群分類][大分類][中分類][小分類]

            string s_ReturnMsg = string.Empty;
            s_ReturnMsg = Check_Condition();

            if (s_ReturnMsg != string.Empty)
            { Alert(s_ReturnMsg); return; }

            #endregion

            #region 畫面取值
            //string v_ID = 新增前不給號
            string v_ITEM = ((WUI.SLP.SLP_PreItem)FormView1.FindControl("txtITEM")).Text.Trim();
            string v_ITEM_NAME = ((TextBox)FormView1.FindControl("txtITEM_NAME")).Text.Trim();
            string v_VICE_ITEM_NAME = ((TextBox)FormView1.FindControl("txtVICE_ITEM_NAME")).Text.Trim();
            string v_MDC_START_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtMDC_START_DATE")).Text.Trim();
            string v_MDC_END_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtMDC_END_DATE")).Text.Trim();
            string v_MANUFACTURE = ((WUI.SLP.SLP_VendorBase)FormView1.FindControl("txtMANUFACTURE")).Text.Trim();
            string v_ROOT_NO = ((WUI.SLP.SLP_RootNo)FormView1.FindControl("ddlROOT_NO")).Text.Trim();
            string v_OUT_OF_PRINT = ((((CheckBox)FormView1.FindControl("txtOUT_OF_PRINT")).Checked) ? "1" : "0");
            string v_PMA = ((WUI.SLP.SLP_PMA)FormView1.FindControl("txtPMA")).Text.Trim();
            string v_CATEGORY = ((WUI.SLP.SLP_Category)FormView1.FindControl("txtCATEGORY")).Text.Trim();
            string v_SORT_OUT = ((WUI.SLP.SLP_SortOut)FormView1.FindControl("txtSORT_OUT")).Text.Trim();
            string v_STATEMENTS = ((TextBox)FormView1.FindControl("txtSTATEMENTS")).Text.Trim();
            string v_ATTRIBUTE = ((((CheckBox)FormView1.FindControl("txtATTRIBUTE")).Checked) ? "1" : "0");
            string v_FIRST_PERIOD = ((TextBox)FormView1.FindControl("txtFIRST_PERIOD")).Text.Trim();
            string v_NEW_SW = ((((CheckBox)FormView1.FindControl("chkNEW_SW")).Checked) ? "1" : "0");
            string v_PERIOD_STEP = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPERIOD_STEP")).Text.Trim();
            string v_INTERVAL = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtINTERVAL")).Text.Trim();
            string v_PUBLISH_TYPE = ((WUI.SLP.CodeFile)FormView1.FindControl("txtPUBLISH_TYPE")).Text.Trim();
            string v_UNIT = ((WUI.SLP.EnumBase)FormView1.FindControl("txtUNIT")).Text.Trim();
            string v_OPEN_SIZE = ((TextBox)FormView1.FindControl("txtOPEN_SIZE")).Text.Trim();
            string v_PAGE_NUM = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtPAGE_NUM")).Text.Trim();
            string v_WEIGHT = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtWEIGHT")).Text.Trim();
            string v_HEIGHT = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtHEIGHT")).Text.Trim();
            string v_LENGTH = ((WUI.SLP.SLPNumber)FormView1.FindControl("txtDEEP")).Text.Trim();
            string v_AUTHOR = ((TextBox)FormView1.FindControl("txtAUTHOR")).Text.Trim();
            string v_CIP = ((TextBox)FormView1.FindControl("txtCIP")).Text.Trim();
            string v_PUBLISH = ((TextBox)FormView1.FindControl("txtPUBLISH")).Text.Trim();
            string v_ITEM_PUBLISHER_NO = ((TextBox)FormView1.FindControl("txtITEM_PUBLISHER_NO")).Text.Trim();
            string v_ITEM_PUBLISHER_NAME = ((TextBox)FormView1.FindControl("txtITEM_PUBLISHER_NAME")).Text.Trim();
            string v_PUBLISHER_TYPE = ((TextBox)FormView1.FindControl("txtPUBLISHER_TYPE")).Text.Trim();
            string v_PUBLISH_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtPUBLISH_DATE")).Text.Trim();
            //string v_PRE_ITEM_CHECK = ((CheckBox)FormView1.FindControl("chkPRE_ITEM_CHECK")).Text.Trim();
            string v_PRE_ITEM_CHECK = "0"; // 未審核(新增時為未審核)
            //FormView2
            string v_DISTRIBUTE_MODE = ((RadioButtonList)FormView2.FindControl("txtDISTRIBUTE_MODE")).Text.Trim();
            string v_QUANTITY = ((WUI.SLP.SLPNumber)FormView2.FindControl("txtQUANTITY")).Text.Trim();
            string v_ACCEPT_TOTAL = ((WUI.SLP.SLPNumber)FormView2.FindControl("txtACCEPT_TOTAL")).Text.Trim();
            string v_RESEMBLE_GOODS = ((TextBox)FormView2.FindControl("txtRESEMBLE_GOODS")).Text.Trim();
            string v_GOODS_MATTER = ((TextBox)FormView2.FindControl("txtGOODS_MATTER")).Text.Trim();
            string v_COMMEND_CAUSE = ((TextBox)FormView2.FindControl("txtCOMMEND_CAUSE")).Text.Trim();
            string v_PATTERN_NO = string.Format("{0}{1}{2}{3}", v_ROOT_NO, v_PMA, v_CATEGORY, v_SORT_OUT);

            string v_SUBSIDY_TYPE = ((RadioButtonList)FormView7.FindControl("rabSUBSIDY_TYPE")).Text.Trim();
            string v_PRICE_DISCOUNT = ((WUI.SLP.SLPNumber)FormView7.FindControl("txtPRICE_DISCOUNT")).Text.Trim();
            string v_MEMO = ((TextBox)FormView7.FindControl("txtMEMO")).Text.Trim();
            string v_MainMEMO = ((TextBox)FormView1.FindControl("txtMEMO")).Text.Trim();
            #endregion 畫面取值

            System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]{6}$");
            bool b_reg1 = reg1.IsMatch(((ASP.itm_slp_slp_preitem_ascx)this.FormView1.FindControl("txtITEM")).Text.Trim());
            bool b_reg2 = reg1.IsMatch(((TextBox)this.FormView1.FindControl("txtFIRST_PERIOD")).Text.Trim());

            if (b_reg1 == false)
            {
                Alert("品號為六位數字");
                return;
            }

            if (b_reg2 == false)
            {
                Alert("首期期別為六位數字");
                return;
            }

            if (Convert.ToDateTime(v_MDC_START_DATE).CompareTo(Convert.ToDateTime(v_MDC_END_DATE)) > 0)
            {
                Alert("DC開始日不可大於DC結束日");
                return;
            }

            if (System.Text.Encoding.Default.GetBytes(v_MainMEMO).Length > 300)
            {
                Alert("新品主檔頁籤的備註欄位不允許超過300的字元");
                return;
            }
            #region 因為有測試到欄位[首期期別][期別累加期]在儲存時,未檢查必填欄位,所以在後端再做一次檢查

            if (v_FIRST_PERIOD == string.Empty)
            {
                Alert("新品主檔頁籤 請輸入首期期別");
                return;
            }

            if (v_PERIOD_STEP == string.Empty)
            {
                Alert("新品主檔頁籤 請輸入期別累加期");
                return;
            }

            #endregion



            #region 檢查 首期期別是否小於折扣設定的期別迄
            DataTable dtPriceS_OLD = (DataTable)Session["VDS_ITM_PRE_PRICEDISCOUNT_S_OLD_" + PageTimeStamp.Value];
            DataTable dtPriceS_NEW = (DataTable)Session["VDS_ITM_PRE_PRICEDISCOUNT_S_NEW_" + PageTimeStamp.Value];
            DataTable dtPriceSG_OLD = (DataTable)Session["VDS_ITM_PRE_PRICEDISCOUNT_SG_OLD_" + PageTimeStamp.Value];
            DataTable dtPriceSG_NEW = (DataTable)Session["VDS_ITM_PRE_PRICEDISCOUNT_SG_NEW_" + PageTimeStamp.Value];
            for (int i = 0; i < dtPriceS_NEW.Rows.Count; i++)
            {
                if (dtPriceS_NEW.Rows[i]["PERIOD_END"].ToString().Trim() != "")
                    if (string.Compare(v_FIRST_PERIOD, dtPriceS_NEW.Rows[i]["PERIOD_END"].ToString()) > 0)
                    {
                        Alert("折扣設定頁籤的[門市折扣]有[期別迄]欄位小於[首期期別]的資料");
                        return;
                    }
            }
            for (int i = 0; i < dtPriceSG_NEW.Rows.Count; i++)
            {
                if (dtPriceSG_NEW.Rows[i]["PERIOD_END"].ToString().Trim() != "")
                    if (string.Compare(v_FIRST_PERIOD, dtPriceSG_NEW.Rows[i]["PERIOD_END"].ToString()) > 0)
                    {
                        Alert("折扣設定頁籤的[店群折扣]有[期別迄]欄位小於[首期期別]的資料");
                        return;
                    }
            }
            #endregion

            if (v_PRICE_DISCOUNT != "")
            {
                if (int.Parse(v_PRICE_DISCOUNT) > 100)
                {
                    Alert("折扣設定頁籤的 大智通牌價計算不超過100");
                    return;
                }
            }

            ParameterList.Clear();
            ParameterList.Add(DBNull.Value); //N_ID 
            ParameterList.Add(v_ITEM);       //V_ITEM 
            ParameterList.Add(DBNull.Value); //V_PATTERN_NO               
            DataTable dtExists = bco.QueryPreItemByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0) { Alert("品號已經存在"); return; }

            #region 檢查供應商是否正確

            TextBox txt_Code = ((ASP.vdm_slp_slp_vendorbase_ascx)this.FormView1.FindControl("txtMANUFACTURE")).TextBox_Code;

            PIC.VDS2G.GFM.VDM.MaintainVendorBase BCO_VDM = new PIC.VDS2G.GFM.VDM.MaintainVendorBase(ConntionDB);

            ParameterList.Clear();
            PIC.VDS2G.GFM.VDM.SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.VENDOR", txt_Code.Text.Trim(), "=", "and");
            DataTable dt_Code = BCO_VDM.QueryVendorBaseByFind_1(ParameterList);

            if (dt_Code.Rows.Count != 1)
            {
                Alert("新品主檔頁籤 請輸入正確的供應商");
                return;
            }

            #endregion

            MaintainItemClassify bcoClass = new MaintainItemClassify(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", v_PATTERN_NO, "=", "and");
            dtExists = bcoClass.QueryItemClassifyByFind_1(ParameterList);
            if (dtExists.Rows.Count == 0) { Alert("PatternNo不存在"); return; }

            DataTable dtMAIN_OLD = (DataTable)Session["VDS_ITM_PRE_PERIOD_MAIN_" + PageTimeStamp.Value];
            DataTable dtMAIN_NEW = (DataTable)Session["VDS_ITM_PRE_PERIOD_MAIN_NEW_" + PageTimeStamp.Value];
            //Call Insert Period_main
            if (dtMAIN_NEW.Rows.Count == 0)
            {
                CHAN_InsertButton_Click(sender, e);
            }
            else
            {
                CHAN_EditCommitButton_Click(sender, e);
            }
            dtMAIN_NEW = (DataTable)Session["VDS_ITM_PRE_PERIOD_MAIN_NEW_" + PageTimeStamp.Value];

            if (dtMAIN_NEW.Rows.Count == 0 && dtMAIN_OLD.Rows.Count == 0)
            {
                Alert("請輸入新品期別明細資料"); return;
            }

            if (dtMAIN_NEW.Rows[0]["BARCODE"].ToString() == "")
            {
                Alert("商品條碼不得為空白"); return;
            }

            #region 檢查門市及店群折扣資料是否在編輯狀態

            if (gv_Price_S.EditIndex != -1) { Alert("請先更新或取消門市折扣資料"); return; }
            if (gv_Price_SG.EditIndex != -1) { Alert("請先更新或取消店群折扣資料"); return; }

            #endregion

            #region 條碼檢查是否重覆
            Button InsertButton = ((Button)FormViewButton.FindControl("InsertButton"));
            HiddenField hdfSaveFlag = ((HiddenField)FormViewButton.FindControl("hdfSaveFlag"));
            if (hdfSaveFlag.Value == "0")
            {
                if (CheckDup_BARCODE(dtMAIN_NEW.Rows[0]["BARCODE"].ToString(), v_ITEM) == true)
                {
                    Page currentPage = (Page)HttpContext.Current.Handler;
                    string strScriptName = "ConfirmSave";

                    string strScriptContent = "DupBarcodeSave('" + InsertButton.ClientID + "','" + hdfSaveFlag.ClientID + "');";
                    ScriptManager.RegisterClientScriptBlock(currentPage, currentPage.GetType(), strScriptName, strScriptContent, true);
                    return;
                }
            }
            #endregion

            //初始化DBT            
            bco.StartDBT(out DBT);

            if (SaveSubsidy(DBT, UpTime) == false)
                return;

            #region PREITEM
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_ITEM); //vCODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM); //vITEM
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM_NAME", v_ITEM_NAME); //vITEM_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vMDC_START_DATE", v_MDC_START_DATE); //vMDC_START_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vMDC_END_DATE", v_MDC_END_DATE); //vMDC_END_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPMA", v_PMA); //vPMA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCATEGORY", v_CATEGORY); //vCATEGORY
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vSORT_OUT", v_SORT_OUT); //vSORT_OUT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPATTERN_NO", v_PATTERN_NO); //vPATTERN_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vATTRIBUTE", v_ATTRIBUTE); //vATTRIBUTE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vFIRST_PERIOD", v_FIRST_PERIOD); //vFIRST_PERIOD
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPERIOD_STEP", v_PERIOD_STEP); //vPERIOD_STEP
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vINTERVAL", v_INTERVAL); //vINTERVAL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUBLISH_TYPE", v_PUBLISH_TYPE); //vPUBLISH_TYPE
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vUNIT", v_UNIT); //vUNIT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vSTATEMENTS", v_STATEMENTS); //vSTATEMENTS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vDISTRIBUTE_MODE", v_DISTRIBUTE_MODE); //vDISTRIBUTE_MODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vRESEMBLE_GOODS", v_RESEMBLE_GOODS); //vRESEMBLE_GOODS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vGOODS_MATTER", v_GOODS_MATTER); //vGOODS_MATTER
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOMMEND_CAUSE", v_COMMEND_CAUSE); //vCOMMEND_CAUSE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vAUTHOR", v_AUTHOR); //vAUTHOR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vNEW_SW", v_NEW_SW); //vNEW_SW
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vQUANTITY1", v_QUANTITY); //vQUANTITY1
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vACCEPT_TOTAL", v_ACCEPT_TOTAL); //vACCEPT_TOTAL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUBLISH", v_PUBLISH); //vPUBLISH
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMANUFACTURE", v_MANUFACTURE); //vMANUFACTURE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vROOT_NO", v_ROOT_NO); //vROOT_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUBLISHER_TYPE", v_PUBLISHER_TYPE); //vPUBLISHER_TYPE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vPUBLISH_DATE", v_PUBLISH_DATE); //vPUBLISH_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVICE_ITEM_NAME", v_VICE_ITEM_NAME); //vVICE_ITEM_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vOUT_OF_PRINT", v_OUT_OF_PRINT); //vOUT_OF_PRINT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vOPEN_SIZE", v_OPEN_SIZE); //vOPEN_SIZE
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPAGE_NUM", v_PAGE_NUM); //vPAGE_NUM
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCIP", v_CIP); //vCIP
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM_PUBLISHER_NO", v_ITEM_PUBLISHER_NO); //vITEM_PUBLISHER_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM_PUBLISHER_NAME", v_ITEM_PUBLISHER_NAME); //vITEM_PUBLISHER_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vLENGTH", v_LENGTH); //vLENGTH
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vWIDTH", v_WEIGHT); //vWIDTH
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vHIEGHT", v_HEIGHT); //vHIEGHT
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", UpTime); //vCREATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", v_MainMEMO); //v_MainMEMO

            v_ID = bco.CreatePreItem(ParameterList, DBT);
            #endregion

            #region PRE_MAIN

            //ADD
            if (dtMAIN_NEW.Rows.Count > 0 && dtMAIN_OLD.Rows.Count == 0)
            {
                DataRow drMAIN_NEW = dtMAIN_NEW.Rows[0];
                ParameterList.Clear();

                ParameterList.Clear();
                ParameterList.Add(v_ITEM + v_FIRST_PERIOD);          //0.vCODE
                ParameterList.Add(v_ITEM);                           //1.vITEM
                ParameterList.Add(v_FIRST_PERIOD);                   //2.vPERIOD
                ParameterList.Add("0");                              //3.vEDIT_NO
                ParameterList.Add(drMAIN_NEW["TAX_TYPE"]);           //4.vTAX_TYPE
                ParameterList.Add(drMAIN_NEW["VENDOR"]);             //5.vVENDOR
                ParameterList.Add(drMAIN_NEW["COST"]);               //6.vCOST
                ParameterList.Add(drMAIN_NEW["PRICE"]);              //7.vPRICE
                ParameterList.Add(drMAIN_NEW["BARCODE"]);            //8.vBARCODE
                ParameterList.Add(drMAIN_NEW["PUBLISH_TYPE"]);       //9.vPUBLISH_TYPE
                ParameterList.Add(drMAIN_NEW["RETURN_DATE"]);        //10.vRETURN_DATE
                ParameterList.Add(drMAIN_NEW["COVER_FILE"]);         //11.vCOVER_FILE
                ParameterList.Add(drMAIN_NEW["PERIOD_BARCODE"]);     //12.vPERIOD_BARCODE
                ParameterList.Add(drMAIN_NEW["DIS_BASE"]);           //13.vDIS_BASE
                ParameterList.Add(drMAIN_NEW["DIS_ACCEPT_DOLLAR"]);  //14.vDIS_ACCEPT_DOLLAR
                ParameterList.Add(drMAIN_NEW["DIS_RETURN_DOLLAR"]);  //15.vDIS_RETURN_DOLLAR
                ParameterList.Add(drMAIN_NEW["DIS_RULE"]);           //16.vDIS_RULE
                ParameterList.Add(drMAIN_NEW["DIS_ACCEPT_RATE"]);    //17.vDIS_ACCEPT_RATE
                ParameterList.Add(drMAIN_NEW["DIS_RETURN_RATE"]);    //18.vDIS_RETURN_RATE
                ParameterList.Add(drMAIN_NEW["ACCT_VALIDATE"]);      //19.vACCT_VALIDATE
                ParameterList.Add(drMAIN_NEW["PERIOD_START_DATE"]);  //20.vPERIOD_START_DATE
                ParameterList.Add(drMAIN_NEW["PERIOD_END_DATE"]);    //21.vPERIOD_END_DATE
                ParameterList.Add(drMAIN_NEW["RESEARCH_FREQUENCY"]); //22.vRESEARCH_FREQUENCY
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL"]);  //23.vRESEARCH_INTERVAL
                ParameterList.Add(drMAIN_NEW["MARKET_RESEARCH"]);    //24.vMARKET_RESEARCH
                ParameterList.Add(drMAIN_NEW["PRINT_CNTY"]);         //25.vPRINT_CNTY
                ParameterList.Add(drMAIN_NEW["LANGUAGE"]);           //26.vLANGUAGE
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL2"]); //27.vRESEARCH_INTERVAL2
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL3"]); //28.vRESEARCH_INTERVAL3
                ParameterList.Add(drMAIN_NEW["EDIT_REASON"]);        //29.vEDIT_REASON
                ParameterList.Add(drMAIN_NEW["DISCOUNT_RATE"]);      //30.vDISCOUNT_RATE
                ParameterList.Add(UpTime);                     //31.vCREATEDATE
                ParameterList.Add(Session["UID"].ToString());                   //32.vCREATEUID
                ParameterList.Add(UpTime);                     //33.vUPDATEDATE
                ParameterList.Add(Session["UID"].ToString());                   //34.vUPDATEUID

                bcoMain.CreatePrePeriodMain(ParameterList, DBT);
            }
            //MODIFY
            if (dtMAIN_NEW.Rows.Count > 0 && dtMAIN_OLD.Rows.Count > 0)
            {
                DataRow drMAIN_OLD = dtMAIN_OLD.Rows[0];
                DataRow drMAIN_NEW = dtMAIN_NEW.Rows[0];

                ParameterList.Clear();
                ParameterList.Add(drMAIN_OLD["ID"]);                 //0.OLD_ID              
                ParameterList.Add(v_ITEM + v_FIRST_PERIOD);          //1.NEW_CODE
                ParameterList.Add(v_ITEM);                           //2.NEW_ITEM
                ParameterList.Add(v_FIRST_PERIOD);                   //3.NEW_PERIOD
                ParameterList.Add("0");                              //4.NEW_EDIT_NO
                ParameterList.Add(drMAIN_NEW["TAX_TYPE"]);           //5.NEW_TAX_TYPE
                ParameterList.Add(drMAIN_NEW["VENDOR"]);             //6.NEW_VENDOR
                ParameterList.Add(drMAIN_NEW["COST"]);               //7.NEW_COST
                ParameterList.Add(drMAIN_NEW["PRICE"]);              //8.NEW_PRICE
                ParameterList.Add(drMAIN_NEW["BARCODE"]);            //9.NEW_BARCODE
                ParameterList.Add(drMAIN_NEW["PUBLISH_TYPE"]);       //10.NEW_PUBLISH_TYPE
                ParameterList.Add(drMAIN_NEW["RETURN_DATE"]);        //11.NEW_RETURN_DATE
                ParameterList.Add(drMAIN_NEW["COVER_FILE"]);         //12.NEW_COVER_FILE
                ParameterList.Add(drMAIN_NEW["PERIOD_BARCODE"]);     //13.NEW_PERIOD_BARCODE
                ParameterList.Add(drMAIN_NEW["DIS_BASE"]);           //14.NEW_DIS_BASE
                ParameterList.Add(drMAIN_NEW["DIS_ACCEPT_DOLLAR"]);  //15.NEW_DIS_ACCEPT_DOLLAR
                ParameterList.Add(drMAIN_NEW["DIS_RETURN_DOLLAR"]);  //16.NEW_DIS_RETURN_DOLLAR
                ParameterList.Add(drMAIN_NEW["DIS_RULE"]);           //17.NEW_DIS_RULE
                ParameterList.Add(drMAIN_NEW["DIS_ACCEPT_RATE"]);    //18.NEW_DIS_ACCEPT_RATE
                ParameterList.Add(drMAIN_NEW["DIS_RETURN_RATE"]);    //19.NEW_DIS_RETURN_RATE
                ParameterList.Add(drMAIN_NEW["ACCT_VALIDATE"]);      //20.NEW_ACCT_VALIDATE
                ParameterList.Add(drMAIN_NEW["PERIOD_START_DATE"]);  //21.NEW_PERIOD_START_DATE
                ParameterList.Add(drMAIN_NEW["PERIOD_END_DATE"]);    //22.NEW_PERIOD_END_DATE
                ParameterList.Add(drMAIN_NEW["RESEARCH_FREQUENCY"]); //23.NEW_RESEARCH_FREQUENCY
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL"]);  //24.NEW_RESEARCH_INTERVAL
                ParameterList.Add(drMAIN_NEW["MARKET_RESEARCH"]);    //25.NEW_MARKET_RESEARCH
                ParameterList.Add(drMAIN_NEW["PRINT_CNTY"]);         //26.NEW_PRINT_CNTY
                ParameterList.Add(drMAIN_NEW["LANGUAGE"]);           //27.NEW_LANGUAGE
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL2"]); //28.NEW_RESEARCH_INTERVAL2
                ParameterList.Add(drMAIN_NEW["RESEARCH_INTERVAL3"]); //29.NEW_RESEARCH_INTERVAL3
                ParameterList.Add(drMAIN_NEW["EDIT_REASON"]);        //30.NEW_EDIT_REASON
                ParameterList.Add(drMAIN_NEW["DISCOUNT_RATE"]);      //31.NEW_DISCOUNT_RATE
                ParameterList.Add(UpTime);                     //32.NEW_UPDATEDATE
                ParameterList.Add(Session["UID"].ToString());        //33.NEW_UPDATEUID

                bcoMain.UpdatePrePeriodMain(ParameterList, DBT);
            }
            #endregion

            #region PRE_CHAN
            DataTable dtCHAN_OLD = (DataTable)Session["VDS_ITM_PRE_PERIOD_CHAN_" + PageTimeStamp.Value];
            DataTable dtCHAN_NEW = (DataTable)Session["VDS_ITM_PRE_PERIOD_CHAN_NEW_" + PageTimeStamp.Value];
            //ADD
            foreach (DataRow drCHAN_NEW in dtCHAN_NEW.Rows)
            {
                if (dtCHAN_OLD.Select(string.Format("ID={0}", ((drCHAN_NEW["ID"].ToString() == "") ? "0" : drCHAN_NEW["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_ITEM + v_FIRST_PERIOD); //vCODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vEDIT_NO", "0"); //vEDIT_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM); //vITEM
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD", v_FIRST_PERIOD); //vPERIOD
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCHAN_NO", drCHAN_NEW["CHAN_NO"].ToString()); //vCHAN_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM_MAP", drCHAN_NEW["ITEM_MAP"].ToString()); //vITEM_MAP
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFFECTIVE_DATE", drCHAN_NEW["EFFECTIVE_DATE"].ToString()); //vEFFECTIVE_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCHAN_END_DATE", drCHAN_NEW["CHAN_END_DATE"].ToString()); //vCHAN_END_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vFREQUENCY_TYPE", drCHAN_NEW["FREQUENCY_TYPE"].ToString()); //vFREQUENCY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vTRUN_OUT", drCHAN_NEW["TRUN_OUT"].ToString()); //vTRUN_OUT
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vSTATE", drCHAN_NEW["STATE"].ToString()); //vSTATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vPLAN_RETURN_DATE", drCHAN_NEW["PLAN_RETURN_DATE"].ToString()); //vPLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vNEXT_PLAN_RETURN_DATE", drCHAN_NEW["NEXT_PLAN_RETURN_DATE"].ToString()); //vNEXT_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vNOTICE_RETURN_DATE", drCHAN_NEW["NOTICE_RETURN_DATE"].ToString()); //vNOTICE_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vBACKWARD_DATE", drCHAN_NEW["BACKWARD_DATE"].ToString()); //vBACKWARD_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCHAN_ISS_DATE", drCHAN_NEW["CHAN_ISS_DATE"].ToString()); //vCHAN_ISS_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCHAN_DIS_NO", drCHAN_NEW["CHAN_DIS_NO"].ToString()); //vCHAN_DIS_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vRETURN_TYPE", drCHAN_NEW["RETURN_TYPE"].ToString()); //vRETURN_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vRTN_DDL", drCHAN_NEW["RTN_DDL"].ToString()); //vRTN_DDL
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vDISPLAY_DAY", drCHAN_NEW["DISPLAY_DAY"].ToString()); //vDISPLAY_DAY
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", UpTime); //vCREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
                    bcoChan.CreatePrePeriodChan(ParameterList, DBT);
                }
            }
            //MODIFY
            foreach (DataRow drCHAN_NEW in dtCHAN_NEW.Rows)
            {
                DataRow[] drsOLD = dtCHAN_OLD.Select(string.Format("ID={0}", ((drCHAN_NEW["ID"].ToString() == "") ? "0" : drCHAN_NEW["ID"].ToString())));
                if (drsOLD.Length > 0)
                {
                    DataRow drOLD = drsOLD[0];
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drOLD["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CODE", drOLD["CODE"].ToString()); //OLD_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_EDIT_NO", drOLD["EDIT_NO"].ToString()); //OLD_EDIT_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_ITEM", drOLD["ITEM"].ToString()); //OLD_ITEM
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PERIOD", drOLD["PERIOD"].ToString()); //OLD_PERIOD
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CHAN_NO", drOLD["CHAN_NO"].ToString()); //OLD_CHAN_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_ITEM_MAP", drOLD["ITEM_MAP"].ToString()); //OLD_ITEM_MAP
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_EFFECTIVE_DATE", drOLD["EFFECTIVE_DATE"].ToString()); //OLD_EFFECTIVE_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CHAN_END_DATE", drOLD["CHAN_END_DATE"].ToString()); //OLD_CHAN_END_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_FREQUENCY_TYPE", drOLD["FREQUENCY_TYPE"].ToString()); //OLD_FREQUENCY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_TRUN_OUT", drOLD["TRUN_OUT"].ToString()); //OLD_TRUN_OUT
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_STATE", drOLD["STATE"].ToString()); //OLD_STATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_PLAN_RETURN_DATE", drOLD["PLAN_RETURN_DATE"].ToString()); //OLD_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_NEXT_PLAN_RETURN_DATE", drOLD["NEXT_PLAN_RETURN_DATE"].ToString()); //OLD_NEXT_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_NOTICE_RETURN_DATE", drOLD["NOTICE_RETURN_DATE"].ToString()); //OLD_NOTICE_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_BACKWARD_DATE", drOLD["BACKWARD_DATE"].ToString()); //OLD_BACKWARD_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CHAN_ISS_DATE", drOLD["CHAN_ISS_DATE"].ToString()); //OLD_CHAN_ISS_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CHAN_DIS_NO", drOLD["CHAN_DIS_NO"].ToString()); //OLD_CHAN_DIS_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_RETURN_TYPE", drOLD["RETURN_TYPE"].ToString()); //OLD_RETURN_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_RTN_DDL", drOLD["RTN_DDL"].ToString()); //OLD_RTN_DDL
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_DISPLAY_DAY", drOLD["DISPLAY_DAY"].ToString()); //OLD_DISPLAY_DAY
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", drOLD["CREATEDATE"].ToString()); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", drOLD["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", drOLD["UPDATEDATE"].ToString()); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", drOLD["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ENABLE", drOLD["ENABLE"].ToString()); //OLD_ENABLE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CODE", v_ITEM + v_FIRST_PERIOD); //NEW_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_EDIT_NO", "0"); //NEW_EDIT_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_ITEM", v_ITEM); //NEW_ITEM
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PERIOD", v_FIRST_PERIOD); //NEW_PERIOD
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CHAN_NO", drCHAN_NEW["CHAN_NO"].ToString()); //NEW_CHAN_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_ITEM_MAP", drCHAN_NEW["ITEM_MAP"].ToString()); //NEW_ITEM_MAP
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_EFFECTIVE_DATE", drCHAN_NEW["EFFECTIVE_DATE"].ToString()); //NEW_EFFECTIVE_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_CHAN_END_DATE", drCHAN_NEW["CHAN_END_DATE"].ToString()); //NEW_CHAN_END_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_FREQUENCY_TYPE", drCHAN_NEW["FREQUENCY_TYPE"].ToString()); //NEW_FREQUENCY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_TRUN_OUT", drCHAN_NEW["TRUN_OUT"].ToString()); //NEW_TRUN_OUT
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_STATE", drCHAN_NEW["STATE"].ToString()); //NEW_STATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_PLAN_RETURN_DATE", drCHAN_NEW["PLAN_RETURN_DATE"].ToString()); //NEW_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_NEXT_PLAN_RETURN_DATE", drCHAN_NEW["NEXT_PLAN_RETURN_DATE"].ToString()); //NEW_NEXT_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_NOTICE_RETURN_DATE", drCHAN_NEW["NOTICE_RETURN_DATE"].ToString()); //NEW_NOTICE_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_BACKWARD_DATE", drCHAN_NEW["BACKWARD_DATE"].ToString()); //NEW_BACKWARD_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_CHAN_ISS_DATE", drCHAN_NEW["CHAN_ISS_DATE"].ToString()); //NEW_CHAN_ISS_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CHAN_DIS_NO", drCHAN_NEW["CHAN_DIS_NO"].ToString()); //NEW_CHAN_DIS_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_RETURN_TYPE", drCHAN_NEW["RETURN_TYPE"].ToString()); //NEW_RETURN_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_RTN_DDL", drCHAN_NEW["RTN_DDL"].ToString()); //NEW_RTN_DDL
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_DISPLAY_DAY", drCHAN_NEW["DISPLAY_DAY"].ToString()); //NEW_DISPLAY_DAY
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", UpTime); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID

                    bcoChan.UpdatePrePeriodChan(ParameterList, DBT);
                }
            }
            //DELETE
            foreach (DataRow drOLD in dtCHAN_OLD.Rows)
            {
                if (dtCHAN_NEW.Select(string.Format("ID={0}", ((drOLD["ID"].ToString() == "") ? "0" : drOLD["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drOLD["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CODE", drOLD["CODE"].ToString()); //OLD_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_EDIT_NO", drOLD["EDIT_NO"].ToString()); //OLD_EDIT_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_ITEM", drOLD["ITEM"].ToString()); //OLD_ITEM
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PERIOD", drOLD["PERIOD"].ToString()); //OLD_PERIOD
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CHAN_NO", drOLD["CHAN_NO"].ToString()); //OLD_CHAN_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_ITEM_MAP", drOLD["ITEM_MAP"].ToString()); //OLD_ITEM_MAP
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_EFFECTIVE_DATE", drOLD["EFFECTIVE_DATE"].ToString()); //OLD_EFFECTIVE_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CHAN_END_DATE", drOLD["CHAN_END_DATE"].ToString()); //OLD_CHAN_END_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_FREQUENCY_TYPE", drOLD["FREQUENCY_TYPE"].ToString()); //OLD_FREQUENCY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_TRUN_OUT", drOLD["TRUN_OUT"].ToString()); //OLD_TRUN_OUT
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_STATE", drOLD["STATE"].ToString()); //OLD_STATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_PLAN_RETURN_DATE", drOLD["PLAN_RETURN_DATE"].ToString()); //OLD_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_NEXT_PLAN_RETURN_DATE", drOLD["NEXT_PLAN_RETURN_DATE"].ToString()); //OLD_NEXT_PLAN_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_NOTICE_RETURN_DATE", drOLD["NOTICE_RETURN_DATE"].ToString()); //OLD_NOTICE_RETURN_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_BACKWARD_DATE", drOLD["BACKWARD_DATE"].ToString()); //OLD_BACKWARD_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CHAN_ISS_DATE", drOLD["CHAN_ISS_DATE"].ToString()); //OLD_CHAN_ISS_DATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CHAN_DIS_NO", drOLD["CHAN_DIS_NO"].ToString()); //OLD_CHAN_DIS_NO
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_RETURN_TYPE", drOLD["RETURN_TYPE"].ToString()); //OLD_RETURN_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_RTN_DDL", drOLD["RTN_DDL"].ToString()); //OLD_RTN_DDL
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_DISPLAY_DAY", drOLD["DISPLAY_DAY"].ToString()); //OLD_DISPLAY_DAY
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", drOLD["CREATEDATE"].ToString()); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", drOLD["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", drOLD["UPDATEDATE"].ToString()); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", drOLD["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ENABLE", drOLD["ENABLE"].ToString()); //OLD_ENABLE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", UpTime); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    bcoChan.DeletePrePeriodChan(ParameterList, DBT);
                }
            }
            #endregion

            #region PRE_PRICE_STORE
            //ADD
            foreach (DataRow drPriceS_NEW in dtPriceS_NEW.Rows)
            {
                if (dtPriceS_OLD.Select(string.Format("ID={0}", ((drPriceS_NEW["ID"].ToString() == "") ? "0" : drPriceS_NEW["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_ITEM + drPriceS_NEW["STORE"].ToString() + v_FIRST_PERIOD + DateTime.Parse(drPriceS_NEW["EFF_START"].ToString()).ToString("yyyyMMdd"));
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vSTORE", drPriceS_NEW["STORE"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD", v_FIRST_PERIOD);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD_END", drPriceS_NEW["PERIOD_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", drPriceS_NEW["PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vVENDOR_SUBSIDY_PERCENT", drPriceS_NEW["VENDOR_SUBSIDY_PERCENT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vFIX_PRICE_DISCOUNT", drPriceS_NEW["FIX_PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vCOST_PERCENT", dtMAIN_NEW.Rows[0]["DISCOUNT_RATE"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_START", drPriceS_NEW["EFF_START"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_END", drPriceS_NEW["EFF_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", drPriceS_NEW["MEMO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", UpTime); //vCREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
                    bcoPrice.CreatePrePrice_S(ParameterList, DBT);
                }
            }
            //MODIFY
            foreach (DataRow drPriceS_NEW in dtPriceS_NEW.Rows)
            {
                DataRow[] drsOLD = dtPriceS_OLD.Select(string.Format("ID={0}", ((drPriceS_NEW["ID"].ToString() == "") ? "0" : drPriceS_NEW["ID"].ToString())));
                if (drsOLD.Length > 0)
                {
                    DataRow drOLD = drsOLD[0];
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vID", drPriceS_NEW["ID"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_ITEM + drPriceS_NEW["STORE"].ToString() + v_FIRST_PERIOD + DateTime.Parse(drPriceS_NEW["EFF_START"].ToString()).ToString("yyyyMMdd"));
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vSTORE", drPriceS_NEW["STORE"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD", v_FIRST_PERIOD);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD_END", drPriceS_NEW["PERIOD_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", drPriceS_NEW["PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vVENDOR_SUBSIDY_PERCENT", drPriceS_NEW["VENDOR_SUBSIDY_PERCENT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vFIX_PRICE_DISCOUNT", drPriceS_NEW["FIX_PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vCOST_PERCENT", dtMAIN_NEW.Rows[0]["DISCOUNT_RATE"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_START", drPriceS_NEW["EFF_START"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_END", drPriceS_NEW["EFF_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", drPriceS_NEW["MEMO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID

                    bcoPrice.UpdatePrePrice_S(ParameterList, DBT);
                }
            }
            //DELETE
            foreach (DataRow drOLD in dtPriceS_OLD.Rows)
            {
                if (dtPriceS_NEW.Select(string.Format("ID={0}", ((drOLD["ID"].ToString() == "") ? "0" : drOLD["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drOLD["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", UpTime); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    bcoPrice.DeletePrePrice_S(ParameterList, DBT);
                }
            }

            #endregion

            #region PRE_PRICE_STOREGROUP
            //ADD
            foreach (DataRow drPriceSG_NEW in dtPriceSG_NEW.Rows)
            {
                if (dtPriceSG_OLD.Select(string.Format("ID={0}", ((drPriceSG_NEW["ID"].ToString() == "") ? "0" : drPriceSG_NEW["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_ITEM + drPriceSG_NEW["GROUP_NO"].ToString() + v_FIRST_PERIOD + DateTime.Parse(drPriceSG_NEW["EFF_START"].ToString()).ToString("yyyyMMdd"));
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vGROUP_NO", drPriceSG_NEW["GROUP_NO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD", v_FIRST_PERIOD);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD_END", drPriceSG_NEW["PERIOD_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", drPriceSG_NEW["PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vFIX_PRICE_DISCOUNT", drPriceSG_NEW["FIX_PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_START", drPriceSG_NEW["EFF_START"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_END", drPriceSG_NEW["EFF_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", drPriceSG_NEW["MEMO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", UpTime); //vCREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
                    bcoPrice.CreatePrePrice_SG(ParameterList, DBT);
                }
            }
            //MODIFY
            foreach (DataRow drPriceSG_NEW in dtPriceSG_NEW.Rows)
            {
                DataRow[] drsOLD = dtPriceSG_OLD.Select(string.Format("ID={0}", ((drPriceSG_NEW["ID"].ToString() == "") ? "0" : drPriceSG_NEW["ID"].ToString())));
                if (drsOLD.Length > 0)
                {
                    DataRow drOLD = drsOLD[0];
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vID", v_ITEM + drPriceSG_NEW["GROUP_NO"].ToString() + v_FIRST_PERIOD + DateTime.Parse(drPriceSG_NEW["EFF_START"].ToString()).ToString("yyyyMMdd"));
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", drPriceSG_NEW["CODE"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vGROUP_NO", drPriceSG_NEW["GROUP_NO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD", v_FIRST_PERIOD);
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPERIOD_END", drPriceSG_NEW["PERIOD_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", drPriceSG_NEW["PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vFIX_PRICE_DISCOUNT", drPriceSG_NEW["FIX_PRICE_DISCOUNT"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_START", drPriceSG_NEW["EFF_START"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vEFF_END", drPriceSG_NEW["EFF_END"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", drPriceSG_NEW["MEMO"].ToString());
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID

                    bcoPrice.UpdatePrePrice_SG(ParameterList, DBT);
                }
            }
            //DELETE
            foreach (DataRow drOLD in dtPriceSG_OLD.Rows)
            {
                if (dtPriceSG_NEW.Select(string.Format("ID={0}", ((drOLD["ID"].ToString() == "") ? "0" : drOLD["ID"].ToString()))).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drOLD["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", UpTime); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    bcoPrice.DeletePrePrice_SG(ParameterList, DBT);
                }
            }

            #endregion

            #region PRE_PRICE_MEMO
            ParameterList.Clear();
            DataTable dtMemo_old = (DataTable)Session["VDS_ITM_PRE_MEMO_" + PageTimeStamp.Value];
            //ADD
            if (dtMemo_old.Rows.Count == 0)
            {
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM); //vITEM
                SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", v_PRICE_DISCOUNT); //vMDC_START_DATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vSUBSIDY_TYPE", v_SUBSIDY_TYPE); //vMDC_END_DATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", v_MEMO); //vPMA
                SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", UpTime); //vCREATEDATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID

                bcoPrice.CreatePrePrice_Memo(ParameterList, DBT);
            }
            //MODIFY
            if (dtMemo_old.Rows.Count > 0)
            {
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM", v_ITEM); //vITEM
                SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPRICE_DISCOUNT", v_PRICE_DISCOUNT); //vMDC_START_DATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vSUBSIDY_TYPE", v_SUBSIDY_TYPE); //vMDC_END_DATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMEMO", v_MEMO); //vPMA
                SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", UpTime); //vUPDATEDATE
                SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID

                bcoPrice.UpdatePrePrice_Memo(ParameterList, DBT);
            }

            #endregion

            //完成交易
            bco.CommitDBT(DBT);

            ArrayList arr = new ArrayList();
            if ((ArrayList)Session[Request.QueryString["arl_Key"]] != null)
                arr = (ArrayList)Session[Request.QueryString["arl_Key"]];
            arr.Add(v_ID.ToString());
            string arl_Key = "";
            if ((ArrayList)Session[Request.QueryString["arl_Key"]] != null)
            {
                arl_Key = Request.QueryString["arl_Key"];
                Session[Request.QueryString["arl_Key"]] = arr;
            }
            else //從查詢頁直接按新增過來時沒有arl_Key參數,所以在這裏重做一個arl_Key參數
            {
                arl_Key = "arl_Key" + PageTimeStamp.Value;
                Session[arl_Key] = arr;
            }
            Script("alert('新增完成');location.href='ITM182.aspx?Code=ITM18&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + arl_Key + "&ID=" + v_ID.ToString() + "'");
        }
        catch (Exception ex)
        {
            if (DBT != null)
                DBT.Rollback();
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vITEM_NO", ((WUI.SLP.SLP_PreItem)FormView1.FindControl("txtITEM")).Text.Trim());
            bco.DeletePreItem_1(ParameterList, null);
            lblInsertError.Text = ex.Message;
        }
        finally { }

    }//end InsertButton_Click
Exemple #3
0
 private string GetVendorName(string strVendorCode)
 {
     string strResult = string.Empty;
     ArrayList ParameterList = new ArrayList();
     SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.VENDOR", strVendorCode, "=", "and");
     MaintainVendorBase co_main = new MaintainVendorBase(ConntionDB);
     DataTable dt = co_main.QueryVendorBaseByFind_1(ParameterList);
     if (dt.Rows.Count > 0)
     { strResult = dt.Rows[0]["VENDOR_NAME"].ToString().Trim(); }
     else
     { strResult = "查無資料"; }
     return strResult;
 }
Exemple #4
0
    private bool CheckExist_Vendor(string strCode)
    {
        bool bResult = true;
        MaintainVendorBase bco = new MaintainVendorBase(ConntionDB);

        if (strCode != "")
        {
            ArrayList ParameterList = new ArrayList();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.VENDOR", strCode, "=", "and");//TextBoxCode.Text

            DataTable dt = bco.QueryVendorBaseByFind_1(ParameterList); //查詢寫在DBO
            if (dt.Rows.Count == 0)
                bResult = false;
        }

        return bResult;
    }
Exemple #5
0
    }//ButtonQuery_Click			

    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    /// <param name="vdb"></param>
    private void databind()
    {
        //抓取本頁初次登記的時間

        string SessionIDName = "VDM011_" + PageTimeStamp.Value;

        MaintainVendorBase BCO = new MaintainVendorBase(ConntionDB);

        DataTable Dt = BCO.QueryVendorBaseByFind_1(ParameterList);

        Session["VDM011_" + PageTimeStamp.Value] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        #region 將Key值存到Session中

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

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

        #endregion
    }//databind