public bool ValidateData(MessageData data) { bool ret = true; if (data.MESSAGE == "") { ret = false; _error = "¡ÃسÒÃкآéͤÇÒÁ"; } else if (data.MESSAGE.Length > 4000) { ret = false; _error = "¡ÃÍ¡¢éͤÇÒÁä´éäÁèà¡Ô¹ 4,000 µÑÇÍÑ¡ÉÃ"; } else if (data.EFDATE.Year == 1) { ret = false; _error = "¡ÃسÒÇѹ·ÕèàÃÔèÁáÊ´§¢éͤÇÒÁ"; } else if (data.EPDATE.Year == 1) { ret = false; _error = "¡ÃسÒÇѹ·ÕèÊÔé¹ÊØ´¡ÒÃáÊ´§¢éͤÇÒÁ"; } else if (data.EPDATE < data.EFDATE) { ret = false; _error = "Çѹ·ÕèàÃÔèÁáÊ´§¢éͤÇÒÁµéͧ¹éÍ¡ÇèÒÇѹ·ÕèÊÔé¹ÊØ´¡ÒÃáÊ´§"; } return ret; }
public MessageData GetMessageData(double LOID) { MessageData data = new MessageData(); DALObj.GetDataByLOID(LOID, null); data.EFDATE = DALObj.EFDATE; data.EPDATE = DALObj.EPDATE; data.MESSAGE = DALObj.MESSAGE; data.LOID = DALObj.LOID; return data; }
public bool UpdateData(string userID, MessageData data) { bool ret = true; if (ValidateData(data)) { OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { DALObj.OnDB = false; DALObj.GetDataByLOID(data.LOID, obj.zTrans); DALObj.MESSAGE = data.MESSAGE; DALObj.EFDATE = data.EFDATE; DALObj.EPDATE = data.EPDATE; if (DALObj.OnDB) ret = DALObj.UpdateCurrentData(userID, obj.zTrans); else ret = DALObj.InsertCurrentData(userID, obj.zTrans); _LOID = DALObj.LOID; if (!ret) { throw new ApplicationException(DALObj.ErrorMessage); } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } } else ret = false; return ret; }