Beispiel #1
0
        //新增
        public bool InsSystemCodeBuff(SystemCodeBufInfo info)
        {
            Database      db    = GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.AppendLine(" INSERT INTO SystemCodeBuf ");
            sbCmd.AppendLine(" (Type, Value, Text, DisplayOrder, Value2, REMARKS, StepID, MODItem, Maker, Maker_Time) ");
            sbCmd.AppendLine(" Values ");
            sbCmd.AppendLine(" (@Type, @Value, @Text, @DisplayOrder, @Value2, @REMARKS, @StepID, @MODItem, @Maker, @Maker_Time) ");

            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());

            #region 指定參數
            db.AddInParameter(dbCommand, "@Type", DbType.String, info.Type);
            db.AddInParameter(dbCommand, "@Value", DbType.String, info.Value);
            db.AddInParameter(dbCommand, "@Text", DbType.String, info.Text);
            db.AddInParameter(dbCommand, "@DisplayOrder", DbType.Int16, info.DisplayOrder);
            db.AddInParameter(dbCommand, "@Value2", DbType.String, info.Value2);
            db.AddInParameter(dbCommand, "@REMARKS", DbType.String, info.REMARKS);
            db.AddInParameter(dbCommand, "@StepID", DbType.String, info.StepID);
            db.AddInParameter(dbCommand, "@MODItem", DbType.String, info.MODItem);
            db.AddInParameter(dbCommand, "@Maker", DbType.String, info.Maker);
            db.AddInParameter(dbCommand, "@Maker_Time", DbType.DateTime, info.Maker_Time);
            #endregion

            return(ExecuteNonQuery(db, dbCommand));
        }
Beispiel #2
0
        //更新
        public bool UpdSystemCodeBuff(SystemCodeBufInfo info)
        {
            Database      db    = GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.AppendLine(" UPDATE SystemCodeBuf ");
            sbCmd.AppendLine("    SET Text = @Text ");
            sbCmd.AppendLine("       ,DisplayOrder = @DisplayOrder ");
            sbCmd.AppendLine("       ,Value2 = @Value2 ");
            sbCmd.AppendLine("       ,REMARKS = @REMARKS ");
            sbCmd.AppendLine("       ,StepID = @StepID ");
            sbCmd.AppendLine("       ,MODItem = @MODItem ");
            sbCmd.AppendLine("       ,Maker = @Maker ");
            sbCmd.AppendLine("       ,Maker_Time = @Maker_Time ");
            sbCmd.AppendLine("  WHERE Type = @Type ");
            sbCmd.AppendLine("    AND Value = @Value ");

            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());

            #region 指定參數
            db.AddInParameter(dbCommand, "@Type", DbType.String, info.Type);
            db.AddInParameter(dbCommand, "@Value", DbType.String, info.Value);
            db.AddInParameter(dbCommand, "@Text", DbType.String, info.Text);
            db.AddInParameter(dbCommand, "@DisplayOrder", DbType.Int16, info.DisplayOrder);
            db.AddInParameter(dbCommand, "@Value2", DbType.String, info.Value2);
            db.AddInParameter(dbCommand, "@REMARKS", DbType.String, info.REMARKS);
            db.AddInParameter(dbCommand, "@StepID", DbType.String, info.StepID);
            db.AddInParameter(dbCommand, "@MODItem", DbType.String, info.MODItem);
            db.AddInParameter(dbCommand, "@Maker", DbType.String, info.Maker);
            db.AddInParameter(dbCommand, "@Maker_Time", DbType.DateTime, info.Maker_Time);
            #endregion

            return(ExecuteNonQuery(db, dbCommand));
        }
Beispiel #3
0
        public bool LoadSystemCodeBuff(string iType, string iValue, out SystemCodeBufInfo iInfo)
        {
            bool Result = false;

            Database      db    = base.GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.AppendLine(" select * from SystemCodeBuf with (nolock) ");
            sbCmd.AppendLine("    where Type = @Type ");
            sbCmd.AppendLine("    and Value = @Value ");

            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());

            #region 指定參數
            db.AddInParameter(dbCommand, "@Type", DbType.String, iType);
            db.AddInParameter(dbCommand, "@Value", DbType.String, iValue);
            #endregion

            base.ErrFlag = true;
            DataTable dtTemp = ExecuteDataSet(db, dbCommand).Tables[0];
            if (dtTemp.Rows.Count == 0)
            {
                Result = false;
                iInfo  = new SystemCodeBufInfo();
            }
            else
            {
                Result = true;
                iInfo  = new SystemCodeBufInfo(dtTemp.Rows[0]);
            }

            return(Result);
        }
Beispiel #4
0
    /// <summary>
    /// 資料捨棄
    /// </summary>
    protected bool Drop()
    {
        SystemCodeDB myDB = new SystemCodeDB(base.strUserID, base.FormID);

        try
        {
            //取UI欄位值
            SystemCodeBufInfo BuffInfo = null;
            GetModFieldValue(out BuffInfo);

            //是否在Buffer資料且已經送審中
            bool IsExistBuffer = myDB.chkSystemCode(BuffInfo, SystemCodeDB.TableType.Buffer, "INCHECKER");

            if (IsExistBuffer)
            {
                base.DoAlertinAjax(this, "SAVE", "該筆資料已經送審,不可捨棄!");
                return(false);
            }
            else
            {
                myDB.DelSysteCodeBuff(BuffInfo);

                base.DoAlertinAjax(this, "SAVE", "捨棄完成!");
                return(true);
            }
        }
        catch (Exception ex)
        {
            base.DoAlertinAjax(this, "SAVE", "作業發生錯誤,錯誤訊息:" + ex.Message);
            return(false);
        }
    }
Beispiel #5
0
    /// <summary>
    /// 資料刪除
    /// </summary>
    protected bool Delete()
    {
        SystemCodeDB myDB = new SystemCodeDB(base.strUserID, base.FormID);

        try
        {
            //取UI欄位值
            SystemCodeBufInfo BuffInfo = null;
            GetModFieldValue(out BuffInfo);

            //是否有在正式資料中
            bool IsExistOfficial = myDB.chkSystemCode(BuffInfo, SystemCodeDB.TableType.Official);

            //是否在Buffer資料中
            bool IsExistBuffer = myDB.chkSystemCode(BuffInfo, SystemCodeDB.TableType.Buffer);

            BuffInfo.StepID     = "20";
            BuffInfo.MODItem    = "D";
            BuffInfo.Maker      = base.strUserID;
            BuffInfo.Maker_Time = DateTime.Now;

            //若資料不在正式資料中就不可刪除
            if (!IsExistOfficial)
            {
                base.DoAlertinAjax(this, "SAVE", "該資料不存在於正式資料中,不可執行申請刪除作業!");
                return(false);
            }

            //如果存在於Buffer就Update反之則新增
            if (IsExistBuffer)
            {
                myDB.UpdSystemCodeBuff(BuffInfo);
            }
            else
            {
                myDB.InsSystemCodeBuff(BuffInfo);
            }

            base.DoAlertinAjax(this, "SAVE", "申請刪除完成!");

            return(true);
        }
        catch (Exception ex)
        {
            base.DoAlertinAjax(this, "SAVE", "作業發生錯誤,錯誤訊息:" + ex.Message);
            return(false);
        }
    }
Beispiel #6
0
    /// <summary>
    /// 資料更新
    /// </summary>
    protected bool Update(string StepID)
    {
        SystemCodeDB myDB = new SystemCodeDB(base.strUserID, base.FormID);

        try
        {
            //取UI欄位值
            SystemCodeBufInfo BuffInfo = null;
            GetModFieldValue(out BuffInfo);

            //是否有在正式資料中
            bool IsExistOfficial = myDB.chkSystemCode(BuffInfo, SystemCodeDB.TableType.Official);

            //是否在Buffer資料中
            bool IsExistBuffer = myDB.chkSystemCode(BuffInfo, SystemCodeDB.TableType.Buffer);

            BuffInfo.StepID     = StepID;
            BuffInfo.MODItem    = IsExistOfficial ? "U" : "I";
            BuffInfo.Maker      = base.strUserID;
            BuffInfo.Maker_Time = DateTime.Now;

            //如果存在於Buffer就Update反之則新增
            if (IsExistBuffer)
            {
                myDB.UpdSystemCodeBuff(BuffInfo);
            }
            else
            {
                myDB.InsSystemCodeBuff(BuffInfo);
            }

            if (StepID == "5")
            {
                base.DoAlertinAjax(this, "SAVE", "暫存完成!");
            }
            else
            {
                base.DoAlertinAjax(this, "SAVE", "送審完成!");
            }

            return(true);
        }
        catch (Exception ex)
        {
            base.DoAlertinAjax(this, "SAVE", "作業發生錯誤,錯誤訊息:" + ex.Message);
            return(false);
        }
    }
Beispiel #7
0
    /// <summary>
    /// 將 info 的值填入到 UI 中
    /// </summary>
    /// <param name="info"></param>
    private void FillModFieldValue(SystemCodeBufInfo iInfo)
    {
        //for 資料狀態
        lbModItem.Text = (iInfo.MODItem == "I") ? "新增"
            : (iInfo.MODItem == "U") ? "修改"
            : (iInfo.MODItem == "D") ? "刪除"
            : iInfo.MODItem;

        //data fields
        txtiType.Text         = iInfo.Type;
        txtiValue.Text        = iInfo.Value;
        txtiText.Text         = iInfo.Text;
        txtiDisplayOrder.Text = iInfo.DisplayOrder.ToString();
        txtiValue2.Text       = iInfo.Value2;
        txtiRemarks.Text      = iInfo.REMARKS;
    }
Beispiel #8
0
        //刪除
        public bool DelSysteCodeBuff(SystemCodeBufInfo info, DbTransaction iTxn = null)
        {
            Database      db    = GetDatabase();
            StringBuilder sbCmd = new StringBuilder();

            sbCmd.AppendLine(" delete from SystemCodeBuf ");
            sbCmd.AppendLine("   where Type = @Type ");
            sbCmd.AppendLine("   and Value = @Value ");

            DbCommand dbCommand = db.GetSqlStringCommand(sbCmd.ToString());

            #region 指定參數
            db.AddInParameter(dbCommand, "@Type", DbType.String, info.Type);
            db.AddInParameter(dbCommand, "@Value", DbType.String, info.Value);
            #endregion

            return(ExecuteNonQuery(db, dbCommand, iTxn));
        }
Beispiel #9
0
    /// <summary>
    /// 將UI上的值指定到Info中
    /// </summary>
    private void GetModFieldValue(out SystemCodeBufInfo BuffInfo)
    {
        BuffInfo = new SystemCodeBufInfo();

        //將值指定到Info中
        BuffInfo.Type  = txtiType.Text.Trim();
        BuffInfo.Value = txtiValue.Text.Trim();
        BuffInfo.Text  = txtiText.Text.Trim();

        if (!string.IsNullOrEmpty(txtiDisplayOrder.Text.Trim()))
        {
            BuffInfo.DisplayOrder = Convert.ToInt32(txtiDisplayOrder.Text);
        }
        else
        {
            BuffInfo.DisplayOrder = 0;
        }

        BuffInfo.Value2  = txtiValue2.Text.Trim();
        BuffInfo.REMARKS = txtiRemarks.Text.Trim();
    }
Beispiel #10
0
    //按下編輯按鈕
    protected bool View(string Type, string Value)
    {
        SystemCodeDB myDB = new SystemCodeDB(base.strUserID, base.FormID);

        //是否有在正式資料中
        bool IsExistOfficial = myDB.chkSystemCode(Type, Value, SystemCodeDB.TableType.Official);

        //是否在Buffer資料中
        bool IsExistBuffer = myDB.chkSystemCode(Type, Value, SystemCodeDB.TableType.Buffer);

        if (IsExistBuffer || IsExistOfficial)
        {
            SystemCodeBufInfo iInfo = new SystemCodeBufInfo();

            if (IsExistBuffer)
            {
                myDB.LoadSystemCodeBuff(Type, Value, out iInfo);
            }
            else if (IsExistOfficial)
            {
                SystemCodeInfo myInfo;

                myDB.LoadSystemCode(Type, Value, out myInfo);

                iInfo = new SystemCodeBufInfo(myInfo);
            }

            FillModFieldValue(iInfo);

            SetBtnStatus(IsExistBuffer, IsExistOfficial);

            return(true);
        }
        else
        {
            base.DoAlertinAjax(this, "SAVE", "該筆資料可能已被刪除,請重新查詢。");
            return(false);
        }
    }
Beispiel #11
0
 //依Key值確認是否已存在於Table中
 public bool chkSystemCode(SystemCodeBufInfo info, TableType TableType, string CheckType = "")
 {
     return(chkSystemCode(info.Type, info.Value, TableType, CheckType));
 }