public bool DeleteRecord(IModelObject KeyObject) { string sqlString = string.Empty; bool isSuccess = false; sqlString = "DELETE FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + this._newLineSybm; sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.RecordID.ToString()] + "=" + KeyObject.RecordID.ToString(); DataAccessLayer dal = new DataAccessLayer(); try { isSuccess = dal.ExecNonQuery(sqlString); } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool UpdateRecord(Model.Master.DeptMasterInfo infoObject) { string sqlString = string.Empty; bool isSuccess = false; if (infoObject == null) { return isSuccess; } sqlString = "UPDATE " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + " SET " + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.DpmCDeptName.ToString()] + "='" + infoObject.DpmCDeptName.Trim().Replace("'", "''") + "'," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.Remark.ToString()] + "='" + infoObject.Remark.ToString() + "'," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.Last.ToString()] + "='" + infoObject.Last.Trim().Replace("'", "''") + "'," + this._newLineSybm; if (infoObject.LastDate == null) { sqlString += this._dataDictionary[DeptMasterInfoEnum.LastDate.ToString()] + "=NULL" + this._newLineSybm; } else { sqlString += this._dataDictionary[DeptMasterInfoEnum.LastDate.ToString()] + "='" + infoObject.LastDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "'" + this._newLineSybm; } sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.RecordID.ToString()] + "=" + infoObject.RecordID.ToString(); DataAccessLayer dal = new DataAccessLayer(); try { isSuccess = dal.ExecNonQuery(sqlString); } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool InsertRecord(Model.Master.DeptMasterInfo infoObject) { string sqlString = string.Empty; bool isSuccess = false; if (infoObject == null) { return isSuccess; } sqlString = "INSERT INTO " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + "(" + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.DpmCDeptNumber.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.DpmCDeptName.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.Remark.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.Add.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.AddDate.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.Last.ToString()] + "," + this._newLineSybm; sqlString += this._dataDictionary[DeptMasterInfoEnum.LastDate.ToString()] + ")" + this._newLineSybm; sqlString += "VALUES(" + this._newLineSybm; sqlString += "'" + infoObject.DpmCDeptNumber.Trim().Replace("'", "''") + "'," + this._newLineSybm; sqlString += "'" + infoObject.DpmCDeptName.Trim().Replace("'", "''") + "'," + this._newLineSybm; sqlString += "'" + infoObject.Remark.Trim().Replace("'", "''") + "'," + this._newLineSybm; sqlString += "'" + infoObject.Add.Trim().Replace("'", "''") + "'," + this._newLineSybm; if (infoObject.AddDate == null) { sqlString += "NULL," + this._newLineSybm; } else { sqlString += "'" + infoObject.AddDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "'," + this._newLineSybm; } sqlString += "'" + infoObject.Last.Trim().Replace("'", "''") + "'," + this._newLineSybm; if (infoObject.LastDate == null) { sqlString += "NULL)" + this._newLineSybm; } else { sqlString += "'" + infoObject.LastDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "')" + this._newLineSybm; } DataAccessLayer dal = new DataAccessLayer(); try { isSuccess = dal.ExecNonQuery(sqlString); } catch (Exception Ex) { throw Ex; } return isSuccess; }