private void btnUpdate_Click(object sender, EventArgs e) { myScreen.myPJEMPPJT = (ctDynamicsSL.project.timeAndExpense.maintenance.projectEmployeePositionRateMaintenance.PJEMPPJT[])gvPJEMPPJT.DataSource; try { var validate = myPEPRMService.editScreen("VALIDATEONLY", myScreen); if (validate.errorMessage.Trim() != "") { MessageBox.Show(validate.errorMessage); return; } else { var result = myPEPRMService.editScreen("UPDATE", myScreen); if (result.errorMessage.Trim() != "") { MessageBox.Show(result.errorMessage); return; } else { myScreen = result; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); gvPJEMPPJT.DataSource = myScreen.myPJEMPPJT; MessageBox.Show("Update Complete!"); } } } catch (Exception ex) { MessageBox.Show("Unexpected error in Update: " + ex.Message); } }
private void btnNew_Click(object sender, EventArgs e) { if (myScreen == null) { MessageBox.Show("You must load an employee first."); return; } var newEntry = new ctDynamicsSL.project.timeAndExpense.maintenance.projectEmployeePositionRateMaintenance.PJEMPPJT(); newEntry.employee = myScreen.myPJEMPLOY.employee; //required newEntry = myPEPRMService.getNewPJEMPPJT(newEntry); //get any employee specific defaults newEntry.effect_date = System.DateTime.Now.AddDays(myScreen.myPJEMPPJT.Length); //required, setting date just for example newEntry.project = myPEPRMService.getProjectsByID("")[0].project; //required, just picking first one found from search; try { var outScreen = myScreen; //create a temporary duplicate of the loaded screen var outEntries = new System.Collections.Generic.List <ctDynamicsSL.project.timeAndExpense.maintenance.projectEmployeePositionRateMaintenance.PJEMPPJT>(); outEntries.AddRange(myScreen.myPJEMPPJT); //add original entries from screen. outEntries.Add(newEntry); //add our new entry to the array. outScreen.myPJEMPPJT = outEntries.ToArray(); var validate = myPEPRMService.editScreen("VALIDATEONLY", outScreen); if (validate.errorMessage.Trim() != "") { MessageBox.Show(validate.errorMessage); return; } else { var result = myPEPRMService.editScreen("", outScreen);//leaving actionType blank will let the system determine if entries are new based on the keys. if (result.errorMessage.Trim() != "") { MessageBox.Show(result.errorMessage); return; } else { myScreen = result; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); gvPJEMPPJT.DataSource = myScreen.myPJEMPPJT; MessageBox.Show("New Complete!"); } } } catch (Exception ex) { MessageBox.Show("Unexpected error in New:: " + ex.Message); } }
private void btnLoad_Click(object sender, EventArgs e) { try { myScreen = myPEPRMService.getScreenByEmployee(tbEmployee.Text.Trim()); if (myScreen.errorMessage != "") { MessageBox.Show("Error: " + myScreen.errorMessage); return; } btnUpdate.Enabled = true; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); gvPJEMPPJT.DataSource = myScreen.myPJEMPPJT; } catch (Exception ex) { MessageBox.Show("Unexpected error in Load: " + ex.Message); } }