protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            #region 清空Message

            this.ErrorMsgLabel.Text = string.Empty;
            this.RightMsgLabel.Text = string.Empty;

            #endregion

            if (!IsPostBack)
            {
                #region Attributes

                this.but_Close.Attributes["onclick"] += "window.close();";

                #endregion

                #region 取得異常資料

                #region 傳入參數

                ParameterList.Clear();
                ParameterList.Add(Session["UID"].ToString());

                #endregion

                #region 連結資料庫

                BCO.MaintainPreItem bco = new BCO.MaintainPreItem(ConntionDB);
                DataTable dt_Return = bco.QUERYERRORBYFIND(ParameterList);

                #endregion

                #region 檢查回傳資料

                if (dt_Return.Rows.Count == 0)
                {
                    this.ErrorMsgLabel.Text = "查無資料";
                    return;
                }
                else
                {
                    this.gv_Result.DataSource = dt_Return;
                    this.gv_Result.DataBind();
                }

                #endregion

                #endregion
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = string.Empty;
            if (!IsPostBack)
            {
                ViewState["ID"] = "";
                ViewState["UPDATEDATE"] = "";
                ViewState["UPDATEUID"] = "";
                btnSave.Enabled = false;

                this.btnCancel.Attributes["onclick"] += "window.close();";

                if (Request.QueryString["ID"] == null)
                {
                    this.ErrorMsgLabel.Text = "ID參數為NULL";
                    return;
                }
                string strID = Request.QueryString["ID"].ToString();

                BCO.MaintainPreItem bco = new BCO.MaintainPreItem(ConntionDB);
                ParameterList.Clear();
                ParameterList.Add(int.Parse(strID));
                DataTable dtData = bco.QueryPreItemByID(ParameterList);

                if (dtData.Rows.Count == 0)
                {
                    this.ErrorMsgLabel.Text = "查無資料";
                    return;
                }
                else
                {
                    lblITEM.Text = dtData.Rows[0]["ITEM"].ToString();
                    lblITEM_NAME.Text = dtData.Rows[0]["ITEM_NAME"].ToString();
                    txtRETURN_MEMO.Text = "";
                    btnSave.Enabled = true;
                    ViewState["ID"] = strID;
                    ViewState["UPDATEDATE"] = dtData.Rows[0]["UPDATEDATE"].ToString();
                    ViewState["UPDATEUID"] = dtData.Rows[0]["UPDATEUID"].ToString();
                }
            }
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
 public SLP_PreItem()
 {
     co_main = new MaintainSKU(ConntionDB);
     co_PreItem = new MaintainPreItem(ConntionDB); 
 }
Example #4
0
    protected void GridView1_RowCommand(Object sender, GridViewDeleteEventArgs e)
    {
        int index = Convert.ToInt32(e.RowIndex);

        string v_ID = GridView1.DataKeys[index].Value.ToString();
        ParameterList.Clear();
        ParameterList.Add(v_ID);
        DataTable dt = bco.QueryItemClassifyByID(ParameterList);
        if (dt.Rows.Count == 0)
        {
            ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者刪除,請重新查詢";
            return;
        }
        // Display the selected author.
        int res = 0;
        try
        {
            ParameterList.Clear();
            DataRow dr = dt.Rows[0];

            MaintainSKU bcoSKU = new MaintainSKU(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and");
            DataTable dtExists = bcoSKU.QuerySKUByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法刪除");
                return;
            }
            MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and");
            dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法刪除");
                return;
            }
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //NEW_UPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID

            bco.DeleteItemClassify(ParameterList, null);

            Page currentPage = (Page)HttpContext.Current.Handler;
            string name = "alert";
            string script = "alert('資料已刪除');location.replace('ITM241.aspx?Code=ITM24');";
            ScriptManager.RegisterClientScriptBlock(currentPage, currentPage.GetType(), name, script, true);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }

    }
Example #5
0
    /// <summary>
    /// 編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        int res = 0;
        try
        {
            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.QueryItemClassifyByFind_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 取得畫面元件的值

            string v_ID = ((TextBox)FormView1.FindControl("TextBoxID")).Text.Trim();
            string v_ITEM_LAYER = ((RadioButtonList)FormView1.FindControl("rblITEM_LAYER")).Text.Trim();
            string v_CODE = ((TextBox)FormView1.FindControl("txtCODE")).Text.Trim();
            string v_NAME = ((TextBox)FormView1.FindControl("txtNAME")).Text.Trim();
            string v_PATTERN_NAME = ((TextBox)FormView1.FindControl("txtPATTERN_NAME")).Text.Trim();
            string v_PATTERN_ALIAS = ((TextBox)FormView1.FindControl("txtPATTERN_ALIAS")).Text.Trim();
            object v_PARENTCODE = null;
            string v_PATTERN_NO = "";
            switch (v_ITEM_LAYER)
            {
                case "0":
                    if (v_CODE.Length != 1)
                    {
                        ErrorMsgLabel.Text = "群分類代碼須為一位";
                        return;
                    }
                    v_PATTERN_NO = string.Format("{0}", v_CODE);
                    break;
                case "1":
                    v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlROOTNO")).Text.Trim();
                    if (v_CODE.Length != 2)
                    {
                        ErrorMsgLabel.Text = "大分類代碼須為兩位";
                        return;
                    }
                    if (v_PARENTCODE.ToString().Length == 0)
                    {
                        ErrorMsgLabel.Text = "未選擇群分類";
                        return;
                    }
                    v_PATTERN_NO = string.Format("{0}{1}",
                        v_PARENTCODE.ToString().Substring(0, 1),
                        v_CODE);
                    break;
                case "2":
                    if (v_CODE.Length != 2)
                    {
                        ErrorMsgLabel.Text = "中分類代碼須為兩位";
                        return;
                    }
                    if (((DropDownList)FormView1.FindControl("ddlPMA")).Text.Trim() == "")
                        v_PARENTCODE = dt.Rows[0]["PARENTCODE"].ToString();
                    else
                        v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlPMA")).Text.Trim();
                    v_PATTERN_NO = string.Format("{0}{1}",
                            v_PARENTCODE.ToString().Substring(0, 3),
                            v_CODE);
                    break;
                case "3":
                    if (v_CODE.Length != 2)
                    {
                        ErrorMsgLabel.Text = "小分類代碼須為兩位";
                        return;
                    }
                    if (((DropDownList)FormView1.FindControl("ddlCATEGORY")).Text.Trim() == "")
                        v_PARENTCODE = dt.Rows[0]["PARENTCODE"].ToString();
                    else
                        v_PARENTCODE = ((DropDownList)FormView1.FindControl("ddlCATEGORY")).Text.Trim();

                    v_PATTERN_NO = string.Format("{0}{1}",
                        v_PARENTCODE.ToString().Substring(0, 5),
                        v_CODE);
                    break;
            }
            #endregion 取得畫面元件的值

            #region 資料檢查
            if (v_CODE == "") { Alert("分類代碼不可空白"); return; }
            if (v_NAME == "") { Alert("代碼名稱不可空白"); return; }
            if (v_PATTERN_NO == "") { Alert("Pattern代碼不可空白"); return; }
            if (v_ITEM_LAYER == "") { Alert("所屬層級不可空白"); return; }
            if (Get_Byte_Length(v_PATTERN_NAME) > 30) { Alert("欄位[Pattern名稱]長度不可大於 30 Byte"); return; }
            if (Get_Byte_Length(v_PATTERN_ALIAS) > 10) { Alert("欄位[Pattern簡稱]長度不可大於 10 Byte"); return; }

            if (dr["ITEM_LAYER"].ToString() == "3")
            {
                ParameterList.Clear();
                ParameterList.Add(dr["ID"].ToString());
                bool IsExist = bco.CheckInUseItem(ParameterList);
                if (IsExist == true)
                {
                    Alert("PATTERN_NO使用中,無法修改");
                    return;
                }
                IsExist = bco.CheckInUsePreItem(ParameterList);
                if (IsExist == true)
                {
                    Alert("PATTERN_NO使用中,無法修改");
                    return;
                }
            }
            else
            {
                ParameterList.Clear();
                ParameterList.Add(dr["ID"].ToString());
                bool IsExist = bco.CheckSubItemExist(ParameterList);
                if (IsExist == true)
                {
                    Alert("子項目已存在,無法修改");
                    return;
                }
            }

            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", v_PATTERN_NO, "=", "and");
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString(), "<>", "and");
            DataTable dtExists = bco.QueryItemClassifyByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("Pattern代碼已經存在");
                return;
            }
            MaintainSKU bcoSKU = new MaintainSKU(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", v_PATTERN_NO + "%", "like", "and");
            dtExists = bcoSKU.QuerySKUByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法修改");
                return;
            }
            MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(DBNull.Value); //N_ID
            ParameterList.Add(DBNull.Value); //V_ITEM
            ParameterList.Add(v_PATTERN_NO + "%"); //V_PATTERN_NO                  
            dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法修改");
                return;
            }
            #endregion

            ParameterList.Clear();

            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_CODE", dr["CODE"].ToString()); //OLD_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_NAME", dr["NAME"].ToString()); //OLD_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_NO", dr["PATTERN_NO"].ToString()); //OLD_PATTERN_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_ALIAS", dr["PATTERN_ALIAS"].ToString()); //OLD_PATTERN_ALIAS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PARENTCODE", dr["PARENTCODE"].ToString()); //OLD_PARENTCODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ITEM_LAYER", dr["ITEM_LAYER"].ToString()); //OLD_ITEM_LAYER
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_PATTERN_NAME", dr["PATTERN_NAME"].ToString()); //OLD_PATTERN_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "OLD_MEMO", dr["MEMO"].ToString()); //OLD_MEMO
            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, "OLD_CREATEUID", dr["CREATEUID"].ToString()); //OLD_CREATEUID
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "OLD_CREATEDATE", dr["CREATEDATE"].ToString()); //OLD_CREATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ENABLE", dr["ENABLE"].ToString()); //OLD_ENABLE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_CODE", v_CODE); //NEW_CODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_NAME", v_NAME); //NEW_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_NO", v_PATTERN_NO); //NEW_PATTERN_NO
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_ALIAS", v_PATTERN_ALIAS); //NEW_PATTERN_ALIAS
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PARENTCODE", v_PARENTCODE); //NEW_PARENTCODE
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "NEW_ITEM_LAYER", v_ITEM_LAYER); //NEW_ITEM_LAYER
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_PATTERN_NAME", v_PATTERN_NAME); //NEW_PATTERN_NAME
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_MEMO", ""); //NEW_MEMO
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //NEW_UPDATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //NEW_UPDATEUID

            bco.UpdateItemClassify(ParameterList, null);

            Response.Redirect("ITM242.aspx?Code=ITM24&isToolBar=N&SessionName=" + Request.QueryString["SessionName"] + "&arl_Key=" + Request.QueryString["arl_Key"] + "&ID=" + v_ID + "&showalert=YES");
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }

    }//end EditCommitButton_Click
Example #6
0
    }//end InsertCancelButton_Click

    /// <summary>
    /// 於檢視模式,按下刪除鈕


    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        int res = 0;
        try
        {
            ParameterList.Clear();
            DataTable dt = bco.ConvertXMLToDataTable(MasterOLDData.InnerHtml);
            DataRow dr = dt.Rows[0];

            MaintainSKU bcoSKU = new MaintainSKU(ConntionDB);
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "MA.PATTERN_NO", dr["PATTERN_NO"].ToString() + "%", "like", "and");
            DataTable dtExists = bcoSKU.QuerySKUByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法刪除");
                return;
            }
            MaintainPreItem bcoPreItem = new MaintainPreItem(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(DBNull.Value); //N_ID
            ParameterList.Add(DBNull.Value); //V_ITEM
            ParameterList.Add(dr["PATTERN_NO"].ToString() + "%"); //V_PATTERN_NO            
            dtExists = bcoPreItem.QueryPreItemByFind_1(ParameterList);
            if (dtExists.Rows.Count > 0)
            {
                Alert("PatternNo使用中,無法刪除");
                return;
            }
            ParameterList.Clear();
            SQLHelper.SQLWhere(ref ParameterList, DbType.VarNumeric, "OLD_ID", dr["ID"].ToString()); //OLD_ID
            SQLHelper.SQLWhere(ref ParameterList, DbType.DateTime, "NEW_UPDATEDATE", DateTime.Now); //OLD_CREATEDATE
            SQLHelper.SQLWhere(ref ParameterList, DbType.String, "NEW_UPDATEUID", Session["UID"].ToString()); //OLD_ENABLE
            bco.DeleteItemClassify(ParameterList, null);

            //Response.Write("<script>alert('刪除完成');location.replace('ITM241.aspx?Code=ITM24');</script>");
            Script("alert('刪除完成');location.replace('ITM241.aspx?Code=ITM24');");
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("其他使用者異動,刪除") != -1)
                ErrorMsgLabel.Text = "刪除失敗,此資料已被其他使用者刪除,請重新查詢";
            else
                ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }//DeleteButton_Click
Example #7
0
 /// <summary>
 /// 寫LOG檔
 /// </summary>        
 private void WriteLogFile(string strLogMsg, bool bOK)
 {
     ITMModel.MaintainPreItem bco = new ITMModel.MaintainPreItem(ConnnectionString);
     bco.LogAdd(LogName, bOK, strLogMsg);            
 }
Example #8
0
        /// <summary>
        /// 主檔載入:新品主檔(VDS_ITM_PRE_ITEM)send_flg=1 的資料
        /// </summary>
        /// <returns></returns>
        private bool Transfer_ALL_ITEM()
        {
            bool bResult = false;
            try
            {
                ITMModel.MaintainPreItem BCO = new ITMModel.MaintainPreItem(ConnnectionString);
                ArrayList Para = new ArrayList();
                Para.Clear();
                Para.Add("VDS2G");
                int iOK = 0;
                int iNG = 0;
                int iTotal = 0;
                BCO.Transfer_ALL_ITEM(Para, null, out iOK, out iNG, out iTotal);

                if (iNG == 0)
                {
                    bResult = true;
                }
                WriteLogFile("處理筆數:" + iTotal.ToString() + ",成功:" + iOK.ToString() + ",失敗:" + iNG.ToString(), true);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return bResult;
        }
    public string PreItemName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainSKU co_main = new MaintainSKU(ConnectionDBStr);
        MaintainPreItem co_PreItem = new MaintainPreItem(ConnectionDBStr);

        ArrayList ParameterList = new ArrayList();
        ParameterList.Add(Code);

        DataTable dt = co_main.QuerySKUByCode(ParameterList);
        if (dt.Rows.Count > 0)
        {
            Name = "已存在";
        }
        else
        {
            dt = co_PreItem.QueryPreItemByCode(ParameterList);
            if (dt.Rows.Count > 0)
                Name = "已存在";
            else
                Name = "查無資料";
        }

        return Name;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            this.ErrorMsgLabel.Text = string.Empty;
            if (txtRETURN_MEMO.Text.Trim() == "")
            {
                this.ErrorMsgLabel.Text = "請輸入退件原因";
                return;
            }
            //N_ID             in NUMBER,
            //V_RETURN_MEMO    in varchar,
            //D_OLD_UPDATEDATE in date,
            //V_OLD_UPDATEUID  in varchar,                         
            //D_NEW_UPDATEDATE in date,
            //V_NEW_UPDATEUID  in varchar
            ParameterList.Clear();
            ParameterList.Add(int.Parse(ViewState["ID"].ToString()));
            ParameterList.Add(txtRETURN_MEMO.Text.Trim());
            ParameterList.Add(DateTime.ParseExact(ViewState["UPDATEDATE"].ToString(), "yyyy/MM/dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
            ParameterList.Add(ViewState["UPDATEUID"].ToString());
            ParameterList.Add(DateTime.Now);
            ParameterList.Add(Session["UID"].ToString());
            BCO.MaintainPreItem bco = new BCO.MaintainPreItem(ConntionDB);
            bco.UpdateReturn(ParameterList, null);
            ScriptManager.RegisterStartupScript(this.up_Msg, typeof(UpdatePanel), "ITM182R", "alert('退件完成');window.returnValue='OK';window.close();", true);

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }