Esempio n. 1
0
    /// <summary>
    /// 輸出為EXCEL
    /// </summary>
    public void WriteToXls()
    {
        try
        {
            LogHelper LOG = new LogHelper(ConntionDB);

            databind();
            DataTable Dt = (DataTable)GridView1.DataSource;
            if (Dt.Columns["ID"] != null) Dt.Columns.Remove("ID");
            if (Dt.Columns["ENABLE"] != null) Dt.Columns.Remove("ENABLE");
            if (Dt.Columns["ORGANIZATIONCODE"] != null) Dt.Columns.Remove("ORGANIZATIONCODE");
            if (Dt.Columns["CODE"] != null) Dt.Columns["CODE"].ColumnName = "代碼";
            if (Dt.Columns["NAME"] != null) Dt.Columns["NAME"].ColumnName = "名稱";
            if (Dt.Columns["CREATEDATE"] != null) Dt.Columns["CREATEDATE"].ColumnName = "建立日期";
            if (Dt.Columns["CREATEUID"] != null) Dt.Columns["CREATEUID"].ColumnName = "建立人員";
            if (Dt.Columns["UPDATEDATE"] != null) Dt.Columns["UPDATEDATE"].ColumnName = "異動日期";
            if (Dt.Columns["UPDATEUID"] != null) Dt.Columns["UPDATEUID"].ColumnName = "異動人員";
            if (Dt.Columns["PASSWORD"] != null) Dt.Columns["PASSWORD"].ColumnName = "密碼";
            if (Dt.Columns["MEMO"] != null) Dt.Columns["MEMO"].ColumnName = "備註";

            foreach (DataRow dr in Dt.Rows)
            {
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("O");//2
                ParameterList.Add(dr["代碼"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                for (int i = 0; i < Dt.Columns.Count; i++)
                {
                    if (Dt.Columns[i].DataType == Type.GetType("System.String"))
                    {
                        dr[i] = string.Format("&nbsp;{0}", dr[i].ToString());
                    }
                }
            }
            Export(System.Text.Encoding.UTF8, PageProgramCode + ".xls", "application/ms-excel", Dt);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Esempio n. 2
0
    }//end EditCancelButton_Click

    /// <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;
        try
        {
            #region 畫面取值


            string v_ID = ViewState["NEWID"].ToString();
            string v_VENDOR = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).Text.Trim();
            string v_VENDOR_NAME = ((TextBox)FormView1.FindControl("txtVENDOR_NAME")).Text.Trim();
            string v_BOSS = ((TextBox)FormView1.FindControl("txtBOSS")).Text.Trim();
            string v_VENDOR_OPEN_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtVENDOR_OPEN_DATE")).Text.Trim();
            string v_VENDOR_CLOSE_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtVENDOR_CLOSE_DATE")).Text.Trim();
            string v_VENDOR_SERVICE_TEL_AREA = ((TextBox)FormView1.FindControl("txtVENDOR_SERVICE_TEL_AREA")).Text.Trim();
            string v_VENDOR_SERVICE_TEL = ((TextBox)FormView1.FindControl("txtVENDOR_SERVICE_TEL")).Text.Trim();
            string v_MAIL_ADDR = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtMAIL_ADDR")).Text.Trim();
            string v_HEAD_OFFICE_BANK = ((TextBox)FormView1.FindControl("txtHEAD_OFFICE_BANK")).Text.Trim();
            string v_HEAD_BANK_NO = ((TextBox)FormView1.FindControl("txtHEAD_BANK_NO")).Text.Trim();
            string v_BANK_ACCOUNT_NO = ((TextBox)FormView1.FindControl("txtBANK_ACCOUNT_NO")).Text.Trim();
            string v_BRANCH_OF_BANK = ((TextBox)FormView1.FindControl("txtBRANCH_OF_BANK")).Text.Trim();
            string v_BRANCH_BANK_NO = ((TextBox)FormView1.FindControl("txtBRANCH_BANK_NO")).Text.Trim();
            string v_INV_PDZ_NO = ((TextBox)FormView1.FindControl("txtINV_PDZ_NO")).Text.Trim();
            string v_INV_ADDR = ((TextBox)FormView1.FindControl("txtINV_ADDR")).Text.Trim();
            string v_INV_TEL_AREA = ((TextBox)FormView1.FindControl("txtINV_TEL_AREA")).Text.Trim();
            string v_INV_TEL = ((TextBox)FormView1.FindControl("txtINV_TEL")).Text.Trim();
            string v_INV_FAX_AREA = ((TextBox)FormView1.FindControl("txtINV_FAX_AREA")).Text.Trim();
            string v_INV_FAX = ((TextBox)FormView1.FindControl("txtINV_FAX")).Text.Trim();
            string v_BUSINESS_PDZ_NO = ((TextBox)FormView1.FindControl("txtBUSINESS_PDZ_NO")).Text.Trim();
            string v_BUSINESS_ADDR = ((TextBox)FormView1.FindControl("txtBUSINESS_ADDR")).Text.Trim();
            string v_BUSINESS_TEL_AREA = ((TextBox)FormView1.FindControl("txtBUSINESS_TEL_AREA")).Text.Trim();
            string v_BUSINESS_TEL = ((TextBox)FormView1.FindControl("txtBUSINESS_TEL")).Text.Trim();
            string v_BUSINESS_FAX_AREA = ((TextBox)FormView1.FindControl("txtBUSINESS_FAX_AREA")).Text.Trim();
            string v_BUSINESS_FAX = ((TextBox)FormView1.FindControl("txtBUSINESS_FAX")).Text.Trim();
            string v_BUSINESS_CONTACT1 = ((TextBox)FormView1.FindControl("txtBUSINESS_CONTACT1")).Text.Trim();
            string v_BUSINESS_EXTENSION1 = ((TextBox)FormView1.FindControl("txtBUSINESS_EXTENSION1")).Text.Trim();
            string v_CELL_PHONE1 = ((TextBox)FormView1.FindControl("txtCELL_PHONE1")).Text.Trim();
            string v_BUSINESS_MAIL1 = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtBUSINESS_MAIL1")).Text.Trim();
            //string v_BUSINESS_CONTACT2 = ((TextBox)FormView1.FindControl("txtBUSINESS_CONTACT2")).Text.Trim();
            string v_BUSINESS_EXTENSION2 = ((TextBox)FormView1.FindControl("txtBUSINESS_EXTENSION2")).Text.Trim();
            string v_CELL_PHONE2 = ((TextBox)FormView1.FindControl("txtCELL_PHONE2")).Text.Trim();
            string v_BUSINESS_MAIL2 = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtBUSINESS_MAIL2")).Text.Trim();
            string v_ACCOUNT_CONTACT = ((TextBox)FormView1.FindControl("txtACCOUNT_CONTACT")).Text.Trim();
            string v_ACCOUNT_EXTENSION = ((TextBox)FormView1.FindControl("txtACCOUNT_EXTENSION")).Text.Trim();
            string v_ACCOUNT_MAIL = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtACCOUNT_MAIL")).Text.Trim();
            string v_PUB_CBRE = ((TextBox)FormView1.FindControl("txtPUB_CBRE")).Text.Trim();
            string v_PUB_ENAME = ((TextBox)FormView1.FindControl("txtPUB_ENAME")).Text.Trim();
            string v_PUB_NUM = ((TextBox)FormView1.FindControl("txtPUB_NUM")).Text.Trim();
            string v_NOTES = ((TextBox)FormView1.FindControl("txtNOTES")).Text.Trim();
            string v_RETURN_CONTACT = ((TextBox)FormView1.FindControl("txtRETURN_CONTACT")).Text.Trim();
            string v_VENDOR_CODE = ((TextBox)FormView1.FindControl("txtVENDOR_CODE")).Text.Trim();
            string v_COL_DAYS = ((WUI.SLP.CodeFile)FormView1.FindControl("txtCOL_DAYS")).Text.Trim();
            string v_PAY_TYPE = ((WUI.SLP.EnumBase)FormView1.FindControl("txtPAY_TYPE")).Text.Trim();
            string v_COM_PDZ_NO = ((TextBox)FormView1.FindControl("txtCOM_PDZ_NO")).Text.Trim();
            string v_COM_ADDR = ((TextBox)FormView1.FindControl("txtCOM_ADDR")).Text.Trim();
            string v_COM_TEL_AREA = ((TextBox)FormView1.FindControl("txtCOM_TEL_AREA")).Text.Trim();
            string v_COM_TEL = ((TextBox)FormView1.FindControl("txtCOM_TEL")).Text.Trim();
            string v_COM_FAX_AREA = ((TextBox)FormView1.FindControl("txtCOM_FAX_AREA")).Text.Trim();
            string v_COM_FAX = ((TextBox)FormView1.FindControl("txtCOM_FAX")).Text.Trim();

            #endregion 畫面取值

            #region 資料檢查

            //檢核各欄位長度
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            
            if (this.Get_Byte_Length(v_VENDOR_NAME) > 50)
            {
                sb.Append("供應商名稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_BOSS) > 10)
            {
                sb.Append("負責人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_MAIL_ADDR) > 50)
            {
                sb.Append("客服EMAIL欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_HEAD_OFFICE_BANK) > 20)
            {
                sb.Append("銀行總行名稱電匯資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_INV_TEL) > 10)
            {
                sb.Append("電話發票資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_INV_FAX) > 10)
            {
                sb.Append("傳真發票資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_BUSINESS_CONTACT1) > 10)
            {
                sb.Append("業務連絡人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_ACCOUNT_CONTACT) > 10)
            {
                sb.Append("財務連絡人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_PUB_CBRE) > 8)
            {
                sb.Append("供應商簡稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_PUB_ENAME) > 50)
            {
                sb.Append("英文名稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_NOTES) > 50)
            {
                sb.Append("說明備註欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_RETURN_CONTACT) > 10)
            {
                sb.Append("廠退聯絡人資料長度過長\\n");
            }

            if (sb.ToString().Length > 0)
            {
                Alert(sb.ToString());
                return;
            }



            if (Convert.ToDateTime(v_VENDOR_OPEN_DATE).CompareTo(Convert.ToDateTime(v_VENDOR_CLOSE_DATE)) > 0) { Alert("往來開始日不可大於往來結束日"); return; }
            //檢核長度
            if (GetStringLen(v_VENDOR) < 0 || GetStringLen(v_VENDOR) < 10)
            {
                Alert("廠商編號欄位長度不足,請重新輸入");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }
            //檢核廠商編號
            if (!(checkCompanyNo(v_VENDOR.Substring(0, 8))))
            {
                Alert("廠商編號輸入有誤,請重新輸入");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }
            
            //檢查廠商統編是否重覆
            ParameterList.Clear();
            
            ParameterList.Add(v_VENDOR);
            DataTable Q_Table = bco.QueryVendorBaseByCode(ParameterList);
            if (Q_Table.Rows.Count > 0)
            {
                Alert("廠商編號重覆輸入,請重新輸入");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }

            #endregion

            DateTime DT = DateTime.Now;
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vID", v_ID); //vID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCODE", v_VENDOR); //vCODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR", v_VENDOR); //vVENDOR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_NAME", v_VENDOR_NAME); //vVENDOR_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBOSS", v_BOSS); //vBOSS
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vVENDOR_OPEN_DATE", v_VENDOR_OPEN_DATE); //vVENDOR_OPEN_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vVENDOR_CLOSE_DATE", v_VENDOR_CLOSE_DATE); //vVENDOR_CLOSE_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_SERVICE_TEL_AREA", v_VENDOR_SERVICE_TEL_AREA); //vVENDOR_SERVICE_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_SERVICE_TEL", v_VENDOR_SERVICE_TEL); //vVENDOR_SERVICE_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vMAIL_ADDR", v_MAIL_ADDR); //vMAIL_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vHEAD_OFFICE_BANK", v_HEAD_OFFICE_BANK); //vHEAD_OFFICE_BANK
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vHEAD_BANK_NO", v_HEAD_BANK_NO); //vHEAD_BANK_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBANK_ACCOUNT_NO", v_BANK_ACCOUNT_NO); //vBANK_ACCOUNT_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBRANCH_OF_BANK", v_BRANCH_OF_BANK); //vBRANCH_OF_BANK
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBRANCH_BANK_NO", v_BRANCH_BANK_NO); //vBRANCH_BANK_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_PDZ_NO", v_INV_PDZ_NO); //vINV_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_ADDR", v_INV_ADDR); //vINV_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_TEL_AREA", v_INV_TEL_AREA); //vINV_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_TEL", v_INV_TEL); //vINV_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_FAX_AREA", v_INV_FAX_AREA); //vINV_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vINV_FAX", v_INV_FAX); //vINV_FAX
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_PDZ_NO", v_BUSINESS_PDZ_NO); //vBUSINESS_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_ADDR", v_BUSINESS_ADDR); //vBUSINESS_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_TEL_AREA", v_BUSINESS_TEL_AREA); //vBUSINESS_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_TEL", v_BUSINESS_TEL); //vBUSINESS_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_FAX_AREA", v_BUSINESS_FAX_AREA); //vBUSINESS_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_FAX", v_BUSINESS_FAX); //vBUSINESS_FAX
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_CONTACT", v_BUSINESS_CONTACT1); //vBUSINESS_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_EXTENSION", v_BUSINESS_EXTENSION1); //vBUSINESS_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_MOBILE", v_CELL_PHONE1); //vBUSINESS_MOBILE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vBUSINESS_MAIL", v_BUSINESS_MAIL1); //vBUSINESS_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vRETURN_EXTENSION", v_BUSINESS_EXTENSION2); //vRETURN_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vRETURN_MOBILE", v_CELL_PHONE2); //vRETURN_MOBILE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vRETURN_MAIL", v_BUSINESS_MAIL2); //vRETURN_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vACCOUNT_CONTACT", v_ACCOUNT_CONTACT); //vACCOUNT_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vACCOUNT_EXTENSION", v_ACCOUNT_EXTENSION); //vACCOUNT_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vACCOUNT_MAIL", v_ACCOUNT_MAIL); //vACCOUNT_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUB_CBRE", v_PUB_CBRE); //vPUB_CBRE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUB_ENAME", v_PUB_ENAME); //vPUB_ENAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPUB_NUM", v_PUB_NUM); //vPUB_NUM
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vNOTES", v_NOTES); //vNOTES
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vRETURN_CONTACT", v_RETURN_CONTACT); //vRETURN_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_CODE", v_VENDOR_CODE); //vVENDOR_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOL_DAYS", v_COL_DAYS); //vCOL_DAYS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vPAY_TYPE", v_PAY_TYPE); //vPAY_TYPE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", DT); //vCREATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", DT); //vUPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_PDZ_NO", v_COM_PDZ_NO); //vCOM_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_ADDR", v_COM_ADDR); //vCOM_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_TEL_AREA", v_COM_TEL_AREA); //vCOM_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_TEL", v_COM_TEL); //vCOM_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_FAX_AREA", v_COM_FAX_AREA); //vCOM_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCOM_FAX", v_COM_FAX); //vCOM_FAX
            bco.CreateVendorBase(ParameterList, DBT);


            LogHelper LOG = new LogHelper(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add("VDM01供應商主檔");//0
            ParameterList.Add(Session["UID"].ToString());//1
            ParameterList.Add("I");//2
            ParameterList.Add(v_VENDOR);//3
            ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

            LOG.AddSafeLog(ParameterList);

            //更新母子關係設定資料
            //更新母子關係設定資料
            DataTable dtMotherOLD = bcoMonther.ConvertXMLToDataTable(MotherVendor.InnerHtml);
            DataTable dtMotherNEW = bcoMonther.ConvertXMLToDataTable(NewMotherVendor.InnerHtml);
            for (int i = 0; i < repMOTHER_VENDOR.Items.Count; i++)
            {
                DataRow nRow = dtMotherNEW.Rows[i];
                RepeaterItem nItem = repMOTHER_VENDOR.Items[i];
                if (((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).Text == "")
                {
                    dtMotherNEW.Rows.RemoveAt(i);
                    continue;
                }
                nRow["PID"] = v_ID;
                nRow["VENDOR_CODE"] = v_VENDOR;
                nRow["VENDOR"] = ((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).Text;
                nRow["VENDOR_NAME"] = ((TextBox)((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).FindControl("TextBoxName")).Text;
                CheckBox cbMOTHER_SINGLE_COST = (CheckBox)((WUI.SLP.SLP_Boolean)nItem.FindControl("txtMOTHER_SINGLE_COST")).FindControl("C1");
                nRow["SINGLE_COST"] = ((cbMOTHER_SINGLE_COST.Checked) ? 1 : 0);
                if (((WUI.SLP.EnumBase)nItem.FindControl("txtMOTHER_PAY_TYPE")).Text != "") nRow["PAY_TYPE"] = ((WUI.SLP.EnumBase)nItem.FindControl("txtMOTHER_PAY_TYPE")).Text;
            }
            for (int i = 0; i < dtMotherOLD.Rows.Count; i++)
            {
                DataRow drMotherOld = dtMotherOLD.Rows[i];
                if (dtMotherNEW.Select(string.Format("VENDOR='{0}'", drMotherOld["VENDOR"].ToString())).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drMotherOld["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PID", drMotherOld["PID"].ToString()); //OLD_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", drMotherOld["VENDOR_CODE"].ToString()); //OLD_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR", drMotherOld["VENDOR"].ToString()); //OLD_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_NAME", drMotherOld["VENDOR_NAME"].ToString()); //OLD_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "OLD_SINGLE_COST", drMotherOld["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PAY_TYPE", drMotherOld["PAY_TYPE"].ToString()); //OLD_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", (DateTime)drMotherOld["CREATEDATE"]); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", drMotherOld["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", (DateTime)drMotherOld["UPDATEDATE"]); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", drMotherOld["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DT); //NEW_UPDATEDATE
                    bcoMonther.DeleteMontherVendor(ParameterList, DBT);
                }
            }
            for (int i = 0; i < dtMotherNEW.Rows.Count; i++)
            {
                DataRow drMotherNew = dtMotherNEW.Rows[i];
                if (dtMotherOLD.Select(string.Format("VENDOR='{0}'", drMotherNew["VENDOR"].ToString())).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPID", drMotherNew["PID"].ToString()); //vPID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_CODE", drMotherNew["VENDOR_CODE"].ToString()); //vVENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR", drMotherNew["VENDOR"].ToString()); //vVENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_NAME", drMotherNew["VENDOR_NAME"].ToString()); //vVENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "vSINGLE_COST", drMotherNew["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPAY_TYPE", drMotherNew["PAY_TYPE"].ToString()); //vPAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", DT); //vCREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", DT); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
                    if (i == (dtMotherNEW.Rows.Count - 1))
                        bcoMonther.CreateMontherVendor(ParameterList, DBT, true);
                    else
                        bcoMonther.CreateMontherVendor(ParameterList, DBT);
                }
                else
                {
                    ParameterList.Clear();
                    DataRow[] drMotherOlds = dtMotherOLD.Select(string.Format("VENDOR='{0}'", drMotherNew["VENDOR"].ToString()));
                    DataRow drMotherOld = drMotherOlds[0];
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drMotherOld["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PID", drMotherOld["PID"].ToString()); //OLD_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", drMotherOld["VENDOR_CODE"].ToString()); //OLD_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR", drMotherOld["VENDOR"].ToString()); //OLD_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_NAME", drMotherOld["VENDOR_NAME"].ToString()); //OLD_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "OLD_SINGLE_COST", drMotherOld["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PAY_TYPE", drMotherOld["PAY_TYPE"].ToString()); //OLD_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", (DateTime)drMotherOld["CREATEDATE"]); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", drMotherOld["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", (DateTime)drMotherOld["UPDATEDATE"]); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", drMotherOld["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_PID", drMotherNew["PID"].ToString()); //NEW_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_CODE", drMotherNew["VENDOR_CODE"].ToString()); //NEW_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR", drMotherNew["VENDOR"].ToString()); //NEW_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_NAME", drMotherNew["VENDOR_NAME"].ToString()); //NEW_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "NEW_SINGLE_COST", drMotherNew["SINGLE_COST"].ToString()); //NEW_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_PAY_TYPE", drMotherNew["PAY_TYPE"].ToString()); //NEW_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DT); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    if (i == (dtMotherNEW.Rows.Count - 1))
                        bcoMonther.UpdateMontherVendor(ParameterList, DBT, true);
                    else
                        bcoMonther.UpdateMontherVendor(ParameterList, DBT);
                }
            }

            //Response.Write("<script>alert('新增完成');location.replace('VDM012.aspx?ID=" + v_ID + "');</script>");
            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.replace('VDM012.aspx?Code=VDM01&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + arl_Key + "&ID=" + v_ID + "');");
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }

    }//end InsertButton_Click
Esempio n. 3
0
    /// <summary>
    /// 繫結資料到控制項
    /// </summary>
    /// <param name="vdb"></param>
    private void databind(string strFLAG)
    {
        #region

        //抓取本頁初次登記的時間

        string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value);

        STMModel.MaintainStoreBase BCO = new STMModel.MaintainStoreBase(ConnectionDB);

        ParameterList.Clear();

        //門市基本31
        TextBox txt_TELAREA = (TextBox)this.SLP_TEL_NO.FindControl("T1");
        TextBox txt_TELNO = (TextBox)this.SLP_TEL_NO.FindControl("T2");
        TextBox txt_FAXAREA = (TextBox)this.SLP_FAX_NO.FindControl("T1");
        TextBox txt_FAXNO = (TextBox)this.SLP_FAX_NO.FindControl("T2");

        ParameterList.Add(GetValueSetParameter(this.SLP_STORE.Text.Trim(),"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_MDC_START_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_MDC_START_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_MDC_END_DATE.StartDate, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_MDC_END_DATE.EndDate, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CHAN_NO.Text,"string",CheckBoxLikeSearch.Checked));;
        ParameterList.Add(GetValueSetParameter(this.SLP_GROUP_NO.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtOLD_STORE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_OPEN_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_OPEN_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_CLOSE_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_CLOSE_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_REOPEN_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_REOPEN_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_REMODEL_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_REMODEL_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));      
        ParameterList.Add(GetValueSetParameter(this.SLP_Z_O.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_D_O.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_TYPE.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtSTORE_ZIP.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(txt_TELAREA.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(txt_TELNO.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(txt_FAXAREA.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(txt_FAXNO.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtSTORE_ADDRESS.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_DATE.EndDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CREATE_UID.Text,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE.StartDate,"string",CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_DATE.EndDate, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_UPDATE_UID.Text, "string", CheckBoxLikeSearch.Checked));
        
        //配送屬性17
        RadioButtonList rdo_DIS_SW = (RadioButtonList)this.SLP_DIS_SW.FindControl("R1");
        RadioButtonList rdo_MARKET_RESEARCH = (RadioButtonList)this.SLP_MARKET_RESEARCH.FindControl("R1");
        RadioButtonList rdo_SING_VEN = (RadioButtonList)this.SLP_SING_VEN.FindControl("R1");
        RadioButtonList rdo_MDC_TAXABLE = (RadioButtonList)this.SLP_MDC_TAXABLE.FindControl("R1");
        RadioButtonList rdo_MDC_TAXFREE = (RadioButtonList)this.SLP_MDC_TAXFREE.FindControl("R1");

        ParameterList.Add(GetValueSetParameter(this.SLP_AREA_NO.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_AREA_CODE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_SHELVE_CM3.Text, "int", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_ROUTE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtSTEP.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtARRIVE_TIME.Text, "string", CheckBoxLikeSearch.Checked));

        if (rdo_DIS_SW.SelectedValue == "")
            ParameterList.Add(DBNull.Value);
        if (rdo_DIS_SW.SelectedValue == "1")
            ParameterList.Add(1);
        if (rdo_DIS_SW.SelectedValue == "0")
            ParameterList.Add(0);

        ParameterList.Add(this.ddlALLOCATION_TIMES.Text);
        ParameterList.Add(GetValueSetParameter(this.SLP_ALLOCATION_TIMES.Text, "int", CheckBoxLikeSearch.Checked));

        if (rdo_MARKET_RESEARCH.SelectedValue == "")
            ParameterList.Add(DBNull.Value);
        if (rdo_MARKET_RESEARCH.SelectedValue == "1")
            ParameterList.Add(1);
        if (rdo_MARKET_RESEARCH.SelectedValue == "0")
            ParameterList.Add(0);

        ParameterList.Add(GetValueSetParameter(this.SLP_AC_UID.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_SAL_ID.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_FEAT_GRADE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.txtPAY_RFNO.Text, "string", CheckBoxLikeSearch.Checked));

        if (rdo_SING_VEN.SelectedValue == "")
            ParameterList.Add(DBNull.Value);
        if (rdo_SING_VEN.SelectedValue == "1")
            ParameterList.Add(1);
        if (rdo_SING_VEN.SelectedValue == "0")
            ParameterList.Add(0);

        if (rdo_MDC_TAXABLE.SelectedValue == "")
            ParameterList.Add(DBNull.Value);
        if (rdo_MDC_TAXABLE.SelectedValue == "1")
            ParameterList.Add(1);
        if (rdo_MDC_TAXABLE.SelectedValue == "0")
            ParameterList.Add(0);
        
        if (rdo_MDC_TAXFREE.SelectedValue == "")
            ParameterList.Add(DBNull.Value);
        if (rdo_MDC_TAXFREE.SelectedValue == "1")
            ParameterList.Add(1);
        if (rdo_MDC_TAXFREE.SelectedValue == "0")
            ParameterList.Add(0);

        //屬性19
        CheckBox chk_W1 = (CheckBox)this.SLP_Boolean_W1.FindControl("C1");
        CheckBox chk_W2 = (CheckBox)this.SLP_Boolean_W2.FindControl("C1");
        CheckBox chk_W3 = (CheckBox)this.SLP_Boolean_W3.FindControl("C1");
        CheckBox chk_W4 = (CheckBox)this.SLP_Boolean_W4.FindControl("C1");
        CheckBox chk_W5 = (CheckBox)this.SLP_Boolean_W5.FindControl("C1");
        CheckBox chk_W6 = (CheckBox)this.SLP_Boolean_W6.FindControl("C1");
        CheckBox chk_W7 = (CheckBox)this.SLP_Boolean_W7.FindControl("C1");

        ParameterList.Add(GetValueSetParameter(this.txtCOPY_SOURCE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(this.ddlPSM.Text);
        ParameterList.Add(GetValueSetParameter(this.SLP_PSM.Text, "int", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_BUSINESS_NO.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_OPEN_TIME.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_CLOSE_TIME.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_COMPETITION.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_REMARK.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_STORE_SPE.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(chk_W1.Checked ? "1" : null);
        ParameterList.Add(chk_W2.Checked ? "1" : null);
        ParameterList.Add(chk_W3.Checked ? "1" : null);
        ParameterList.Add(chk_W4.Checked ? "1" : null);
        ParameterList.Add(chk_W5.Checked ? "1" : null);
        ParameterList.Add(chk_W6.Checked ? "1" : null);
        ParameterList.Add(chk_W7.Checked ? "1" : null);
        ParameterList.Add(GetValueSetParameter(this.SLP_SHELF_NO.Text, "string", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_DISPLAY_NUM.Text, "int", CheckBoxLikeSearch.Checked));
        ParameterList.Add(GetValueSetParameter(this.SLP_SHELVE_CM3_2.Text, "int", CheckBoxLikeSearch.Checked));

        ParameterList.Add(GetValueSetParameter(this.txtStoreName.Text, "string", CheckBoxLikeSearch.Checked)); //2010/06/14新增店名查詢欄位

        if (strFLAG != "EXCEL")
        {
            DataTable Dt = BCO.QuerySwitch(STMModel.MaintainStoreBase.QueryType.QueryByLike, ParameterList);
            int iRowCount = (this.TextBoxRowCountLimit.Text.Trim() == string.Empty) ? 9999 : int.Parse(TextBoxRowCountLimit.Text);
            while (Dt.Rows.Count > iRowCount)
            {
                DataRow dr = Dt.Rows[Dt.Rows.Count - 1];
                dr.Delete();
                Dt.AcceptChanges();
            }
            Session[SessionIDName] = Dt;
            GridView1.DataSource = Dt;

            //設定分頁大小
            GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
            GridView1.PageIndex = 0;
            GridView1.DataBind();

            LabelQueryRecordCount.Text = string.Format(" {0} Rows ", Dt.Rows.Count.ToString());

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
            }

            #region 將Key值存到Session中

            ArrayList arl_Key = new ArrayList();

            foreach (DataRow drRow in Dt.Rows)
            { arl_Key.Add("store=" + drRow["STORE"].ToString() + "&date=" + drRow["MDC_START_DATE"].ToString()); }

            Session["STM012_SortKey" + this.PageTimeStamp.Value] = arl_Key;
        }
        else
        {
            DataTable Dt1 = BCO.QuerySwitch(STMModel.MaintainStoreBase.QueryType.Excel, ParameterList);
            int iRowCount = (this.TextBoxRowCountLimit.Text.Trim() == string.Empty) ? 9999 : int.Parse(TextBoxRowCountLimit.Text);
            while (Dt1.Rows.Count > iRowCount)
            {
                DataRow dr = Dt1.Rows[Dt1.Rows.Count - 1];
                dr.Delete();
                Dt1.AcceptChanges();
            }

            for (int j = 0; j < Dt1.Rows.Count; j++)
            {
                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("STM01門市主檔");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("O");//2
                ParameterList.Add(Dt1.Rows[j]["STORE"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);
            }

                Session[SessionIDName] = Dt1;
        }

        #endregion

        #endregion
    }//databind
Esempio n. 4
0
    }//ChangeFormMSTMode

    /// <summary>
    /// 繫結資料到畫面控制項
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind()
    {
        try
        {
            bool noData = false;
            ParameterList.Clear();
            if (Request["ID"] != null)
            {
                ViewState["NEWID"] = Request["ID"].ToString();
                ParameterList.Add(Request["ID"].ToString());
            }
            else
            {
                ViewState["NEWID"] = bco.GetNewID();
                ParameterList.Add("0");
            }
            DataTable dt = bco.QueryVendorBaseByID(ParameterList);
            MasterOLDData.InnerHtml = bco.ConvertBetweenDataTableToXML(dt);
            if (dt.Rows.Count > 0 || Request["ID"] == null)
            {
                LogHelper LOG = new LogHelper(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add("VDM01供應商主檔");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("Q");//2
                ParameterList.Add(dt.Rows[0]["VENDOR"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                ParameterList.Clear();
                SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "PID", ViewState["NEWID"].ToString(), "=", "and");
                DataTable dtMother = bcoMonther.QueryMontherVendorByFind_1(ParameterList);
                MotherVendor.InnerHtml = bcoMonther.ConvertBetweenDataTableToXML(dtMother);
                NewMotherVendor.InnerHtml = bco.ConvertBetweenDataTableToXML(dtMother);

                if (dt.Rows.Count > 0)
                {
                    txtMOTHER_VENDOR_CODE.Text = dt.Rows[0]["VENDOR"].ToString();
                    txtMOTHER_VENDOR_NAME.Text = dt.Rows[0]["VENDOR_NAME"].ToString();
                }

                repMOTHER_VENDOR.DataSource = dtMother;
                repMOTHER_VENDOR.DataBind();


                FormView1.DataSource = dt;
                FormView1.DataBind();
                //AuthorityControls(this);
            }
            else
            {
                noData = true;
                if (Request.QueryString["isToolBar"] == "Y")
                    ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕繼續查詢";
                else
                    ErrorMsgLabel.Text = "無法取得資料";
            }

            switch (FormView1.CurrentMode)
            {
                case FormViewMode.Edit:
                    if (noData)
                    {
                        FormView1.ChangeMode(FormViewMode.ReadOnly);
                        ((Button)FormView1.FindControl("EditButton")).Enabled = false;
                        ((Button)FormView1.FindControl("DeleteButton")).Enabled = false;
                    }
                    else
                    {
                        GMToolbar1.SetupControl(null, null, (Button)FormView1.FindControl("EditCommitButton"), null, null);
                        GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.UpdateEdit;
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete,
                         false,
                         "",
                         (Button)FormView1.FindControl("DeleteButton"),
                         WUI_GMToolbarV.ClickAction.ButtonClick
                         );
                    }
                    break;
                case FormViewMode.Insert:

                    GMToolbar1.SetupControl(null, null, (Button)FormView1.FindControl("InsertButton"), null, null);
                    GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.NewEdit;
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete,
                     false,
                     "",
                     (Button)FormView1.FindControl("DeleteButton"),
                     WUI_GMToolbarV.ClickAction.ButtonClick
                     );
                    break;
                case FormViewMode.ReadOnly:
                    GMToolbar1.SetupControl(null, null, null, (Button)FormView1.FindControl("DeleteButton"), (Button)FormView1.FindControl("EditButton"));
                    GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.ViewOne;
                    ArrayList arr = (ArrayList)Session[Request.QueryString["arl_Key"]];
                    if (arr.Count == 1)
                        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarJustOneRecord, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                    else
                        if (Request["ID"] != null)
                        {
                            int i = GetALIndex(Request["ID"].ToString());
                            if (i == 0)
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarFirstRecord, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                            else if (i == arr.Count - 1)
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarLastRecord, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                        }
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, true, "", (Button)FormView1.FindControl("DeleteButton"), WUI_GMToolbarV.ClickAction.ButtonClick);
                    break;
            }
            if (noData)
            {
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }//databind
Esempio n. 5
0
    }//end CancelButton_Click

    /// <summary>
    /// 編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        int res = 0;
        try
        {
            this.txtMOTHER_VENDOR_CODE.Text = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).Text.Trim();
            #region 取得畫面元件的值

            string v_ID = ((TextBox)FormView1.FindControl("txtID")).Text.Trim();
            string v_VENDOR = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).Text.Trim();
            string v_VENDOR_NAME = ((TextBox)FormView1.FindControl("txtVENDOR_NAME")).Text.Trim();
            string v_BOSS = ((TextBox)FormView1.FindControl("txtBOSS")).Text.Trim();
            string v_VENDOR_OPEN_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtVENDOR_OPEN_DATE")).Text.Trim();
            string v_VENDOR_CLOSE_DATE = ((WUI.SLP.SLPDate)FormView1.FindControl("txtVENDOR_CLOSE_DATE")).Text.Trim();
            string v_VENDOR_SERVICE_TEL_AREA = ((TextBox)FormView1.FindControl("txtVENDOR_SERVICE_TEL_AREA")).Text.Trim();
            string v_VENDOR_SERVICE_TEL = ((TextBox)FormView1.FindControl("txtVENDOR_SERVICE_TEL")).Text.Trim();
            string v_MAIL_ADDR = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtMAIL_ADDR")).Text.Trim();
            string v_HEAD_OFFICE_BANK = ((TextBox)FormView1.FindControl("txtHEAD_OFFICE_BANK")).Text.Trim();
            string v_HEAD_BANK_NO = ((TextBox)FormView1.FindControl("txtHEAD_BANK_NO")).Text.Trim();
            string v_BANK_ACCOUNT_NO = ((TextBox)FormView1.FindControl("txtBANK_ACCOUNT_NO")).Text.Trim();
            string v_BRANCH_OF_BANK = ((TextBox)FormView1.FindControl("txtBRANCH_OF_BANK")).Text.Trim();
            string v_BRANCH_BANK_NO = ((TextBox)FormView1.FindControl("txtBRANCH_BANK_NO")).Text.Trim();
            string v_INV_PDZ_NO = ((TextBox)FormView1.FindControl("txtINV_PDZ_NO")).Text.Trim();
            string v_INV_ADDR = ((TextBox)FormView1.FindControl("txtINV_ADDR")).Text.Trim();
            string v_INV_TEL_AREA = ((TextBox)FormView1.FindControl("txtINV_TEL_AREA")).Text.Trim();
            string v_INV_TEL = ((TextBox)FormView1.FindControl("txtINV_TEL")).Text.Trim();
            string v_INV_FAX_AREA = ((TextBox)FormView1.FindControl("txtINV_FAX_AREA")).Text.Trim();
            string v_INV_FAX = ((TextBox)FormView1.FindControl("txtINV_FAX")).Text.Trim();
            string v_BUSINESS_PDZ_NO = ((TextBox)FormView1.FindControl("txtBUSINESS_PDZ_NO")).Text.Trim();
            string v_BUSINESS_ADDR = ((TextBox)FormView1.FindControl("txtBUSINESS_ADDR")).Text.Trim();
            string v_BUSINESS_TEL_AREA = ((TextBox)FormView1.FindControl("txtBUSINESS_TEL_AREA")).Text.Trim();
            string v_BUSINESS_TEL = ((TextBox)FormView1.FindControl("txtBUSINESS_TEL")).Text.Trim();
            string v_BUSINESS_FAX_AREA = ((TextBox)FormView1.FindControl("txtBUSINESS_FAX_AREA")).Text.Trim();
            string v_BUSINESS_FAX = ((TextBox)FormView1.FindControl("txtBUSINESS_FAX")).Text.Trim();
            string v_BUSINESS_CONTACT1 = ((TextBox)FormView1.FindControl("txtBUSINESS_CONTACT1")).Text.Trim();
            string v_BUSINESS_EXTENSION1 = ((TextBox)FormView1.FindControl("txtBUSINESS_EXTENSION1")).Text.Trim();
            string v_CELL_PHONE1 = ((TextBox)FormView1.FindControl("txtCELL_PHONE1")).Text.Trim();
            string v_BUSINESS_MAIL1 = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtBUSINESS_MAIL1")).Text.Trim();
            //string v_BUSINESS_CONTACT2 = ((TextBox)FormView1.FindControl("txtBUSINESS_CONTACT2")).Text.Trim();
            string v_BUSINESS_EXTENSION2 = ((TextBox)FormView1.FindControl("txtBUSINESS_EXTENSION2")).Text.Trim();
            string v_CELL_PHONE2 = ((TextBox)FormView1.FindControl("txtCELL_PHONE2")).Text.Trim();
            string v_BUSINESS_MAIL2 = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtBUSINESS_MAIL2")).Text.Trim();
            string v_ACCOUNT_CONTACT = ((TextBox)FormView1.FindControl("txtACCOUNT_CONTACT")).Text.Trim();
            string v_ACCOUNT_EXTENSION = ((TextBox)FormView1.FindControl("txtACCOUNT_EXTENSION")).Text.Trim();
            string v_ACCOUNT_MAIL = ((WUI.SLP.EMailAddress)FormView1.FindControl("txtACCOUNT_MAIL")).Text.Trim();
            string v_PUB_CBRE = ((TextBox)FormView1.FindControl("txtPUB_CBRE")).Text.Trim();
            string v_PUB_ENAME = ((TextBox)FormView1.FindControl("txtPUB_ENAME")).Text.Trim();
            string v_PUB_NUM = ((TextBox)FormView1.FindControl("txtPUB_NUM")).Text.Trim();
            string v_NOTES = ((TextBox)FormView1.FindControl("txtNOTES")).Text.Trim();
            string v_RETURN_CONTACT = ((TextBox)FormView1.FindControl("txtRETURN_CONTACT")).Text.Trim();
            string v_VENDOR_CODE = ((TextBox)FormView1.FindControl("txtVENDOR_CODE")).Text.Trim();
            string v_COL_DAYS = ((WUI.SLP.CodeFile)FormView1.FindControl("txtCOL_DAYS")).Text.Trim();
            string v_PAY_TYPE = ((WUI.SLP.EnumBase)FormView1.FindControl("txtPAY_TYPE")).Text.Trim();
            string v_COM_PDZ_NO = ((TextBox)FormView1.FindControl("txtCOM_PDZ_NO")).Text.Trim();
            string v_COM_ADDR = ((TextBox)FormView1.FindControl("txtCOM_ADDR")).Text.Trim();
            string v_COM_TEL_AREA = ((TextBox)FormView1.FindControl("txtCOM_TEL_AREA")).Text.Trim();
            string v_COM_TEL = ((TextBox)FormView1.FindControl("txtCOM_TEL")).Text.Trim();
            string v_COM_FAX_AREA = ((TextBox)FormView1.FindControl("txtCOM_FAX_AREA")).Text.Trim();
            string v_COM_FAX = ((TextBox)FormView1.FindControl("txtCOM_FAX")).Text.Trim();

            #endregion 取得畫面元件的值

            DataTable dt = bco.ConvertXMLToDataTable(MasterOLDData.InnerHtml);
            DataRow dr = dt.Rows[0];

            #region 新舊值比對
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ID", dr["ID"].ToString(), "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.ENABLE", 1, "=", "and");
            DataTable dtOld = bco.QueryVendorBaseByFind_1(ParameterList);
            if (dtOld.Rows.Count == 0)
            { Alert("更新失敗,此資料已被其他使用者刪除,請重新查詢"); return; }
            else
            {
                DataRow drOld = dtOld.Rows[0];
                if (dr["UpdateUid"].ToString() != drOld["UpdateUid"].ToString() ||
                    dr["UpdateDate"].ToString() != drOld["UpdateDate"].ToString())
                {
                    Alert("更新失敗,此資料已被其他使用者異動,請重新查詢再進行編輯"); return;
                }
            }
            #endregion

            #region 資料檢查

            //檢核各欄位長度
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            if (this.Get_Byte_Length(v_VENDOR_NAME) > 50)
            {
                sb.Append("供應商名稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_BOSS) > 10)
            {
                sb.Append("負責人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_MAIL_ADDR) > 50)
            {
                sb.Append("客服EMAIL欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_HEAD_OFFICE_BANK) > 20)
            {
                sb.Append("銀行總行名稱電匯資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_INV_TEL) > 10)
            {
                sb.Append("電話發票資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_INV_FAX) > 10)
            {
                sb.Append("傳真發票資料欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_BUSINESS_CONTACT1) > 10)
            {
                sb.Append("業務連絡人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_ACCOUNT_CONTACT) > 10)
            {
                sb.Append("財務連絡人欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_PUB_CBRE) > 8)
            {
                sb.Append("供應商簡稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_PUB_ENAME) > 50)
            {
                sb.Append("英文名稱欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_NOTES) > 50)
            {
                sb.Append("說明備註欄位資料長度過長\\n");
            }
            if (this.Get_Byte_Length(v_RETURN_CONTACT) > 10)
            {
                sb.Append("廠退聯絡人資料長度過長\\n");
            }

            if (sb.ToString().Length > 0)
            {
                Alert(sb.ToString());
                return;
            }

            //  if (DateTime.Today.CompareTo(Convert.ToDateTime(v_VENDOR_OPEN_DATE)) >= 0 && dr["VENDOR"].ToString() != v_VENDOR) { Alert("系統日>=往來開始日不可修改供應商統編"); return; }
            //  if (DateTime.Today.CompareTo(Convert.ToDateTime(v_VENDOR_CLOSE_DATE)) <= 0 && dr["VENDOR"].ToString() != v_VENDOR) { Alert("系統日<=往來結束日不可修改供應商統編"); return; }
            if (Convert.ToDateTime(v_VENDOR_OPEN_DATE).CompareTo(Convert.ToDateTime(v_VENDOR_CLOSE_DATE)) > 0) { Alert("往來開始日不可大於往來結束日"); return; }
            //檢核資料供應商合約中的有效合約
            string CONTRACT_CNT = "", ITEM_CNT = "";
            bco.QueryForDelete(dr["VENDOR_CODE"].ToString(), out CONTRACT_CNT, out ITEM_CNT);
            if ((CONTRACT_CNT != "0") && (dr["VENDOR"].ToString() != v_VENDOR))
            {
                Alert("此廠商已有簽訂合約,不能修改供應商統編欄位");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }

            //檢核資料商品主檔中的有效商品
            ParameterList.Clear();
            ParameterList.Add(dr["VENDOR"].ToString());
            if ((bco.CheckVendorItemExists(ParameterList) == "1") && (dr["VENDOR"].ToString() != v_VENDOR))
            {
                Alert("此廠商還有提供商品主檔中的有效商品,不能修改供應商統編欄位");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }
            //檢核長度
            if (GetStringLen(v_VENDOR) < 0 || GetStringLen(v_VENDOR) < 10)
            {
                Alert("廠商編號欄位長度不足,請重新輸入");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }            
            //檢核廠商編號            
            if (!(checkCompanyNo(v_VENDOR.Substring(0, 8))))
            {
                Alert("廠商編號輸入有誤,請重新輸入");
                hiddenFocusCtrlID.Value = ((PIC.VDS2G.WebUI.SLP.SLPUnique)FormView1.FindControl("txtVENDOR")).TextBox_Code.ClientID;
                return;
            }

            if (this.LengthVaild(v_BRANCH_OF_BANK, 30) == false)
            {
                Alert("分行名稱欄位長度過長,請重新輸入");
                hiddenFocusCtrlID.Value = ((TextBox)FormView1.FindControl("txtBRANCH_OF_BANK")).ClientID;
                return;
            }

            if (this.LengthVaild(v_INV_ADDR, 50) == false)
            {
                Alert("地址欄位長度過長,請重新輸入");
                hiddenFocusCtrlID.Value = ((TextBox)FormView1.FindControl("txtINV_ADDR")).ClientID;
                return;
            }

            if (this.LengthVaild(v_COM_ADDR, 50) == false)
            {
                Alert("地址欄位長度過長,請重新輸入");
                hiddenFocusCtrlID.Value = ((TextBox)FormView1.FindControl("txtCOM_ADDR")).ClientID;
                return;
            }

            if (this.LengthVaild(v_BUSINESS_ADDR, 50) == false)
            {
                Alert("地址欄位長度過長,請重新輸入");
                hiddenFocusCtrlID.Value = ((TextBox)FormView1.FindControl("txtBUSINESS_ADDR")).ClientID;
                return;
            }
            #endregion

            DateTime DT = DateTime.Now;
            #region 更新編輯後的資料
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID
            //SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", dr["VENDOR_CODE"].ToString()); //OLD_VENDOR_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", dr["VENDOR"].ToString()); //OLD_VENDOR_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_NAME", dr["VENDOR_NAME"].ToString()); //OLD_VENDOR_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", dr["UPDATEDATE"].ToString()); //OLD_UPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", dr["UPDATEUID"].ToString()); //OLD_UPDATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CODE", v_VENDOR); //NEW_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR", v_VENDOR); //NEW_VENDOR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_NAME", v_VENDOR_NAME); //NEW_VENDOR_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BOSS", v_BOSS); //NEW_BOSS
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_VENDOR_OPEN_DATE", v_VENDOR_OPEN_DATE); //NEW_VENDOR_OPEN_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_VENDOR_CLOSE_DATE", v_VENDOR_CLOSE_DATE); //NEW_VENDOR_CLOSE_DATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_SERVICE_TEL_AREA", v_VENDOR_SERVICE_TEL_AREA); //NEW_VENDOR_SERVICE_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_SERVICE_TEL", v_VENDOR_SERVICE_TEL); //NEW_VENDOR_SERVICE_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_MAIL_ADDR", v_MAIL_ADDR); //NEW_MAIL_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_HEAD_OFFICE_BANK", v_HEAD_OFFICE_BANK); //NEW_HEAD_OFFICE_BANK
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_HEAD_BANK_NO", v_HEAD_BANK_NO); //NEW_HEAD_BANK_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BANK_ACCOUNT_NO", v_BANK_ACCOUNT_NO); //NEW_BANK_ACCOUNT_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BRANCH_OF_BANK", v_BRANCH_OF_BANK); //NEW_BRANCH_OF_BANK
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BRANCH_BANK_NO", v_BRANCH_BANK_NO); //NEW_BRANCH_BANK_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_PDZ_NO", v_INV_PDZ_NO); //NEW_INV_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_ADDR", v_INV_ADDR); //NEW_INV_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_TEL_AREA", v_INV_TEL_AREA); //NEW_INV_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_TEL", v_INV_TEL); //NEW_INV_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_FAX_AREA", v_INV_FAX_AREA); //NEW_INV_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_INV_FAX", v_INV_FAX); //NEW_INV_FAX
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_PDZ_NO", v_BUSINESS_PDZ_NO); //NEW_BUSINESS_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_ADDR", v_BUSINESS_ADDR); //NEW_BUSINESS_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_TEL_AREA", v_BUSINESS_TEL_AREA); //NEW_BUSINESS_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_TEL", v_BUSINESS_TEL); //NEW_BUSINESS_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_FAX_AREA", v_BUSINESS_FAX_AREA); //NEW_BUSINESS_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_FAX", v_BUSINESS_FAX); //NEW_BUSINESS_FAX
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_CONTACT", v_BUSINESS_CONTACT1); //NEW_BUSINESS_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_EXTENSION", v_BUSINESS_EXTENSION1); //NEW_BUSINESS_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_MOBILE", v_CELL_PHONE1); //NEW_BUSINESS_MOBILE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_BUSINESS_MAIL", v_BUSINESS_MAIL1); //NEW_BUSINESS_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_RETURN_EXTENSION", v_BUSINESS_EXTENSION2); //NEW_RETURN_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_RETURN_MOBILE", v_CELL_PHONE2); //NEW_RETURN_MOBILE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_RETURN_MAIL", v_BUSINESS_MAIL2); //NEW_RETURN_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_ACCOUNT_CONTACT", v_ACCOUNT_CONTACT); //NEW_ACCOUNT_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_ACCOUNT_EXTENSION", v_ACCOUNT_EXTENSION); //NEW_ACCOUNT_EXTENSION
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_ACCOUNT_MAIL", v_ACCOUNT_MAIL); //NEW_ACCOUNT_MAIL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PUB_CBRE", v_PUB_CBRE); //NEW_PUB_CBRE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PUB_ENAME", v_PUB_ENAME); //NEW_PUB_ENAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PUB_NUM", v_PUB_NUM); //NEW_PUB_NUM
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_NOTES", v_NOTES); //NEW_NOTES
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_RETURN_CONTACT", v_RETURN_CONTACT); //NEW_RETURN_CONTACT
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_CODE", v_VENDOR_CODE); //NEW_VENDOR_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COL_DAYS", v_COL_DAYS); //NEW_COL_DAYS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PAY_TYPE", v_PAY_TYPE); //NEW_PAY_TYPE
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DT); //NEW_UPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_PDZ_NO", v_COM_PDZ_NO); //NEW_COM_PDZ_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_ADDR", v_COM_ADDR); //NEW_COM_ADDR
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_TEL_AREA", v_COM_TEL_AREA); //NEW_COM_TEL_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_TEL", v_COM_TEL); //NEW_COM_TEL
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_FAX_AREA", v_COM_FAX_AREA); //NEW_COM_FAX_AREA
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_COM_FAX", v_COM_FAX); //NEW_COM_FAX
            bco.UpdateVendorBase(ParameterList, DBT);

            LogHelper LOG = new LogHelper(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add("VDM01供應商主檔");//0
            ParameterList.Add(Session["UID"].ToString());//1
            ParameterList.Add("U");//2
            ParameterList.Add(dr["VENDOR"].ToString());//3
            ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

            LOG.AddSafeLog(ParameterList);

            #endregion 更新編輯後的資料

            //更新母子關係設定資料
            DataTable dtMotherOLD = bcoMonther.ConvertXMLToDataTable(MotherVendor.InnerHtml);
            DataTable dtMotherNEW = bcoMonther.ConvertXMLToDataTable(NewMotherVendor.InnerHtml);

            int i_dtMotherNEW = 0;
            for (int i = 0; i < repMOTHER_VENDOR.Items.Count; i++)
            {
                DataRow nRow = dtMotherNEW.Rows[i_dtMotherNEW];
                RepeaterItem nItem = repMOTHER_VENDOR.Items[i];
                if (((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).Text == "")
                {
                    dtMotherNEW.Rows.RemoveAt(i_dtMotherNEW);
                    
                    continue;
                }
                nRow["VENDOR_CODE"] = v_VENDOR;
                nRow["VENDOR"] = ((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).Text;
                nRow["VENDOR_NAME"] = ((TextBox)((WUI.SLP.SLP_VendorBase)nItem.FindControl("txtMOTHER_VENDOR")).FindControl("TextBoxName")).Text;
                CheckBox cbMOTHER_SINGLE_COST = (CheckBox)((WUI.SLP.SLP_Boolean)nItem.FindControl("txtMOTHER_SINGLE_COST")).FindControl("C1");
                nRow["SINGLE_COST"] = ((cbMOTHER_SINGLE_COST.Checked) ? 1 : 0);
                if (((WUI.SLP.EnumBase)nItem.FindControl("txtMOTHER_PAY_TYPE")).Text != "") nRow["PAY_TYPE"] = ((WUI.SLP.EnumBase)nItem.FindControl("txtMOTHER_PAY_TYPE")).Text;
                i_dtMotherNEW++;
            }
            for (int i = 0; i < dtMotherOLD.Rows.Count; i++)
            {
                DataRow drMotherOld = dtMotherOLD.Rows[i];
                if (dtMotherNEW.Select(string.Format("VENDOR='{0}'", drMotherOld["VENDOR"].ToString())).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drMotherOld["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PID", drMotherOld["PID"].ToString()); //OLD_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", drMotherOld["VENDOR_CODE"].ToString()); //OLD_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR", drMotherOld["VENDOR"].ToString()); //OLD_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_NAME", drMotherOld["VENDOR_NAME"].ToString()); //OLD_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "OLD_SINGLE_COST", drMotherOld["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PAY_TYPE", drMotherOld["PAY_TYPE"].ToString()); //OLD_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", (DateTime)drMotherOld["CREATEDATE"]); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", drMotherOld["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", (DateTime)drMotherOld["UPDATEDATE"]); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", drMotherOld["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DT); //NEW_UPDATEDATE
                    bcoMonther.DeleteMontherVendor(ParameterList, DBT);
                }
            }
            for (int i = 0; i < dtMotherNEW.Rows.Count; i++)
            {
                DataRow drMotherNew = dtMotherNEW.Rows[i];
                if (dtMotherOLD.Select(string.Format("VENDOR='{0}'", drMotherNew["VENDOR"].ToString())).Length == 0)
                {
                    ParameterList.Clear();
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPID", drMotherNew["PID"].ToString()); //vPID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_CODE", drMotherNew["VENDOR_CODE"].ToString()); //vVENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR", drMotherNew["VENDOR"].ToString()); //vVENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vVENDOR_NAME", drMotherNew["VENDOR_NAME"].ToString()); //vVENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "vSINGLE_COST", drMotherNew["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "vPAY_TYPE", drMotherNew["PAY_TYPE"].ToString()); //vPAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vCREATEDATE", DT); //vCREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vCREATEUID", Session["UID"].ToString()); //vCREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "vUPDATEDATE", DT); //vUPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "vUPDATEUID", Session["UID"].ToString()); //vUPDATEUID
                    if (i == (dtMotherNEW.Rows.Count - 1))
                        bcoMonther.CreateMontherVendor(ParameterList, DBT, true);
                    else
                        bcoMonther.CreateMontherVendor(ParameterList, DBT);
                }
                else
                {
                    ParameterList.Clear();
                    DataRow[] drMotherOlds = dtMotherOLD.Select(string.Format("VENDOR='{0}'", drMotherNew["VENDOR"].ToString()));
                    DataRow drMotherOld = drMotherOlds[0];
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", drMotherOld["ID"].ToString()); //OLD_ID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PID", drMotherOld["PID"].ToString()); //OLD_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_CODE", drMotherOld["VENDOR_CODE"].ToString()); //OLD_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR", drMotherOld["VENDOR"].ToString()); //OLD_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_VENDOR_NAME", drMotherOld["VENDOR_NAME"].ToString()); //OLD_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "OLD_SINGLE_COST", drMotherOld["SINGLE_COST"].ToString()); //OLD_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_PAY_TYPE", drMotherOld["PAY_TYPE"].ToString()); //OLD_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", (DateTime)drMotherOld["CREATEDATE"]); //OLD_CREATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CREATEUID", dr["CREATEUID"].ToString()); //OLD_CREATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_UPDATEDATE", (DateTime)dr["UPDATEDATE"]); //OLD_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_UPDATEUID", dr["UPDATEUID"].ToString()); //OLD_UPDATEUID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_PID", drMotherNew["PID"].ToString()); //NEW_PID
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_CODE", drMotherNew["VENDOR_CODE"].ToString()); //NEW_VENDOR_CODE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR", drMotherNew["VENDOR"].ToString()); //NEW_VENDOR
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_VENDOR_NAME", drMotherNew["VENDOR_NAME"].ToString()); //NEW_VENDOR_NAME
                    SQLHelper.SQLWhere(ref ParameterList, DbType.Decimal, "NEW_SINGLE_COST", drMotherNew["SINGLE_COST"].ToString()); //NEW_SINGLE_COST
                    SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_PAY_TYPE", drMotherNew["PAY_TYPE"].ToString()); //NEW_PAY_TYPE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DT); //NEW_UPDATEDATE
                    SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID
                    if (i == (dtMotherNEW.Rows.Count - 1))
                        bcoMonther.UpdateMontherVendor(ParameterList, DBT, true);
                    else
                        bcoMonther.UpdateMontherVendor(ParameterList, DBT);
                }
            }

            //Response.Write(string.Format("<script>alert('更改完成');location.replace('VDM012.aspx?ID={0}');</script>", v_ID));
            //Script("alert('更改完成');location.replace('VDM012.aspx?Code=VDM01&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + Request.QueryString["arl_Key"] + "&ID=" + v_ID + "');");
            
            Response.Redirect("VDM012.aspx?Code=VDM01&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + Request.QueryString["arl_Key"] + "&ID=" + v_ID + "&P=update");
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("其他使用者異動") != -1)
                Alert("更新失敗,此資料已被其他使用者異動,請重新查詢");
            else
                ErrorMsgLabel.Text = ex.Message;
        }
        finally { }

    }//end EditCommitButton_Click
Esempio n. 6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        STMModel.MaintainStoreBase STM = new STMModel.MaintainStoreBase(ConntionDB);

        #region 檢核
        //檢核必輸入欄位
        TextBox start_date = ((TextBox)((ASP.wui_slp_slp_slpdate_ascx)SLP_MDC_START_DATE).FindControl("TextBoxCode"));
        TextBox StoreChain = ((TextBox)SLP_CHAN_NO.FindControl("TextBoxCode"));
        TextBox StoreGroup = ((TextBox)SLP_GROUP_NO.FindControl("TextBoxCode"));
        TextBox tel_area = ((TextBox)((ASP.wui_slp_slp_telfax_ascx)SLP_TEL_NO).FindControl("T1"));
        TextBox tel_no = ((TextBox)((ASP.wui_slp_slp_telfax_ascx)SLP_TEL_NO).FindControl("T2"));
        TextBox fax_area = ((TextBox)((ASP.wui_slp_slp_telfax_ascx)SLP_FAX_NO).FindControl("T1"));
        TextBox fax_no = ((TextBox)((ASP.wui_slp_slp_telfax_ascx)SLP_FAX_NO).FindControl("T2"));
        TextBox AC_UID = ((TextBox)((ASP.sys_slp_slp_user_ascx)SLP_AC_UID).FindControl("TextBoxCode"));
        TextBox SAL_ID = ((TextBox)((ASP.sys_slp_slp_user_ascx)SLP_SAL_ID).FindControl("TextBoxCode"));

        TextBox[] FieldIDs ={ txtSTORE, txtSTORE_NAME, start_date, StoreChain, StoreGroup, txtSTORE_ZIP, tel_area, tel_no, fax_area, fax_no, txtSTORE_ADDRESS, AC_UID, SAL_ID };
        string[] FieldNames ={ "店號", "店名", "DC適用開始日", "配本通路", "店群", "郵遞區號", "電話區碼", "電話號碼", "傳真區碼", "傳真號碼", "地址", "帳務人員", "營業人員" };
        int i = 0;
        foreach (TextBox FieldName in FieldIDs)
        {
            if (FieldName.Text.Trim().Length == 0)
            {
                ErrorMsgLabel.Text = "必須輸入「" + FieldNames[i] + "」欄位";
                return;
            }
            i++;
        }

        //20130828 純萍 異動判斷=>特定店群不判斷店號規則
        //判斷店群
        ParameterList.Clear();
        ParameterList.Add(StoreGroup.Text.Trim());
        if (STM.ExceptionStoreGroup(ParameterList) == "0")
        {
            if (!IsNumber(txtSTORE.Text.Substring(1)) || !IsWord(txtSTORE.Text.Substring(0, 1)))
            {
                ErrorMsgLabel.Text = "店號第一碼是英文字或數字,第二碼後都要是數字 !!";
                return;
            }
        }

        //檢核長度
        if (GetStringLen(txtSTORE.Text.Trim()) > 10)
        {
            ErrorMsgLabel.Text = "店號長度限制10位 !!";
            return;
        }
        if (GetStringLen(txtSTORE_NAME.Text.Trim()) > 12)
        {
            ErrorMsgLabel.Text = "店名長度限制12位 !!";
            return;
        }
        if (GetStringLen(txtSTORE_ADDRESS.Text.Trim()) > 50)
        {
            ErrorMsgLabel.Text = "地址長度限制50位 !!";
            return;
        }
        if (GetStringLen(txtOLD_STORE.Text.Trim()) > 10)
        {
            ErrorMsgLabel.Text = "舊店號長度限制10位 !!";
            return;
        }

        //DC適用開始日檢核
        if (SLP_MDC_END_DATE.Text.Trim().Length > 0)
        {
            if (DateTime.Parse(SLP_MDC_START_DATE.Text) >= DateTime.Parse(SLP_MDC_END_DATE.Text))
            {
                ErrorMsgLabel.Text = "DC適用開始日須小於DC適用結束日 !!";
                return;
            }

            if ((SLP_MDC_END_DATE.Text.Trim().Length == 0 ? DateTime.Parse("9999/12/31") : DateTime.Parse(SLP_MDC_END_DATE.Text)) <= DateTime.Today)
            {
                ErrorMsgLabel.Text = "DC適用結束日須大於系統日 !!";
                return;
            }
        }

        //開店日期須小於關店日期
        if ((SLP_STORE_OPEN_DATE.Text != "") && (SLP_STORE_CLOSE_DATE.Text != ""))
        {
            if (DateTime.Parse(SLP_STORE_OPEN_DATE.Text) >= DateTime.Parse(SLP_STORE_CLOSE_DATE.Text))
            {
                ErrorMsgLabel.Text = "開店日期須小於關店日期 !!";
                return;
            }
        }

        //判斷配本通路
        ParameterList.Clear();
        ParameterList.Add(StoreChain.Text.Trim());
        if (STM.ValidateStoreChan(ParameterList) == "0")
        {
            ErrorMsgLabel.Text = "配本通路錯誤 !!";
            return;
        }

        //判斷店群
        ParameterList.Clear();
        ParameterList.Add(StoreGroup.Text.Trim());
        if (STM.ValidateStoreGroup(ParameterList) == "0")
        {
            ErrorMsgLabel.Text = "店群錯誤 !!";
            return;
        }

        //取得結帳統編
        if (txtPAY_RFNO.Text.Trim().Length == 0)
            txtPAY_RFNO.Text = STM.GetViutualPayRFNO();

        //取得舊店號 
        if (txtOLD_STORE.Text.Trim().Length != 0)
        {
            ParameterList.Clear();
            ParameterList.Add(txtOLD_STORE.Text.Trim());//舊門市
            ParameterList.Add(txtSTORE.Text.Trim());//門市
            if (STM.GetChargestore(ParameterList) == "0")
            {
                ErrorMsgLabel.Text = "舊店號錯誤 !!";
                return;
            }
        }

        //取得審核狀態
        if (txtPAY_RFNO.Text.Trim().Length != 0)
        {
            ParameterList.Clear();
            ParameterList.Add(txtSTORE.Text.Trim());//門市
            lblARMK.Text = "未審核";
            if (STM.GetStoreAccountInfo(ParameterList) == "1")
                lblARMK.Text = "已審核";
        }
        #endregion

        #region 新增儲存
        if (Request.QueryString["mode"] == "insert")
        {
            //判斷DC適用開始日與門市的DC適用開始日是否重疊
            ParameterList.Clear();
            ParameterList.Add(txtSTORE.Text.Trim());//門市
            ParameterList.Add(SLP_MDC_START_DATE.Text.Trim());//DC適用開始日

            if (STM.CheckDcStartData(ParameterList) == "0")
            {
                ErrorMsgLabel.Text = "門市的DC生效區間重疊 !!";
                return;
            }

            //儲存作業
            int res = 0;
            int v_ID = 0;

            #region
            try
            {
                #region 取得畫面元件的值

                TextBox txt_TELAREA = (TextBox)this.SLP_TEL_NO.FindControl("T1");
                TextBox txt_TELNO = (TextBox)this.SLP_TEL_NO.FindControl("T2");
                TextBox txt_FAXAREA = (TextBox)this.SLP_FAX_NO.FindControl("T1");
                TextBox txt_FAXNO = (TextBox)this.SLP_FAX_NO.FindControl("T2");

                CheckBox chk_DIS_SW = (CheckBox)this.SLP_DIS_SW.FindControl("C1");
                CheckBox chk_MARKET_RESEARCH = (CheckBox)this.SLP_MARKET_RESEARCH.FindControl("C1");
                CheckBox chk_SING_VEN = (CheckBox)this.SLP_SING_VEN.FindControl("C1");
                RadioButtonList rdo_MDC_TAXABLE = (RadioButtonList)this.SLP_MDC_TAXABLE.FindControl("R1");
                RadioButtonList rdo_MDC_TAXFREE = (RadioButtonList)this.SLP_MDC_TAXFREE.FindControl("R1");

                CheckBox chk_W1 = (CheckBox)this.SLP_Boolean1.FindControl("C1");
                CheckBox chk_W2 = (CheckBox)this.SLP_Boolean2.FindControl("C1");
                CheckBox chk_W3 = (CheckBox)this.SLP_Boolean3.FindControl("C1");
                CheckBox chk_W4 = (CheckBox)this.SLP_Boolean4.FindControl("C1");
                CheckBox chk_W5 = (CheckBox)this.SLP_Boolean5.FindControl("C1");
                CheckBox chk_W6 = (CheckBox)this.SLP_Boolean6.FindControl("C1");
                CheckBox chk_W7 = (CheckBox)this.SLP_Boolean7.FindControl("C1");

                DateTime processtime = DateTime.Now;

                #endregion

                #region 門市基本,配送屬性
                ParameterList.Clear();
                ParameterList.Add(string.Format("{0}{1}", this.txtSTORE.Text.Trim(), Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Year.ToString() + Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Month.ToString().PadLeft(2, '0') + Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Day.ToString().PadLeft(2, '0')));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_NAME.Text.Trim(), "string", false));
                ParameterList.Add(processtime);
                ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string", false));
                ParameterList.Add(processtime);
                ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_MDC_START_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_MDC_END_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_NAME.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_CHAN_NO.Text, "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_GROUP_NO.Text, "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtOLD_STORE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_OPEN_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_CLOSE_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_REOPEN_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_REMODEL_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_Z_O.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_D_O.Text.Trim(), "string", false)); ;
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_TYPE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_ZIP.Text.Trim(), "string", false));
                ParameterList.Add(txt_TELAREA.Text.Trim());
                ParameterList.Add(txt_TELNO.Text.Trim());
                ParameterList.Add(txt_FAXAREA.Text.Trim());
                ParameterList.Add(txt_FAXNO.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_ADDRESS.Text.Trim(), "string", false));

                ParameterList.Add(GetValueSetParameter(this.SLP_AREA_NO.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_AREA_CODE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_SHELVE_CM3.Text, "int", false));
                ParameterList.Add(chk_DIS_SW.Checked ? 1 : 0);
                ParameterList.Add(GetValueSetParameter(this.SLP_ALLOCATION_TIMES.Text, "int", false));
                ParameterList.Add(chk_MARKET_RESEARCH.Checked ? 1 : 0);
                ParameterList.Add(this.SLP_AC_UID.Text.Trim());
                ParameterList.Add(this.SLP_SAL_ID.Text.Trim());
                ParameterList.Add(this.SLP_FEAT_GRADE.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.txtPAY_RFNO.Text.Trim(), "string", false));
                ParameterList.Add(chk_SING_VEN.Checked ? 1 : 0);
                if (rdo_MDC_TAXABLE.SelectedValue == "1")
                    ParameterList.Add(1);
                else
                    ParameterList.Add(0);
                if (rdo_MDC_TAXFREE.SelectedValue == "1")
                    ParameterList.Add(1);
                else
                    ParameterList.Add(0);

                ParameterList.Add(this.txtVIRTUAL_FLAG.Text.Trim());

                #endregion

                #region 屬性
                ParameterList.Add(this.txtSTORE.Text.Trim());
                ParameterList.Add(this.txtSTORE_NAME.Text.Trim());
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(this.txtSTORE.Text.Trim());
                ParameterList.Add(this.txtCOPY_SOURCE.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.SLP_PSM.Text, "int", false));
                ParameterList.Add(this.SLP_BUSINESS_NO.Text.Trim());
                ParameterList.Add(this.SLP_OPEN_TIME.Text.Trim());
                ParameterList.Add(this.SLP_CLOSE_TIME.Text.Trim());
                ParameterList.Add(this.SLP_COMPETITION.Text.Trim());
                ParameterList.Add(this.SLP_REMARK.Text.Trim());
                ParameterList.Add(this.SLP_STORE_SPE.Text.Trim());
                ParameterList.Add(chk_W1.Checked ? 1 : 0);
                ParameterList.Add(chk_W2.Checked ? 1 : 0);
                ParameterList.Add(chk_W3.Checked ? 1 : 0);
                ParameterList.Add(chk_W4.Checked ? 1 : 0);
                ParameterList.Add(chk_W5.Checked ? 1 : 0);
                ParameterList.Add(chk_W6.Checked ? 1 : 0);
                ParameterList.Add(chk_W7.Checked ? 1 : 0);
                #endregion

                #region 貨架設置

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

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        dr.BeginEdit();
                        dr["CODE"] = txtSTORE.Text + dr["SHELF_NO"].ToString();
                        dr["NAME"] = txtSTORE_NAME.Text;
                        dr["STORE"] = txtSTORE.Text;
                        dr.EndEdit();
                    }
                }

                #endregion

                STMModel.MaintainStoreBase BCO = new STMModel.MaintainStoreBase(ConnectionDB);

                v_ID = BCO.CreateStoreBase(ParameterList, null, ds.Tables[0]);

                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("STM01門市主檔");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("I");//2
                ParameterList.Add(txtSTORE.Text.Trim());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                if (v_ID == 0)
                {
                    throw new Exception("新增0筆資料!");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel11, this.GetType(), "ClientScript", "alert('新增完成');location.replace('STM012.aspx?mode=view&store=" + txtSTORE.Text + "&date=" + SLP_MDC_START_DATE.Text + "&Code=STM01');", true);
                }
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            }
            #endregion
        }
        #endregion

        #region 更新儲存
        else if (Request.QueryString["mode"] == "view")
        {

            //儲存作業
            int res = 0;
            int v_ID = 0;
            int v_Code = 0;   //0:nothing 1:insert 2:update

            #region
            try
            {
                #region 取得畫面元件的值

                TextBox txt_TELAREA = (TextBox)this.SLP_TEL_NO.FindControl("T1");
                TextBox txt_TELNO = (TextBox)this.SLP_TEL_NO.FindControl("T2");
                TextBox txt_FAXAREA = (TextBox)this.SLP_FAX_NO.FindControl("T1");
                TextBox txt_FAXNO = (TextBox)this.SLP_FAX_NO.FindControl("T2");

                CheckBox chk_DIS_SW = (CheckBox)this.SLP_DIS_SW.FindControl("C1");
                CheckBox chk_MARKET_RESEARCH = (CheckBox)this.SLP_MARKET_RESEARCH.FindControl("C1");
                CheckBox chk_SING_VEN = (CheckBox)this.SLP_SING_VEN.FindControl("C1");
                RadioButtonList rdo_MDC_TAXABLE = (RadioButtonList)this.SLP_MDC_TAXABLE.FindControl("R1");
                RadioButtonList rdo_MDC_TAXFREE = (RadioButtonList)this.SLP_MDC_TAXFREE.FindControl("R1");

                CheckBox chk_W1 = (CheckBox)this.SLP_Boolean1.FindControl("C1");
                CheckBox chk_W2 = (CheckBox)this.SLP_Boolean2.FindControl("C1");
                CheckBox chk_W3 = (CheckBox)this.SLP_Boolean3.FindControl("C1");
                CheckBox chk_W4 = (CheckBox)this.SLP_Boolean4.FindControl("C1");
                CheckBox chk_W5 = (CheckBox)this.SLP_Boolean5.FindControl("C1");
                CheckBox chk_W6 = (CheckBox)this.SLP_Boolean6.FindControl("C1");
                CheckBox chk_W7 = (CheckBox)this.SLP_Boolean7.FindControl("C1");

                DateTime processtime = DateTime.Now;

                #endregion

                #region 門市基本,配送屬性
                ParameterList.Clear();
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["CREATEUID"].ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["UPDATEUID"].ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["STORE"].ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["MDC_START_DATE"].ToString(), "date", false));
                ParameterList.Add(string.Format("{0}{1}", this.txtSTORE.Text.Trim(), Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Year.ToString() + Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Month.ToString().PadLeft(2, '0') + Convert.ToDateTime(this.SLP_MDC_START_DATE.Text).Day.ToString().PadLeft(2, '0')));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_NAME.Text.Trim(), "string", false));
                ParameterList.Add(processtime);
                ParameterList.Add(GetValueSetParameter(Session["UID"].ToString(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_MDC_START_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_MDC_END_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_NAME.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_CHAN_NO.Text, "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_GROUP_NO.Text, "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtOLD_STORE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_OPEN_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_CLOSE_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_REOPEN_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_REMODEL_DATE.Text, "date", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_Z_O.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_D_O.Text.Trim(), "string", false)); ;
                ParameterList.Add(GetValueSetParameter(this.SLP_STORE_TYPE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_ZIP.Text.Trim(), "string", false));
                ParameterList.Add(txt_TELAREA.Text.Trim());
                ParameterList.Add(txt_TELNO.Text.Trim());
                ParameterList.Add(txt_FAXAREA.Text.Trim());
                ParameterList.Add(txt_FAXNO.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.txtSTORE_ADDRESS.Text.Trim(), "string", false));
                ParameterList.Add(this.txtVIRTUAL_FLAG.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.SLP_AREA_NO.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_AREA_CODE.Text.Trim(), "string", false));
                ParameterList.Add(GetValueSetParameter(this.SLP_SHELVE_CM3.Text, "int", false));
                ParameterList.Add(chk_DIS_SW.Checked ? 1 : 0);
                ParameterList.Add(GetValueSetParameter(this.SLP_ALLOCATION_TIMES.Text, "int", false));
                ParameterList.Add(chk_MARKET_RESEARCH.Checked ? 1 : 0);
                ParameterList.Add(this.SLP_AC_UID.Text.Trim());
                ParameterList.Add(this.SLP_SAL_ID.Text.Trim());
                ParameterList.Add(this.SLP_FEAT_GRADE.Text.Trim());
                ParameterList.Add(GetValueSetParameter(this.txtPAY_RFNO.Text.Trim(), "string", false));
                ParameterList.Add(chk_SING_VEN.Checked ? 1 : 0);
                if (rdo_MDC_TAXABLE.SelectedValue == "1")
                    ParameterList.Add(1);
                else
                    ParameterList.Add(0);
                if (rdo_MDC_TAXFREE.SelectedValue == "1")
                    ParameterList.Add(1);
                else
                    ParameterList.Add(0);

                
                #endregion

                #region 屬性
                //判斷屬性是否有資料
                if (ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows.Count == 0)
                {
                    //判斷是否有輸入資料
                    if (this.txtCOPY_SOURCE.Text.Trim() != "" || this.SLP_PSM.Text != "" || this.SLP_BUSINESS_NO.Text != "" ||
                        this.SLP_OPEN_TIME.Text != "" || this.SLP_CLOSE_TIME.Text != "" || this.SLP_COMPETITION.Text != "" ||
                        this.SLP_REMARK.Text != "" || this.SLP_STORE_SPE.Text != "" ||
                        chk_W1.Checked || chk_W2.Checked || chk_W3.Checked || chk_W4.Checked || chk_W5.Checked || chk_W6.Checked || chk_W7.Checked)
                    {
                        //新增資料
                        v_Code = 1;
                        ParameterList.Add(this.txtSTORE.Text.Trim());
                        ParameterList.Add(this.txtSTORE_NAME.Text.Trim());
                        ParameterList.Add(processtime);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(processtime);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(this.txtSTORE.Text.Trim());
                        ParameterList.Add(this.txtCOPY_SOURCE.Text.Trim());
                        ParameterList.Add(GetValueSetParameter(this.SLP_PSM.Text, "int", false));
                        ParameterList.Add(this.SLP_BUSINESS_NO.Text.Trim());
                        ParameterList.Add(this.SLP_OPEN_TIME.Text.Trim());
                        ParameterList.Add(this.SLP_CLOSE_TIME.Text.Trim());
                        ParameterList.Add(this.SLP_COMPETITION.Text.Trim());
                        ParameterList.Add(this.SLP_REMARK.Text.Trim());
                        ParameterList.Add(this.SLP_STORE_SPE.Text.Trim());
                        ParameterList.Add(chk_W1.Checked ? 1 : 0);
                        ParameterList.Add(chk_W2.Checked ? 1 : 0);
                        ParameterList.Add(chk_W3.Checked ? 1 : 0);
                        ParameterList.Add(chk_W4.Checked ? 1 : 0);
                        ParameterList.Add(chk_W5.Checked ? 1 : 0);
                        ParameterList.Add(chk_W6.Checked ? 1 : 0);
                        ParameterList.Add(chk_W7.Checked ? 1 : 0);
                    }
                }
                else
                {
                    //更新資料
                    v_Code = 2;
                    ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows[0]["CREATEDATE"].ToString(), "datetime", false));
                    ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows[0]["CREATEUID"].ToString(), "string", false));
                    ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows[0]["UPDATEDATE"].ToString(), "datetime", false));
                    ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows[0]["UPDATEUID"].ToString(), "string", false));
                    ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE_PROPERTY"].Rows[0]["STORE"].ToString(), "string", false));

                    ParameterList.Add(this.txtSTORE_NAME.Text.Trim());
                    ParameterList.Add(processtime);
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(this.txtSTORE.Text.Trim());
                    ParameterList.Add(this.txtCOPY_SOURCE.Text.Trim());
                    ParameterList.Add(GetValueSetParameter(this.SLP_PSM.Text, "int", false));
                    ParameterList.Add(this.SLP_BUSINESS_NO.Text.Trim());
                    ParameterList.Add(this.SLP_OPEN_TIME.Text.Trim());
                    ParameterList.Add(this.SLP_CLOSE_TIME.Text.Trim());
                    ParameterList.Add(this.SLP_COMPETITION.Text.Trim());
                    ParameterList.Add(this.SLP_REMARK.Text.Trim());
                    ParameterList.Add(this.SLP_STORE_SPE.Text.Trim());
                    ParameterList.Add(chk_W1.Checked ? 1 : 0);
                    ParameterList.Add(chk_W2.Checked ? 1 : 0);
                    ParameterList.Add(chk_W3.Checked ? 1 : 0);
                    ParameterList.Add(chk_W4.Checked ? 1 : 0);
                    ParameterList.Add(chk_W5.Checked ? 1 : 0);
                    ParameterList.Add(chk_W6.Checked ? 1 : 0);
                    ParameterList.Add(chk_W7.Checked ? 1 : 0);
                }
                #endregion

                #region 貨架設置



                DataSet ds = (DataSet)Session["STM012_" + PageTimeStamp.Value];
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        dr.BeginEdit();
                        dr["NAME"] = txtSTORE_NAME.Text;
                        dr.EndEdit();
                    }
                }

                #endregion

                STMModel.MaintainStoreBase BCO = new STMModel.MaintainStoreBase(ConnectionDB);

                BCO.UpdateStoreBase(ParameterList, null, ds.Tables[0], v_Code);

                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("STM01門市主檔");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("U");//2
                ParameterList.Add(GetValueSetParameter(ds_Data.Tables["VDS_STM_STORE"].Rows[0]["STORE"].ToString(), "string", false));//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                int i_Count = 0;
                string s_Request_Key = "";
                if (Request.QueryString["STM012_COUNT"] != null)
                {
                    i_Count = int.Parse(Request.QueryString["STM012_COUNT"]);
                    s_Request_Key = Request.QueryString["STM012_PageTimeStamp"];
                }

                ScriptManager.RegisterStartupScript(UpdatePanel11, this.GetType(), "ClientScript", "alert('更新完成');location.replace('STM012.aspx?mode=view&store=" + txtSTORE.Text + "&date=" + SLP_MDC_START_DATE.Text + "&Code=STM01&STM012_COUNT=" + i_Count.ToString() + "&STM012_PageTimeStamp=" + s_Request_Key + "');", true);
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
            }
            #endregion

        }
        #endregion

        //儲存完成後變成檢視模式
        ReadOnlyMode(false);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "STM011.aspx?Code=STM01", null, WUI_GMToolbarV.ClickAction.LinkURL);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.FindExport, true, "", this.btnStorePrint, WUI_GMToolbarV.ClickAction.ButtonClick);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.New, false, string.Empty, this.btnEdt, WUI_GMToolbarV.ClickAction.ButtonClick);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, string.Empty, this.btnSave, WUI_GMToolbarV.ClickAction.ButtonClick);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, string.Empty, this.btnEdt, WUI_GMToolbarV.ClickAction.ButtonClick);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Delete, true, string.Empty, this.btnDelete, WUI_GMToolbarV.ClickAction.ButtonClick);
        GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, true, string.Empty, this.btnCopy, WUI_GMToolbarV.ClickAction.ButtonClick);
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            //驗證SESSION過期和登入狀態

            //this.CheckLogin(ref vdb);
            AuthorityControls(this);
            SetAuthCRUD();
            SetAuthority();//判斷功能權限
            if (!IsPostBack)
            {
                //TextBox txtD_O = (TextBox)this.SLP_D_O.FindControl("TextBoxCode");
                //DropDownList ddlSTORE_TYPE = (DropDownList)this.SLP_STORE_TYPE.FindControl("D1");
                //txtD_O.Attributes["onblur"] = "document.getElementById('" + ddlSTORE_TYPE.ClientID + "').focus();";  

                //寫入首次載入Page TimeStamp
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                    DateTime.Now.Year.ToString(),
                                                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                    );

                SLP_SHELF_NO_Add.ReadOnly = true;
                SLP_SHELVE_CM3_Add.ReadOnly = true;
                SLP_DISPLAY_NUM_Add.ReadOnly = true;

                ToolBarInit();
                this.btnDelete.Attributes.Add("onclick", "return Check_Store_Save();");

                #region 新增DataSet
                //新增DataSet
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                DataColumn[] keys = new DataColumn[2];

                ds.Tables.Add(dt);
                dt.Columns.Add("CODE", Type.GetType("System.String"));//VARCHAR2(50)代號(STORE+SHELF_NO)
                dt.Columns.Add("NAME", Type.GetType("System.String"));//VARCHAR2(50)名稱(店名)
                dt.Columns.Add("STORE", Type.GetType("System.String"));//VARCHAR2(10)門市@
                dt.Columns.Add("SHELF_NO", Type.GetType("System.String"));//VARCHAR2(2)貨架代號@
                dt.Columns.Add("SHELVE_CM3", Type.GetType("System.Int16"));//NUMBER(3)貨架尺寸@個貨架長cm*寬cm*高cm合計
                dt.Columns.Add("DISPLAY_NUM", Type.GetType("System.Int16"));//NUMBER(3)可陳列數
                dt.Columns.Add("CREATEDATE");
                dt.Columns.Add("CREATEUID");
                dt.Columns.Add("UPDATEDATE");
                dt.Columns.Add("UPDATEUID");

                dt.Columns["STORE"].AllowDBNull = false;
                dt.Columns["SHELF_NO"].AllowDBNull = false;

                keys[0] = dt.Columns["STORE"];
                keys[1] = dt.Columns["SHELF_NO"];
                dt.PrimaryKey = keys;

                string SessionIDName = "STM012_" + PageTimeStamp.Value;
                Session[SessionIDName] = ds;

                #endregion

                //模式指定
                string mode = "";
                mode = Request.QueryString["mode"].ToString();
                if (mode == "view")
                {
                    QueryData(Request.QueryString["store"].ToString(), Request.QueryString["date"].ToString());

                    LogHelper LOG = new LogHelper(ConnectionDB);
                    ParameterList.Clear();
                    ParameterList.Add("STM01門市主檔");//0
                    ParameterList.Add(Session["UID"].ToString());//1
                    ParameterList.Add("Q");//2
                    ParameterList.Add(Request.QueryString["store"].ToString());//3
                    ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                    LOG.AddSafeLog(ParameterList);

                    ReadOnlyMode(false);
                    btnConfirm.Enabled = false; //確認
                    btnCancle.Enabled = false; //取消 
                    lblEFF_DATE_TO.Visible = true;
                    txtEFF_DATE_TO.Visible = true;
                }
                if (mode == "insert")
                {
                    if (Request.QueryString["store"] != null && Request.QueryString["date"] != null) //複製新增
                    {
                        QueryData(Request.QueryString["store"].ToString(), Request.QueryString["date"].ToString());
                        this.txtSTORE.Text = string.Empty;
                        SetClinetFocus(txtSTORE.ClientID);
                    }
                    ReadOnlyMode(true);
                    btnCancel.Visible = false;//取消
                    btnAcctCancle.Visible = true; //取消(回查詢頁
                    lblEFF_DATE_TO.Visible = false;
                    txtEFF_DATE_TO.Visible = false;
                    txtVIRTUAL_FLAG.Text = "0";
                }
                if (lblARMK.Text == "已審核")
                {
                    btnEdt.Enabled = false; //編輯
                    btnDelete.Enabled = false;  //刪除               
                }
            }

            #region 重取DO NAME
            if (SLP_D_O.Text.Length > 0)
            {
                string strDoName = GetDoName();
                TextBox txtDoName = ((TextBox)SLP_D_O.FindControl("TextBoxName"));
                string strJS = @"function CAACommon_set_Focus() 
                              {
                                try 
                                {
                                    document.getElementById('" + txtDoName.ClientID + "').value='" + strDoName + "';";

                strJS += @"
                                }
                                catch(err){setTimeout('CAACommon_set_Focus()', 100);}
                              }

                            CAACommon_set_Focus( );";

                ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, typeof(UpdatePanel), "", strJS, true);
            }
            #endregion

            #region 預設Focus欄位

            STMModel.STMCommon STMComm = new STMModel.STMCommon();
            string s_ScriptManager_Script = STMComm.ToMakeUp_SetFocus_Script(txtSTORE.ClientID, false);
            ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "STM012", s_ScriptManager_Script, true);

            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally { Finally_Function(); }
    }//Page_Load
Esempio n. 8
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        try
        {
            Add_Parameter("EXPORT");
            MaintainVendorBase BCO = new MaintainVendorBase(ConntionDB);
            LogHelper LOG = new LogHelper(ConntionDB);

            DataTable Dt = BCO.QueryVendorBaseByFind_2(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                if (Dt.Columns["ID"] != null) Dt.Columns.Remove("ID");
                if (Dt.Columns["CODE"] != null) Dt.Columns.Remove("CODE");
                if (Dt.Columns["ENABLE"] != null) Dt.Columns.Remove("ENABLE");
                foreach (DataRow dr in Dt.Rows)
                {
                    ParameterList.Clear();
                    ParameterList.Add("VDM01供應商主檔");//0
                    ParameterList.Add(Session["UID"].ToString());//1
                    ParameterList.Add("O");//2
                    ParameterList.Add(dr["廠商編號"].ToString());//3
                    ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                    LOG.AddSafeLog(ParameterList);

                    for (int i = 0; i < Dt.Columns.Count; i++)
                    {
                        if (Dt.Columns[i].DataType == Type.GetType("System.String"))
                        {
                            dr[i] = string.Format("&nbsp;{0}", dr[i].ToString());
                        }
                    }

                }
                Export(System.Text.Encoding.UTF8, "供應商主檔_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls", "application/ms-excel", Dt);
            }
            else
            {
                Alert("查無資料");
                return; 
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
Esempio n. 9
0
    /// <summary>
    /// 於檢視模式,按下刪除鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            int DeleteRecord = 0;

            #region 取得畫面元件的值
            DateTime processtime = DateTime.Now;

            #endregion

            #region 取得刪除前舊值


            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;

            #endregion

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();
            //舊值

            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["PASSWORD"]);
            ParameterList.Add(Dt.Rows[0]["MEMO"]);
            //需要更新值

            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            #endregion

            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

            DeleteRecord = BCO.DeleteUser(ParameterList, null);

            if (DeleteRecord == 0)
            {
                throw new Exception("刪除失敗!");
            }
            else
            {
                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("U");//2
                ParameterList.Add(Dt.Rows[0]["CODE"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                Response.Write("<script>alert('刪除完成');location.replace('SYS041.aspx?Code=SYS04');</script>");
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Esempio n. 10
0
    }//end EditCancelButton_Click

    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";
            int UpdateRecord = 0;

            #region 取得畫面元件的值

            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;          
            string v_Memo = ((TextBox)FormView1.FindControl("TextBoxMemo")).Text.Trim();
            string v_Password = ((TextBox)FormView1.FindControl("TextBoxPassword")).Text.Trim();

            if (v_Password.Length <8)
                throw new Exception("密碼長度不足8碼!");

            //密碼加密
            SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
            string CryPassword = Cry.Encrypt(v_Password);

            #endregion

            #region 取得更新前舊值

            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();
            DataTable Dt = dt_Result;

            #endregion

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();

            //舊值
            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["PASSWORD"]);
            ParameterList.Add(Dt.Rows[0]["MEMO"]);

            //需要更新值
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());           
            ParameterList.Add(CryPassword);
            ParameterList.Add(v_Memo);

            #endregion

            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

            UpdateRecord = BCO.UpdateUser(ParameterList, null);

            if (UpdateRecord == 0)
            {
                throw new Exception("更新0筆資料!");
            }
            else
            {
                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("U");//2
                ParameterList.Add(Dt.Rows[0]["CODE"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);

                //ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "SYS042", string.Format("<script>alert('更改完成');location.replace('SYS042.aspx?mode=readonly&ID={0}');</script>", Dt.Rows[0]["ID"].ToString()),false);
                Response.Write(string.Format("<script>alert('更改完成');location.replace('SYS042.aspx?mode=readonly&ID={0}');</script>", Dt.Rows[0]["ID"].ToString()));
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Esempio n. 11
0
    }//end InsertCancelButton_Click


    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        try
        {
            int AddRecord = 0;
            ErrorMsgLabel.Text = "";

            #region 取得畫面元件的值

            string v_Code = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            //string v_Organizationcode = ((WUI.SLP.Organization)FormView1.FindControl("TextBoxOrganizationCode")).Text.Trim();
            string v_Password = ((TextBox)FormView1.FindControl("TextBoxPassword")).Text.Trim();
            string v_Memo = ((TextBox)FormView1.FindControl("TextBoxMemo")).Text.Trim();

            if (v_Password.Length < 8)
                throw new Exception("密碼長度不足8碼!");

            //密碼加密
            SYSModel.CryptographyHelper Cry = new SYSModel.CryptographyHelper();
            string CryPassword = Cry.Encrypt(v_Password);

            ParameterList.Clear();
            SYSModel.MaintainProgram Uniq = new SYSModel.MaintainProgram(ConnectionDB);
            ParameterList.Add(v_Code);
            ParameterList.Add("SYS_USER");
            ParameterList.Add("CODE");
            ParameterList.Add("");
            DataTable Dup = Uniq.QuerySwitch(SYSModel.MaintainProgram.QueryType.Duplicate,
                                         ParameterList
                                         );
            if (Dup.Rows.Count > 0)
            {
                if (Dup.Rows[0]["ENABLE"].ToString() == "1")
                {
                    throw new Exception("資料重覆!");
                }
            }
            #endregion

            #region 加入輸入條件

            ParameterList.Clear();

            ParameterList.Add(v_Code);
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);               //vCreateDate
            ParameterList.Add(Session["UID"].ToString()); //vCreateUID
            ParameterList.Add(processtime);               //vUpdateDate
            ParameterList.Add(Session["UID"].ToString()); //vUpdateUID
            //ParameterList.Add(v_Organizationcode);
            ParameterList.Add(CryPassword);
            ParameterList.Add(v_Memo);

            #endregion

            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);
            AddRecord = BCO.CreateUser(ParameterList, null);

            if (AddRecord == 0)
            {
                throw new Exception("新增0筆資料!");
            }
            else
            {
                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("I");//2
                ParameterList.Add(v_Code);//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);
                Response.Write("<script>alert('新增完成');location.replace('SYS042.aspx?mode=readonly&ID=" + AddRecord + "');</script>");
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Esempio n. 12
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind(FormViewMode fvm)
    {
        try
        {
            SYSModel.MaintainUser BCO = new SYSModel.MaintainUser(ConnectionDB);

            ParameterList.Clear();         
            if (Request["ID"] != null)
                ParameterList.Add(Request["ID"].ToString());
            else
                ParameterList.Add("0");


            dt_Result = BCO.QuerySwitch(SYSModel.MaintainUser.QueryType.ID,
                                           ParameterList
                                           );
            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();

                FormView1.DataSource = dt_Result;
                FormView1.DataBind();

                if (dt_Result.Rows[0]["ENABLE"].ToString() == "0")
                {
                    ((Button)FormView1.FindControl("EditButton")).Visible = false;
                    ((Button)FormView1.FindControl("DeleteButton")).Visible = false;
                }

                LogHelper LOG = new LogHelper(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add("SYS04人員");//0
                ParameterList.Add(Session["UID"].ToString());//1
                ParameterList.Add("Q");//2
                ParameterList.Add(dt_Result.Rows[0]["CODE"].ToString());//3
                ParameterList.Add(Request.ServerVariables["Server_Name"]);//4

                LOG.AddSafeLog(ParameterList);
            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:
                    ToolBarStatus("edit");
                    TextBox txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname.Visible = false;
                    break;
                case FormViewMode.Insert:
                    ToolBarStatus("insert");
                    break;
                case FormViewMode.ReadOnly:
                    ToolBarStatus("readonly");
                    TextBox txtname1 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname1.Visible = false;
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }//databind