private void SaveDependentGuestPass() { if (guestDependantPassDetail == null) { guestDependantPassDetail = new GuestDependantPassDetail(); guestDependantPassDetail.NSGPassID = nsgPassId; guestDependantPassDetail.EntryDate = DateTime.Now; guestDependantPassDetail.EntryUserID = GlobalClass.LoggedInUserID; } else { guestDependantPassDetail.UpdateDate = DateTime.Now; guestDependantPassDetail.UpdateUserID = GlobalClass.LoggedInUserID; } guestDependantPassDetail.IdentificationMark = txtIdentificationMark_Guest.Text; guestDependantPassDetail.RelativeOf = txtRelativeOfName.Text; guestDependantPassDetail.NSGEmployeeCode = txtEmployeeId_Guest.Text; guestDependantPassDetail.RankID = Convert.ToInt16(cmbRank_Guest.SelectedValue); guestDependantPassDetail.UnitID = Convert.ToInt16(cmbUnit_Guest.SelectedValue); guestDependantPassDetail.RelationshipID = Convert.ToInt16(cmbRelationship.SelectedValue); if (guestDependantPassDetail.GuestDependantPassDetailID == 0) { DB.GuestDependantPassDetails.Add(guestDependantPassDetail); } DB.SaveChanges(); }
private void LoadGuestDependantPassDetail() { guestDependantPassDetail = DB.GuestDependantPassDetails.Where(gdp => gdp.NSGPassID == nsgPassId).FirstOrDefault(); txtIdentificationMark_Guest.Text = guestDependantPassDetail.IdentificationMark; txtRelativeOfName.Text = guestDependantPassDetail.RelativeOf; txtEmployeeId_Guest.Text = guestDependantPassDetail.NSGEmployeeCode; cmbRank_Guest.SelectedValue = guestDependantPassDetail.RankID; cmbUnit_Guest.SelectedValue = guestDependantPassDetail.UnitID; cmbRelationship.SelectedValue = guestDependantPassDetail.RelationshipID; }
private void RefreshMe(bool reEntry = false) { if (reEntry) { nsgPassId = 0; } nsgPass = null; civilianPassDetail = null; guestDependantPassDetail = null; vehiclePassDetail = null; outlivingPassDetail = null; passDocuments = null; cmbPassType.SelectedIndex = -1; txtFirstName.Text = string.Empty; txtLastName.Text = string.Empty; cmbGender.SelectedIndex = -1; txtMobileNo.Text = string.Empty; txtGuardianName.Text = string.Empty; txtPassHolderAddress.Text = string.Empty; cmbState.SelectedIndex = -1; cmbCity.SelectedIndex = -1; dteIssueDate.Value = DateTime.Today; dteExpiryDate.Value = DateTime.Today.AddDays(30); dteBirthDate.Value = DateTime.Today; txtDesignation.Text = string.Empty; txtContractorName.Text = string.Empty; txtIdentificationMark_Guest.Text = string.Empty; txtRelativeOfName.Text = string.Empty; txtEmployeeId_Guest.Text = string.Empty; cmbRank_Guest.SelectedIndex = -1; cmbUnit_Guest.SelectedIndex = -1; cmbRelationship.SelectedIndex = -1; txtRegistrationNumber.Text = string.Empty; txtVehicleType.Text = string.Empty; txtVehicleMake.Text = string.Empty; txtEmployeeId_Vehicle.Text = string.Empty; cmbRank_Vehicle.SelectedIndex = -1; cmbUnit_Vehicle.SelectedIndex = -1; txtIdentificationMark_Outliving.Text = string.Empty; txtBloodGroup.Text = string.Empty; txtEmployeeId_Outliving.Text = string.Empty; cmbRank_Outliving.SelectedIndex = -1; cmbUnit_Outliving.SelectedIndex = -1; picVisitorPhoto.Image = null; grpCivilianPassDetail.BackColor = Color.Gray; grpCivilianPassDetail.Enabled = false; grpGuestDependantPassDetail.BackColor = Color.Gray; grpGuestDependantPassDetail.Enabled = false; grpOutlivingPassDetail.BackColor = Color.Gray; grpOutlivingPassDetail.Enabled = false; grpVehiclePassDetail.BackColor = Color.Gray; grpVehiclePassDetail.Enabled = false; if (nsgPassId > 0) { LoadData(); this.Text = "NSG Pass [EDIT] - " + (nsgPassId).ToString().PadLeft(6, '0'); } else { var nsgLastPass = DB.NSGPasses.OrderByDescending(p => p.NSGPassID).FirstOrDefault(); if (nsgLastPass == null) { this.Text = "NSG Pass [ADD] - 000001"; } else { this.Text = "NSG Pass [ADD] - " + (nsgLastPass.NSGPassID + 1).ToString().PadLeft(6, '0'); } dteIssueDate.Value = DateTime.Today; dteExpiryDate.Value = DateTime.Today.AddDays(30); } }