public void UpdateReasonCode(JObject requestValue, JToken Data, MESStationReturn StationReturn) { string id = Data["ID"].ToString(); if (string.IsNullOrEmpty(id)) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000006"; StationReturn.MessagePara = new List <Object>() { "Reason Code ID" }; StationReturn.Data = null; return; } string reason_code = Data["REASON_CODE"].ToString(); if (string.IsNullOrEmpty(reason_code)) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000006"; StationReturn.MessagePara = new List <Object>() { "Reason Code" }; StationReturn.Data = null; return; } string en_desc = Data["ENGLISH_DESC"].ToString(); string cn_desc = Data["CHINESE_DESC"].ToString(); OleExec sfcdb = DBPools["SFCDB"].Borrow(); string updateSQL = null; T_C_REASON_CODE t_reason_code = null; Row_C_REASON_CODE row_reason_code = null; C_REASON_CODE c_reason_code = null; try { t_reason_code = new T_C_REASON_CODE(sfcdb, DB_TYPE_ENUM.Oracle); c_reason_code = t_reason_code.GetObjById(sfcdb, id); if (c_reason_code == null) { StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000007"; StationReturn.Data = ""; StationReturn.MessagePara = new List <Object>() { "Object 'C_REASON_CODE'" }; if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } return; } row_reason_code = (Row_C_REASON_CODE)t_reason_code.NewRow(); row_reason_code.ID = c_reason_code.ID; row_reason_code.REASON_CODE = reason_code; row_reason_code.ENGLISH_DESCRIPTION = en_desc; row_reason_code.CHINESE_DESCRIPTION = cn_desc; row_reason_code.EDIT_EMP = this.LoginUser.EMP_NO; row_reason_code.EDIT_TIME = this.GetDBDateTime(); updateSQL = row_reason_code.GetUpdateString(DB_TYPE_ENUM.Oracle, c_reason_code.ID); sfcdb.ExecuteNonQuery(updateSQL, CommandType.Text, null); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000003"; StationReturn.Data = ""; if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } catch (Exception ex) { if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } throw ex; } }
public void AddReasonCode(JObject requestValue, JToken Data, MESStationReturn StationReturn) { string reason_code = Data["REASON_CODE"].ToString(); if (string.IsNullOrEmpty(reason_code)) { StationReturn.MessageCode = "MES00000006"; StationReturn.Status = StationReturnStatusValue.Fail; return; } string en_desc = Data["ENGLISH_DESC"].ToString(); string cn_desc = Data["CHINESE_DESC"].ToString(); OleExec sfcdb = DBPools["SFCDB"].Borrow(); int res = 0; T_C_REASON_CODE t_reasonCode = null; Row_C_REASON_CODE r_ReasonCode = null; try { t_reasonCode = new T_C_REASON_CODE(sfcdb, DB_TYPE_ENUM.Oracle); r_ReasonCode = (Row_C_REASON_CODE)t_reasonCode.NewRow(); r_ReasonCode.ID = t_reasonCode.GetNewID(this.BU, sfcdb); r_ReasonCode.REASON_CODE = reason_code; r_ReasonCode.CHINESE_DESCRIPTION = cn_desc; r_ReasonCode.ENGLISH_DESCRIPTION = en_desc; r_ReasonCode.EDIT_EMP = this.LoginUser.EMP_NAME; r_ReasonCode.EDIT_TIME = this.GetDBDateTime(); string insertSQL = r_ReasonCode.GetInsertString(DB_TYPE_ENUM.Oracle); res = sfcdb.ExecSqlNoReturn(insertSQL, null); if (res > 0) { StationReturn.MessageCode = "MES00000001"; StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Data = ""; } else { StationReturn.MessageCode = "MES00000021"; StationReturn.MessagePara = new List <object>() { "Reason Code" }; StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Data = ""; } if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } catch (Exception ex) { if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } throw ex; } }