private void SaveCancellation(ApprovalStatus approvalStatus) { if (EntryApproved != ApprovalStatus.Pending) { MessageBox.Show("This entry has already been Approved/Rejected"); return; } if (id == 0 && approvalStatus != ApprovalStatus.Pending) { MessageBox.Show("This entry needs to be saved first before approval process."); return; } var clsCan = new clsCancellation(); clsCan.id = id; clsCan.RegistrationOrBookingNo = txtRegistrationNo.Text; clsCan.ClientID = txtClientID.Text; clsCan.CancellationDate = dTCancellationDate.Value; clsCan.Remarks = txtRemarks.Text.Trim(); clsCan.strProjectid = txtProjectNo.Text; clsCan.strBlock = txtBlockNo.Text; clsCan.strUnitID = txtUnit.Text; clsCan.Approved = chkBoxApproved.Checked; if (id == 0) { clsCan.CreatedBy = Program._userid; clsCan.CreationDate = DateTime.Now; clsCan.ApprovalStatusCode = (int)ApprovalStatus.Pending; clsCan.LastUpdateDate = new DateTime(1900, 1, 1); clsCan.LastUpdateUser = ""; clsCan.ApprovalActionUser = ""; clsCan.ApprovalActionDate = new DateTime(1900, 1, 1); clsCan.intPreviousStatusCode = infoMember.intStatusCode; } else if (id != 0) { clsCan.CreatedBy = Program._userid; clsCan.CreationDate = DateTime.Now; clsCan.LastUpdateDate = DateTime.Now; clsCan.LastUpdateUser = Program._userid; clsCan.ApprovalStatusCode = (int)approvalStatus; if (approvalStatus != ApprovalStatus.Pending) { clsCan.ApprovalActionUser = Program._userid; clsCan.ApprovalActionDate = DateTime.Now; } else { clsCan.ApprovalActionUser = ""; clsCan.ApprovalActionDate = new DateTime(1900, 1, 1); } } bool result = da.AddCancellationInfo(clsCan); if (result == false) { MessageBox.Show("An Error Occured"); return; } infoMember.RegistrationNo = txtRegistrationNo.Text; infoMember.ClientID = txtClientID.Text; if (approvalStatus == ApprovalStatus.Approved) { infoMember.intStatusCode = (int)memberLookupCodes.Cancelled; } else if (approvalStatus == ApprovalStatus.Pending) { infoMember.intStatusCode = (int)memberLookupCodes.MarkedForCancellation; } result = da.UpdateMemberRegistrationAfterCancellation(infoMember); if (result == false) { MessageBox.Show("An Error Occured"); return; } if (txtUnit.Text != "" && approvalStatus == ApprovalStatus.Approved) { result = da.UpdateUnitStatus("Marked for Cancellation", txtUnit.Text, txtRegistrationNo.Text, (int)unitLookupCodes.Available); if (result == false) { MessageBox.Show("An Error Occurred."); return; } } if (result == true) { MessageBox.Show("Cancellation successful."); Clear(); } }