private void SaveAllocation(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 infoAloc = new clsAllocation(); infoAloc.id = this.id; infoAloc.strProjectid = cmbProject.Text; infoAloc.strBlock = cmbBlock.Text; infoAloc.dtAllocationDate = dTAllocationDate.Value; infoAloc.RegistrationOrBookingNo = txtRegistrationNo.Text; infoAloc.strUnitID = txtUnit.Text; infoAloc.strClientID = txtClientID.Text; infoAloc.bitApprove = chkBoxApproved.Checked; infoAloc.strDirector = cmbDirector.Text; infoAloc.strRemarks = txtRemarks.Text; if (id == 0) { infoAloc.CreatedBy = Microsoft.Dexterity.Applications.Dynamics.Globals.UserId; infoAloc.CreationDate = DateTime.Now; infoAloc.ApprovalStatusCode = (int)ApprovalStatus.Pending; infoAloc.LastUpdateDate = new DateTime(1900, 1, 1); infoAloc.LastUpdateUser = ""; infoAloc.ApprovalActionUser = ""; infoAloc.ApprovalActionDate = new DateTime(1900, 1, 1); infoAloc.intPreviousStatusCode = infoMember.intStatusCode; } else if (id != 0) { infoAloc.CreatedBy = Microsoft.Dexterity.Applications.Dynamics.Globals.UserId; infoAloc.CreationDate = DateTime.Now; infoAloc.LastUpdateDate = DateTime.Now; infoAloc.LastUpdateUser = Microsoft.Dexterity.Applications.Dynamics.Globals.UserId;//Microsoft.Dexterity.Applications.Dynamics.Globals.UserId; infoAloc.ApprovalStatusCode = (int)approvalStatus; if (approvalStatus != ApprovalStatus.Pending) { infoAloc.ApprovalActionUser = Microsoft.Dexterity.Applications.Dynamics.Globals.UserId;; infoAloc.ApprovalActionDate = DateTime.Now; } else { infoAloc.ApprovalActionUser = ""; infoAloc.ApprovalActionDate = new DateTime(1900, 1, 1); } } bool result = da.AddAllocationINFO(infoAloc); if (result == false) { MessageBox.Show("An Error Occured"); return; } infoMember.RegistrationNo = txtRegistrationNo.Text; infoMember.ClientID = txtClientID.Text; infoMember.strProjectid = cmbProject.Text; infoMember.Block = cmbBlock.Text; infoMember.Plan = txtSizeCode.Text; infoMember.Plot = txtUnit.Text; infoMember.bitAllocated = true; // if (this.chkBoxApproved.Checked == true) if (approvalStatus == ApprovalStatus.Approved) { infoMember.intStatusCode = (int)memberLookupCodes.Allocated; } else if (approvalStatus == ApprovalStatus.Pending) { infoMember.intStatusCode = (int)memberLookupCodes.MarkedForAllocation; } infoMember.strDirectorName = cmbDirector.Text; result = da.UpdateMemberRegistrationAfterAllocation(infoMember); if (result == false) { MessageBox.Show("An Error Occured"); return; } #region //////////////////// Unit Status Unit if (approvalStatus == ApprovalStatus.Approved) { result = da.UpdateUnitStatus("Allocated", txtUnit.Text, txtRegistrationNo.Text, (int)unitLookupCodes.Allocated); } else if (approvalStatus == ApprovalStatus.Pending) { result = da.UpdateUnitStatus("Allocated", txtUnit.Text, txtRegistrationNo.Text, (int)unitLookupCodes.MarkedForAllocation); } if (result == false) { MessageBox.Show("An Error Occoured While Update Process"); return; } if (result == true) { MessageBox.Show("Allocation successful."); } #endregion Clear(); }