using System; using System.Net.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Text; using System.Diagnostics; using System.Globalization; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; // Interface for Web Service Program JSPG2 // Generated by MANASYS Jazz from Visual Studio at 22/02/2024 5:12:13 PM, User 11JAZZUSR namespace MyJSv { public class JSPG2Client { // Private - objects that are not known outside the Client object static readonly HttpClient client = new HttpClient(); private RequestJSPG2 Request = new RequestJSPG2(); // Actual request message private ResponseJSPG2 Response = new ResponseJSPG2(); // Actual response message private int IXT1Sub = 0; // Used if response has >1 occurrences of Table data struct SetByUser { public bool Skip; public bool EMPNO; public bool FIRSTNME; public bool MIDINIT; public bool LASTNAME; public bool WORKDEPT; public bool PHONENO; public bool HIREDATE; public bool JOB; public bool EDLEVEL; public bool SEX; public bool BIRTHDATE; public bool SALARY; public bool BONUS; public bool COMM; public bool CURRENCY; public bool DEPTMGR; public bool STARTTIME; } private SetByUser Changed = new SetByUser(); private string _Function = null; private string Function // => Request.Function { get => _Function; set { if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _Function = InList(value, new[] { "E", "U", "A", "D" }, true, "Function"); Request.JSPG2.IJSPG2.JZ_Function = _Function; } } private string _Checksum = null; // Save 2ry Key fields for browse private string SaveBrowse_PWORKDEPT = ""; // Key Properties - fields used by methods to access records // Skip controls scrolling for EMPLOYEE private string _Skip = null; public string Skip // => Request.Skip { get => _Skip; set { Changed.Skip = true; _Skip = null; if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _Skip = IsInt(value, 0, 999, "Skip"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE_Skip = int.Parse(_Skip); } } private string _EMPNO = null; public string EMPNO // => Request.EMPNO { get => _EMPNO; set { Changed.EMPNO = true; _EMPNO = null; if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _EMPNO = IsInt(value, 0, 999999, "EMPNO"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.EMPNO = _EMPNO; } } private string _WORKDEPT = null; public string WORKDEPT // => Request.WORKDEPT { get => _WORKDEPT; set { Changed.WORKDEPT = true; _WORKDEPT = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _WORKDEPT = "nul"; else _WORKDEPT = IsNoLongerThan(value, 3, "WORKDEPT"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.WORKDEPT = _WORKDEPT; } } // I/O Data - non-key fields that may be set for update and add, will be set in response private string _FIRSTNME = null; public string FIRSTNME // => Request.FIRSTNME { get => _FIRSTNME; set { Changed.FIRSTNME = true; _FIRSTNME = null; if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _FIRSTNME = IsNoLongerThan(value, 12, "FIRSTNME"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.FIRSTNME = _FIRSTNME; } } private string _MIDINIT = null; public string MIDINIT // => Request.MIDINIT { get => _MIDINIT; set { Changed.MIDINIT = true; _MIDINIT = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _MIDINIT = "n"; else _MIDINIT = IsNoLongerThan(value, 1, "MIDINIT"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.MIDINIT = _MIDINIT; } } private string _LASTNAME = null; public string LASTNAME // => Request.LASTNAME { get => _LASTNAME; set { Changed.LASTNAME = true; _LASTNAME = null; if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _LASTNAME = IsNoLongerThan(value, 15, "LASTNAME"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.LASTNAME = _LASTNAME; } } private string _PHONENO = null; public string PHONENO // => Request.PHONENO { get => _PHONENO; set { Changed.PHONENO = true; _PHONENO = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _PHONENO = "null"; else _PHONENO = IsInt(value, 0, 9999, "PHONENO"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.PHONENO = _PHONENO; } } private string _HIREDATE = null; public string HIREDATE // => Request.HIREDATE { get => _HIREDATE; set { Changed.HIREDATE = true; _HIREDATE = null; string ReqValue = ""; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _HIREDATE = "null"; else _HIREDATE = IsDate(value, "HIREDATE", ref ReqValue); //Date Request.JSPG2.IJSPG2.JZ_EMPLOYEE.HIREDATE = ReqValue; } } private string _JOB = null; public string JOB // => Request.JOB { get => _JOB; set { Changed.JOB = true; _JOB = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _JOB = "null"; else _JOB = IsNoLongerThan(value, 8, "JOB"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.JOB = _JOB; } } private string _EDLEVEL = null; public string EDLEVEL // => Request.EDLEVEL { get => _EDLEVEL; set { Changed.EDLEVEL = true; _EDLEVEL = null; if (value == "") { _Error = "Value required"; _JZ_EMPLOYEE_ReturnCode = "E"; return; } _EDLEVEL = IsInt(value, -32767, 32767, "EDLEVEL"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.EDLEVEL = _EDLEVEL; } } private string _SEX = null; public string SEX // => Request.SEX { get => _SEX; set { Changed.SEX = true; _SEX = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _SEX = "n"; else _SEX = InList(value, new[] { "M", "F" }, true, "SEX"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.SEX = _SEX; } } public string SEX_Value // => Request.SEX_Value { get { if (_SEX == "M") return "Male"; if (_SEX == "F") return "Female"; return ""; } } private string _BIRTHDATE = null; public string BIRTHDATE // => Request.BIRTHDATE { get => _BIRTHDATE; set { Changed.BIRTHDATE = true; _BIRTHDATE = null; string ReqValue = ""; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _BIRTHDATE = "null"; else _BIRTHDATE = IsDate(value, "BIRTHDATE", ref ReqValue); //Date Request.JSPG2.IJSPG2.JZ_EMPLOYEE.BIRTHDATE = ReqValue; } } private string _SALARY = null; public string SALARY // => Request.SALARY { get => _SALARY; set { Changed.SALARY = true; _SALARY = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _SALARY = "null"; else _SALARY = IsFloat(value, 0, 9999999, "SALARY"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.SALARY = _SALARY; } } private string _BONUS = null; public string BONUS // => Request.BONUS { get => _BONUS; set { Changed.BONUS = true; _BONUS = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _BONUS = "null"; else _BONUS = IsFloat(value, 0, 9999999, "BONUS"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.BONUS = _BONUS; } } private string _COMM = null; public string COMM // => Request.COMM { get => _COMM; set { Changed.COMM = true; _COMM = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _COMM = "null"; else _COMM = IsFloat(value, 0, 9999999, "COMM"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.COMM = _COMM; } } private string _CURRENCY = null; public string CURRENCY // => Request.CURRENCY { get => _CURRENCY; set { Changed.CURRENCY = true; _CURRENCY = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _CURRENCY = "nul"; else _CURRENCY = IsNoLongerThan(value, 3, "CURRENCY"); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.JZ_CURRENCY = _CURRENCY; } } private string _DEPTMGR = null; public string DEPTMGR // => Request.DEPTMGR { get => _DEPTMGR; set { Changed.DEPTMGR = true; _DEPTMGR = null; if (value == "" || value == "n" || value == "nu" || value == "nul") return; string ReqValue = "N"; _DEPTMGR = IsBool(value, "DEPTMGR", ref ReqValue); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.DEPTMGR = ReqValue; } } private string _STARTTIME = null; public string STARTTIME // => Request.STARTTIME { get => _STARTTIME; set { Changed.STARTTIME = true; _STARTTIME = null; string ReqValue = ""; if (value == "" || value == "n" || value == "nu" || value == "nul") return; if (value == "null") _STARTTIME = "null"; else _STARTTIME = IsTime(value, "STARTTIME", ref ReqValue); //Time Request.JSPG2.IJSPG2.JZ_EMPLOYEE.STARTTIME = ReqValue; } } // Output data - readonly properties that are set from response, e.g. Message private string _Error = null; public string Error // Readonly { get => _Error; } private string _JZ_EMPLOYEE_ReadTo = null; public string JZ_EMPLOYEE_ReadTo // Readonly { get => _JZ_EMPLOYEE_ReadTo; } private string _JZ_EMPLOYEE_NbrReturned = null; public string JZ_EMPLOYEE_NbrReturned // Readonly { get => _JZ_EMPLOYEE_NbrReturned; } private string _JZ_EMPLOYEE_BrowseCount = null; public string JZ_EMPLOYEE_BrowseCount // Readonly { get => _JZ_EMPLOYEE_BrowseCount; } private string _JZ_EMPLOYEE_ReturnCode = null; public string JZ_EMPLOYEE_ReturnCode // Readonly { get => _JZ_EMPLOYEE_ReturnCode; } public string JZ_EMPLOYEE_ReturnCode_Value // => Request.JZ_EMPLOYEE_ReturnCode_Value { get { if (_JZ_EMPLOYEE_ReturnCode == "' '") return "' '"; if (_JZ_EMPLOYEE_ReturnCode == "W") return "Warning"; if (_JZ_EMPLOYEE_ReturnCode == "E") return "Error"; if (_JZ_EMPLOYEE_ReturnCode == "S") return "'Serious Error'"; if (_JZ_EMPLOYEE_ReturnCode == "T") return "'Terminal Error'"; if (_JZ_EMPLOYEE_ReturnCode == "A") return "Absent"; if (_JZ_EMPLOYEE_ReturnCode == "C") return "Changed"; if (_JZ_EMPLOYEE_ReturnCode == "D") return "Deleted"; if (_JZ_EMPLOYEE_ReturnCode == "F") return "First"; if (_JZ_EMPLOYEE_ReturnCode == "I") return "Inserted"; if (_JZ_EMPLOYEE_ReturnCode == "L") return "Last"; if (_JZ_EMPLOYEE_ReturnCode == "N") return "Nth"; if (_JZ_EMPLOYEE_ReturnCode == "U") return "Unique"; return ""; } } private string _DEPTNAME = null; public string DEPTNAME // Readonly { get => _DEPTNAME; } // Functions used to check input properties // Methods. Usually related to Function, e.g. Function CHAR(1) CAPS CODES(E:Enquiry, U:Update, A:Add, D:Delete) will have // Enquiry, Update, Add, and Delete methods private string InList(string Funct, string[] VList, bool Upcase, string FieldName) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Upcase) Funct = Funct.ToUpper(); foreach (string X in VList) { if (X == Funct) return Funct; } _Error = FieldName + " Value out of range"; _JZ_EMPLOYEE_ReturnCode = "E"; return ""; } private string IsInt(string Value, int MinVal, int maxval, string FieldName) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Value == "") return "0"; int IX = 0; if (!int.TryParse(Value, out IX)) { _Error = FieldName + " Value is Not Numeric"; _JZ_EMPLOYEE_ReturnCode = "E"; } else if (IX < MinVal || IX > maxval) { _Error = FieldName + " Value out of range"; _JZ_EMPLOYEE_ReturnCode = "E"; } return Value; } private string IsNoLongerThan(string Value, int MaxLen, string FieldName) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Value.Length > MaxLen) { _Error = FieldName + " Value is too long"; _JZ_EMPLOYEE_ReturnCode = "W"; return Value.Substring(0, MaxLen); } return Value; } private string IsDate(string Value, string FieldName, ref string ReqValue) // Validate Date { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Value == "") return "0"; if (Value == "null") { ReqValue = "null"; return "null"; } // Dates are entered according to the local culture, or as Jazz Format // Jazz format is ccyymmdd, i.e. 20210317 = 17th March 2021 DateTime DT; int IX = 0; if (int.TryParse(Value, out IX)) // Jazz format { if (Value.Length < 8) { _Error = FieldName + " integer-form date must be 8 digits"; _JZ_EMPLOYEE_ReturnCode = "E"; return Value; } int Year = int.Parse(Value.Substring(0, 4)); int Month = int.Parse(Value.Substring(4, 2)); int Day = int.Parse(Value.Substring(6, 2)); try { DT = new DateTime(Year, Month, Day); ReqValue = Year.ToString("0000") + Month.ToString("00") + Day.ToString("00"); return DT.ToString("d"); } catch { _Error = FieldName + " Year:" + Year + ", Month:" + Month + ", Day:" + Day + " not a valid date"; _JZ_EMPLOYEE_ReturnCode = "E"; } return Value; } if (!DateTime.TryParse(Value, out DT)) { _Error = FieldName + " Value is Not a date"; _JZ_EMPLOYEE_ReturnCode = "E"; } ReqValue = DT.Year.ToString("0000") + DT.Month.ToString("00") + DT.Day.ToString("00"); return Value; } private string DateValue(string InputValue) // Display Jazz-Format Date as in local culture date { if (InputValue == "0") return "0"; int IX; if (InputValue.Length != 8 || !int.TryParse(InputValue, out IX)) { return InputValue + " invalid date"; } else { int Year = int.Parse(InputValue.Substring(0, 4)); int Month = int.Parse(InputValue.Substring(4, 2)); int Day = int.Parse(InputValue.Substring(6, 2)); try { DateTime DT = new DateTime(Year, Month, Day); return DT.ToString("d"); } catch { return InputValue + " invalid date"; } } } private string IsFloat(string Value, int MinVal, int maxval, string FieldName) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; string C = NumberFormatInfo.CurrentInfo.CurrencySymbol; string V2 = Value.Replace(C, ""); if (V2 == "") return "0"; float X = 0; if (!float.TryParse(V2, out X)) { _Error = FieldName + " Value is Not Numeric"; _JZ_EMPLOYEE_ReturnCode = "E"; } else if (X < MinVal || X > maxval) { _Error = FieldName + " Value out of range"; _JZ_EMPLOYEE_ReturnCode = "E"; } return Value; } private string IsBool(string Value, string FieldName, ref string ReqValue) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Value == "null") { ReqValue = "null"; return "null"; } // Request: COBOL-side values are Y or N ReqValue = "N"; has been set before IsBool reference string V1; if (Value.Length == 1) { V1 = Value.ToUpper(); if (V1 == "T" || V1 == "Y") { ReqValue = "Y"; return "True"; } else if (V1 == "F" || V1 == "N") { return "False"; } } // Invalid _Error = FieldName + " Enter t or f"; _JZ_EMPLOYEE_ReturnCode = "E"; return Value; } private string BoolValue(string InputValue) // Display Y as True, anything else as False { if (InputValue == "Y") { return "True"; } else { return "False"; } } private string IsTime(string Value, string FieldName, ref string ReqValue) // Validate Time { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; if (Value == "") return "0"; if (Value == "null") { ReqValue = "null"; return "null"; } // Times should have been displayed with format hh:mm:ss.mmm // i.e. 13:45:24.567 = 24.567 seconds after 1:45 PM string[] Parts = Value.Split(":"); if (Parts.Length == 1) // : not found. Format Time properly { Value = TimeValue(Value); Parts = Value.Split(":"); } int Hour, Min, Sec, MSec; string Cma = ""; if (int.TryParse(Parts[0], out Hour) == false || Hour < 0 || Hour > 23) { _Error += "Hour invalid"; Cma = ","; } if (int.TryParse(Parts[1], out Min) == false || Min < 0 || Min > 59) { _Error += Cma + "Min invalid"; Cma = ","; } string[] SecMSec = Parts[2].Split("."); if (int.TryParse(SecMSec[0], out Sec) == false || Sec < 0 || Sec > 59) { _Error += Cma + "Sec invalid"; Cma = ","; } MSec = 0; if (SecMSec.Length > 1) { if (int.TryParse(SecMSec[1], out MSec) == false || MSec < 0 || Sec > 999) { _Error += Cma + "Sec invalid"; Cma = ","; } } if (Cma == ",") { _JZ_EMPLOYEE_ReturnCode = "E"; } Value = Hour.ToString("00") + ":" + Min.ToString("00") + ":" + Sec.ToString("00") + "." + MSec.ToString("000"); ReqValue = Hour.ToString("00") + Min.ToString("00") + Sec.ToString("00") + MSec.ToString("000"); return Value; } private string TimeValue(string InputValue) // Input:Integer. Output:Time as hh:mm:ss.mmm { if (InputValue == "0") return "00:00:00.000"; int IX; if (InputValue.Length < 9) { int Z = 9 - InputValue.Length; InputValue = "00000000".Substring(0,Z) + InputValue; } int Hour, Min, Sec, MSec; if (InputValue.Length > 9 || !int.TryParse(InputValue, out IX)) { return InputValue + " invalid Time"; } else { Hour = int.Parse(InputValue.Substring(0, 2)); Min = int.Parse(InputValue.Substring(2, 2)); Sec = int.Parse(InputValue.Substring(4, 2)); MSec = int.Parse(InputValue.Substring(6, 3)); String OutValue = Hour.ToString("00") + ":" + Min.ToString("00") + ":" + Sec.ToString("00") + "." + MSec.ToString("000"); return OutValue; } } // Standard Response Properties private System.Net.HttpStatusCode _StatusCode; public int StatusCode { get => (int)_StatusCode; } public string StatusCode_Value { get => _StatusCode.ToString(); } private bool _IsSuccessStatusCode; public string IsSuccessStatusCode { get => _IsSuccessStatusCode.ToString(); } private string _ReasonPhrase = null; public string ReasonPhrase { get => _ReasonPhrase; } private string _RawResponse = null; // blank except when unsuccessful request public string RawResponse { get => _RawResponse; } // Common Request/Response logic public bool RequestResponse(bool DoAssignToProperties = true) { try { var json = JsonConvert.SerializeObject(Request); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = "http://localhost:9003/cics/services/JSPG2"; var response = client.PostAsync(url, data).Result; String result = response.Content.ReadAsStringAsync().Result; _StatusCode = response.StatusCode; _ReasonPhrase = response.ReasonPhrase; _IsSuccessStatusCode = response.IsSuccessStatusCode; _RawResponse = null; if (response.IsSuccessStatusCode) { Response = JsonConvert.DeserializeObject(result); if (DoAssignToProperties) AssignResponseToProperties(true); else { _Error = Response.JSPG2Response.OJSPG2.JZ_Error.JZD_Error; _JZ_EMPLOYEE_ReturnCode = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.JZ_EMPLOYEE_ReturnCode; } return true; } // Faulty Response, hasn't thrown an exception AssignResponseToProperties(true); _RawResponse = result; _JZ_EMPLOYEE_ReturnCode = "S"; _Error = response.ReasonPhrase; return false; } catch (Exception e) { _JZ_EMPLOYEE_ReturnCode = "S"; _Error = e.Message; return false; } } public bool Enquiry(string PSkip = null,string PEMPNO = null,string PWORKDEPT = null) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; return DoRead(PSkip,PEMPNO,PWORKDEPT); } public bool ReadNext(string PSkip = null) { return Scroll(1, PSkip); } public bool ReadLast() { int PSkip; int.TryParse(JZ_EMPLOYEE_BrowseCount, out PSkip); PSkip -= 1; return Scroll(PSkip, ""); } public bool ReadPrev(string PSkip = null) { return Scroll(-1, PSkip); } public bool ReadFirst() { return Scroll(0, ""); } private bool Scroll(int Increment, string PSkip = null) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; Response.JSPG2Response.OJSPG2.JZ_Error.JZD_Error = ""; int Skip; int.TryParse(PSkip, out Skip); Skip += Increment; int BrowseCount; int.TryParse(JZ_EMPLOYEE_BrowseCount, out BrowseCount); if (Skip < 0 || Skip > BrowseCount) { _Error = "Skip Value out of Range. BrowseCount = " + BrowseCount.ToString(); _JZ_EMPLOYEE_ReturnCode = "E"; return false; } PSkip = Skip.ToString(); Request.JSPG2.IJSPG2.JZ_EMPLOYEE.EMPNO = ""; // Ensure no residue of Update/Add/Delete return DoRead(PSkip, "" ,SaveBrowse_PWORKDEPT); } public bool DoRead(string PSkip = null,string PEMPNO = null,string PWORKDEPT = null) { //For Enquiry at least one key field must be given. With duplicate keys (DKEY) scrolling is a possibility. if (PEMPNO == null && PWORKDEPT == null) { _Error = "EMPNO or WORKDEPT required for Enquiry"; _JZ_EMPLOYEE_ReturnCode = "E"; return false; } if (PEMPNO != "") { EMPNO = PEMPNO; } else { Skip = PSkip; SaveBrowse_PWORKDEPT = ""; if (PWORKDEPT != "") { WORKDEPT = PWORKDEPT; SaveBrowse_PWORKDEPT = PWORKDEPT; } } Function = "E"; AddPrivateFieldsToRequest(); return RequestResponse(); } public bool Update(string PEMPNO = null) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; //Update must follow Enquiry. // Validate Argument(s) if (PEMPNO == null) _Error = "EMPNO required for Update"; else if (PEMPNO != EMPNO) _Error = "EMPNO must not change"; if (_Error != "") { _JZ_EMPLOYEE_ReturnCode = "E"; return false; } // Set Key and Function IXT1Sub = 0; EMPNO = PEMPNO; Function = "U"; AddPrivateFieldsToRequest(); bool Result = false; int BrowseCount; int.TryParse(_JZ_EMPLOYEE_BrowseCount, out BrowseCount); Result = RequestResponse(); _JZ_EMPLOYEE_ReturnCode = "C"; _JZ_EMPLOYEE_BrowseCount = BrowseCount.ToString(); return Result; } public bool Add(string PEMPNO = null) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; // Validate Argument(s) // Set Key and Function if (Changed.EMPNO) { EMPNO = PEMPNO; } else { EMPNO = ""; } Function = "A"; AddPrivateFieldsToRequest(); bool Result = false; int BrowseCount; int.TryParse(_JZ_EMPLOYEE_BrowseCount, out BrowseCount); Result = RequestResponse(); BrowseCount += 1; _JZ_EMPLOYEE_BrowseCount = BrowseCount.ToString(); _JZ_EMPLOYEE_ReturnCode = "I"; return Result; } public bool Delete(string PEMPNO = null) { _Error = ""; _JZ_EMPLOYEE_ReturnCode = ""; // Validate Argument(s) if (PEMPNO == null) _Error = "EMPNO required for Delete"; else if (PEMPNO != EMPNO) _Error = "EMPNO must not change"; if (_Error != "") { _JZ_EMPLOYEE_ReturnCode = "E"; return false; } // Set Key and Function EMPNO = PEMPNO; Function = "D"; AddPrivateFieldsToRequest(); bool Result = false; int BrowseCount; int.TryParse(_JZ_EMPLOYEE_BrowseCount, out BrowseCount); Result = RequestResponse(false); if (_JZ_EMPLOYEE_ReturnCode != "E") { BrowseCount -= 1; _JZ_EMPLOYEE_BrowseCount = BrowseCount.ToString(); _JZ_EMPLOYEE_ReturnCode = "D"; } return Result; } // Routines. Functions and Subroutine used by methods private bool ResetChanged() { Changed.Skip = false; Changed.EMPNO = false; Changed.FIRSTNME = false; Changed.MIDINIT = false; Changed.LASTNAME = false; Changed.WORKDEPT = false; Changed.PHONENO = false; Changed.HIREDATE = false; Changed.JOB = false; Changed.EDLEVEL = false; Changed.SEX = false; Changed.BIRTHDATE = false; Changed.SALARY = false; Changed.BONUS = false; Changed.COMM = false; Changed.CURRENCY = false; Changed.DEPTMGR = false; Changed.STARTTIME = false; return true; } private void AssignResponseToProperties(bool BrowseCount) { ResetChanged(); // Mark all properties as 'Unchanged By User' ClearRequest(); // Ensure no carry-forward data // Set properties From Response _Error = Response.JSPG2Response.OJSPG2.JZ_Error.JZD_Error; _JZ_EMPLOYEE_ReadTo = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE_ReadTo.ToString(); _JZ_EMPLOYEE_NbrReturned = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE_NbrReturned.ToString(); if (BrowseCount) _JZ_EMPLOYEE_BrowseCount = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE_BrowseCount.ToString(); _JZ_EMPLOYEE_ReturnCode = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.JZ_EMPLOYEE_ReturnCode; _EMPNO = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.EMPNO; _FIRSTNME = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.FIRSTNME.JZD_FIRSTNME; _MIDINIT = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.MIDINIT; _LASTNAME = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.LASTNAME.JZD_LASTNAME; _WORKDEPT = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.WORKDEPT; _PHONENO = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.PHONENO; _HIREDATE = DateValue(Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.HIREDATE.ToString()); _JOB = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.JOB; _EDLEVEL = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.EDLEVEL.ToString(); _SEX = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.SEX; _BIRTHDATE = DateValue(Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.BIRTHDATE.ToString()); _SALARY = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.SALARY.ToString("C2"); _BONUS = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.BONUS.ToString("C2"); _COMM = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.COMM.ToString("C2"); _CURRENCY = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.JZ_CURRENCY; _DEPTMGR = BoolValue(Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.DEPTMGR); _STARTTIME = TimeValue(Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.STARTTIME.ToString()); _Checksum = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.Checksum; _DEPTNAME = Response.JSPG2Response.OJSPG2.JZ_EMPLOYEE.DEPTNAME.JZD_DEPTNAME; } private void ClearRequest() { // Clear Request, to prevent data carry-over' Request.JSPG2.IJSPG2.JZ_Function = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE_Skip = 0; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.EMPNO = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.FIRSTNME = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.MIDINIT = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.LASTNAME = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.WORKDEPT = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.PHONENO = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.HIREDATE = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.JOB = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.EDLEVEL = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.SEX = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.BIRTHDATE = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.SALARY = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.BONUS = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.COMM = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.JZ_CURRENCY = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.DEPTMGR = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.STARTTIME = null; Request.JSPG2.IJSPG2.JZ_EMPLOYEE.Checksum = null; } private void AddPrivateFieldsToRequest() { Request.JSPG2.IJSPG2.JZ_EMPLOYEE.Checksum = _Checksum; } } }