public string makeEmpinsertQuery(DetailUnit _du) { string preString = "insert into EMP "; string whereString = ""; string valuesString = "values ( "; if (_du.getEmpID().Equals("")) { return(null); } whereString = ""; valuesString = valuesString + "'" + _du.getName() + "'"; valuesString = valuesString + ", '" + _du.getName() + "'"; valuesString = valuesString + ", '" + _du.getName() + "'"; if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + "'" + _du.getSsno() + "'"; if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + "" + _du.getDepartment(); if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " " + _du.getDivision(); if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + "" + _du.getTitle(); if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " '" + _du.getTel() + "'"; if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " '" + _du.getEmail() + "'"; if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " '" + _du.getAddress() + "'"; valuesString = valuesString + ", getdate()"; if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " " + getCastString(getDate(_du.getBirth())); if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " " + _du.getGender(); if (!valuesString.Equals("")) { valuesString = valuesString + ", "; } valuesString = valuesString + " " + _du.getFpNum(); valuesString = valuesString + ",'','','','','','','')"; if (valuesString.Equals("")) { return(null); } return(preString + valuesString + whereString); }
public string makeEmpUpdateQuery(DetailUnit _du) { string preString = "update EMP set "; string whereString = ""; string setString = ""; if (_du.getEmpID().Equals("")) { return(null); } whereString = " where ID = " + _du.getEmpID(); if (!_du.getName().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "NAME_1 = '" + _du.getName() + "'"; } if (_du.getBirth() != new DateTime(1000, 1, 1)) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "BIRTH_DATE = " + getCastString(getDate(_du.getBirth())); } if (!_du.getGender().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "GENDER = " + _du.getGender(); } if (!_du.getSsno().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "SSNO = '" + _du.getSsno() + "'"; } if (_du.getDepartment() != -1) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "DEPARTMENT = " + _du.getDepartment(); } if (_du.getDivision() != -1) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "DIVISION = " + _du.getDivision(); } if (_du.getTitle() != -1) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "TITLE = " + _du.getTitle(); } if (!_du.getEmail().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "EMAIL = '" + _du.getEmail() + "'"; } if (!_du.getTel().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "TEL = '" + _du.getTel() + "'"; } if (!_du.getAddress().Equals("")) { if (!setString.Equals("")) { setString = setString + ", "; } setString = setString + "ADDRESS = '" + _du.getAddress() + "'"; } if (setString.Equals("")) { return(null); } setString = setString + ", MODIFY_DATE = GETDATE()"; return(preString + setString + whereString); }