private void tbxFirstName_TextChanged(object sender, EventArgs e) { EFERTDbUtility.ValidateInputs(new List <TextBox>() { this.tbxCheckInCardNumber, this.tbxFirstName }); }
private void btnBlock_Click(object sender, EventArgs e) { bool validtated = EFERTDbUtility.ValidateInputs(new List <TextBox>() { this.tbxFirstName, this.tbxCNICNumber, this.tbxBlockedBy, this.tbxBlockedReason }); if (!validtated) { MessageBox.Show(this, "Please fill mandatory fields first."); return; } DialogResult result = MessageBox.Show(this, "Are you sure you want to block this person?", "Confirmation Dialog", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } if (this.tbxBlockedBy.Text == EFERTDbUtility.CONST_SYSTEM_BLOCKED_BY) { MessageBox.Show(this, "Block by \"System\" can not be used."); return; } BlockedPersonInfo blockedPerson = this.BlockPerson(this.tbxBlockedBy.Text, this.tbxBlockedReason.Text); if (blockedPerson != null) { this.UpdateLayoutForBlockedPerson(blockedPerson); } }
private void btnCheckIn_Click(object sender, EventArgs e) { string cardNumber = this.tbxCheckInCardNumber.Text; if (!this.tbxCnicNumber.MaskCompleted) { MessageBox.Show(this, "Please Enter correct CNIC NUMBER."); this.tbxCnicNumber.ReadOnly = false; this.tbxCnicNumber.BackColor = System.Drawing.Color.White; return; } bool validtated = EFERTDbUtility.ValidateInputs(new List <TextBox>() { this.tbxFirstName, this.tbxCheckInCardNumber }); if (validtated && this.cbxVFCategory.SelectedItem == null || string.IsNullOrEmpty(this.cbxVFCategory.SelectedItem.ToString().Trim())) { validtated = false; } if (!validtated) { MessageBox.Show(this, "Please fill mandatory fields first."); return; } bool isCardNotReturned = this.mCheckIns.Any(checkInInfo => checkInInfo.CheckedIn && checkInInfo.CardNumber == cardNumber); CCFTCentralDb.CCFTCentral ccftCentralDb = new CCFTCentralDb.CCFTCentral(); bool cardExist = ccftCentralDb.Cardholders.Any(card => card.LastName == cardNumber); if (cardExist && !isCardNotReturned) { var cardAlreadyIssued = (from checkin in EFERTDbUtility.mEFERTDb.CheckedInInfos where checkin != null && checkin.CheckedIn && checkin.CardNumber == cardNumber select new { checkin.CheckedIn, checkin.CNICNumber }).FirstOrDefault(); if (cardAlreadyIssued != null && cardAlreadyIssued.CheckedIn) { MessageBox.Show(this, "This card is already issue to the person with CNIC number: " + cardAlreadyIssued.CNICNumber); return; } if (this.mVisitor == null) { VisitorCardHolder visitor = new VisitorCardHolder(); visitor.CNICNumber = this.tbxCnicNumber.Text; visitor.Gender = this.cbxGender.SelectedItem == null ? string.Empty : this.cbxGender.SelectedItem as String; visitor.FirstName = this.tbxFirstName.Text; visitor.LastName = this.tbxLastName.Text; visitor.Address = this.tbxAddress.Text; visitor.PostCode = this.tbxPostCode.Text; visitor.City = this.tbxCity.Text; visitor.State = this.tbxState.Text; visitor.CompanyName = this.tbxCompanyName.Text; visitor.ContactNo = this.tbxPhoneNumber.Text; visitor.EmergencyContantPerson = this.tbxEmergencyContact.Text; visitor.EmergencyContantPersonNumber = this.tbxEmergencyContactNumber.Text; visitor.VisitorType = this.cbxVisitorType.SelectedItem == null ? string.Empty : this.cbxVisitorType.SelectedItem as String; visitor.IsOnPlant = SearchForm.mIsPlant; if (this.pbxSnapShot.Image != null) { visitor.Picture = EFERTDbUtility.ImageToByteArray(this.pbxSnapShot.Image); } if (this.mSchoolingStaff) { visitor.SchoolName = this.cbxSchoolCollege.SelectedItem == null ? string.Empty : this.cbxSchoolCollege.SelectedItem as String; } visitor.VisitorInfo = this.mVisitorInfo; EFERTDbUtility.mEFERTDb.Visitors.Add(visitor); //EFERTDbUtility.mEFERTDb.SaveChanges(); this.mVisitor = visitor; } CheckInAndOutInfo checkedInInfo = new CheckInAndOutInfo(); checkedInInfo.CheckInToPlant = SearchForm.mIsPlant; checkedInInfo.CheckInToPlant = !SearchForm.mIsPlant; checkedInInfo.FirstName = this.mVisitor.FirstName; checkedInInfo.Visitors = this.mVisitor; checkedInInfo.CNICNumber = this.mCNICNumber; checkedInInfo.CardNumber = this.tbxCheckInCardNumber.Text; checkedInInfo.VehicleNmuber = this.tbxCheckInVehicleNumber.Text; checkedInInfo.NoOfMaleGuest = this.nuNoOfMaleGuest.Value; checkedInInfo.NoOfFemaleGuest = this.nuNoOfFemaleGuest.Value; checkedInInfo.DurationOfStay = this.numCheckInDurationOfStay.Value; checkedInInfo.NoOfChildren = this.nuCheckInNoOfChildren.Value; checkedInInfo.AreaOfVisit = this.cbxAreaOfVisit.SelectedItem == null ? string.Empty : this.cbxAreaOfVisit.SelectedItem as String; checkedInInfo.HostName = this.tbxCheckInHostName.Text; checkedInInfo.DateTimeIn = Convert.ToDateTime(this.tbxCheckInDateTimeIn.Text); checkedInInfo.DateTimeOut = DateTime.MaxValue; checkedInInfo.CheckedIn = true; checkedInInfo.Category = this.mVisitorInfo; try { EFERTDbUtility.mEFERTDb.CheckedInInfos.Add(checkedInInfo); EFERTDbUtility.mEFERTDb.SaveChanges(); } catch (Exception ex) { EFERTDbUtility.RollBack(); MessageBox.Show(this, "Some error occurred in issuing card.\n\n" + EFERTDbUtility.GetInnerExceptionMessage(ex)); return; } this.btnCheckIn.Enabled = false; this.btnCheckOut.Enabled = true; this.Close(); } else { if (!cardExist) { MessageBox.Show(this, "Please enter valid card number."); } else if (isCardNotReturned) { MessageBox.Show(this, "Card is already issued to some one else."); } } }
private void btnUnBlock_Click(object sender, EventArgs e) { if (!this.tbxCnicNumber.MaskCompleted) { MessageBox.Show(this, "Please Enter correct CNIC NUMBER."); this.tbxCnicNumber.ReadOnly = false; this.tbxCnicNumber.BackColor = System.Drawing.Color.White; return; } bool validtated = EFERTDbUtility.ValidateInputs(new List <TextBox>() { this.tbxFirstName, this.tbxUnBlockedBy, this.tbxUnblockReason }); if (!validtated) { MessageBox.Show(this, "Please fill mandatory fields first."); return; } DialogResult result = MessageBox.Show(this, "Are you sure you want to block this person?", "Confirmation Dialog", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } if (this.mBlocks.Exists(blocked => blocked.Blocked && blocked.CNICNumber == this.mCNICNumber)) { BlockedPersonInfo blockedPerson = this.mBlocks.Find(blocked => blocked.Blocked && blocked.CNICNumber == this.mCNICNumber); blockedPerson.Blocked = false; blockedPerson.UnBlockTime = DateTime.Now; blockedPerson.UnBlockedBy = this.tbxUnBlockedBy.Text; blockedPerson.UnBlockedReason = this.tbxUnblockReason.Text; try { EFERTDbUtility.mEFERTDb.Entry(blockedPerson).State = System.Data.Entity.EntityState.Modified; EFERTDbUtility.mEFERTDb.SaveChanges(); } catch (Exception ex) { EFERTDbUtility.RollBack(); MessageBox.Show(this, "Some error occurred in unblocking cardholder.\n\n" + EFERTDbUtility.GetInnerExceptionMessage(ex)); return; } if (this.mCheckIns.Exists(checkedIn => checkedIn.CheckedIn && checkedIn.CNICNumber == this.mCNICNumber)) { this.btnCheckIn.Enabled = false; this.btnCheckOut.Enabled = true; } else { this.btnCheckIn.Enabled = true; this.btnCheckOut.Enabled = false; } this.mBlocks = this.mVisitor.BlockingInfos; this.tbxBlockedBy.Text = string.Empty; this.tbxBlockedReason.Text = string.Empty; this.lblVisitorStatus.Text = "Allowed"; this.lblVisitorStatus.BackColor = Color.Green; this.tbxUnBlockTime.Text = blockedPerson.UnBlockTime.ToString(); this.btnBlock.Enabled = true; this.btnUnBlock.Enabled = false; this.tbxBlockedBy.ReadOnly = false; this.tbxBlockedReason.ReadOnly = false; this.tbxBlockedBy.BackColor = System.Drawing.Color.White; this.tbxBlockedReason.BackColor = System.Drawing.Color.White; this.tbxUnBlockedBy.ReadOnly = true; this.tbxUnblockReason.ReadOnly = true; this.tbxUnBlockedBy.BackColor = System.Drawing.SystemColors.ButtonFace; this.tbxUnblockReason.BackColor = System.Drawing.SystemColors.ButtonFace; } else { MessageBox.Show(this, "This user is not blocked."); } }
private void btnBlock_Click(object sender, EventArgs e) { if (!this.tbxCnicNumber.MaskCompleted) { MessageBox.Show(this, "Please Enter correct CNIC NUMBER."); this.tbxCnicNumber.ReadOnly = false; this.tbxCnicNumber.BackColor = System.Drawing.Color.White; return; } bool validtated = EFERTDbUtility.ValidateInputs(new List <TextBox>() { this.tbxFirstName, this.tbxBlockedBy, this.tbxBlockedReason }); if (!validtated) { MessageBox.Show(this, "Please fill mandatory fields first."); return; } DialogResult result = MessageBox.Show(this, "Are you sure you want to block this person?", "Confirmation Dialog", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } if (this.tbxBlockedBy.Text == EFERTDbUtility.CONST_SYSTEM_BLOCKED_BY) { MessageBox.Show(this, "Block by \"System\" can not be used."); return; } if (this.mVisitor == null) { VisitorCardHolder visitor = new VisitorCardHolder(); visitor.CNICNumber = this.tbxCnicNumber.Text; visitor.Gender = this.cbxGender.SelectedItem == null ? string.Empty : this.cbxGender.SelectedItem as String; visitor.FirstName = this.tbxFirstName.Text; visitor.LastName = this.tbxLastName.Text; visitor.Address = this.tbxAddress.Text; visitor.PostCode = this.tbxPostCode.Text; visitor.City = this.tbxCity.Text; visitor.State = this.tbxState.Text; visitor.CompanyName = this.tbxCompanyName.Text; visitor.ContactNo = this.tbxPhoneNumber.Text; visitor.EmergencyContantPerson = this.tbxEmergencyContact.Text; visitor.EmergencyContantPersonNumber = this.tbxEmergencyContactNumber.Text; visitor.VisitorType = this.cbxVisitorType.SelectedItem == null ? string.Empty : this.cbxVisitorType.SelectedItem as String; visitor.IsOnPlant = SearchForm.mIsPlant; if (this.mSchoolingStaff) { visitor.SchoolName = this.cbxSchoolCollege.SelectedItem == null ? string.Empty : this.cbxSchoolCollege.SelectedItem as String; } visitor.VisitorInfo = this.mVisitorInfo; if (this.pbxSnapShot.Image != null) { visitor.Picture = EFERTDbUtility.ImageToByteArray(this.pbxSnapShot.Image); } EFERTDbUtility.mEFERTDb.Visitors.Add(visitor); //EFERTDbUtility.mEFERTDb.SaveChanges(); this.mVisitor = visitor; } BlockedPersonInfo blockedPerson = this.BlockPerson(this.tbxBlockedBy.Text, this.tbxBlockedReason.Text); if (blockedPerson != null) { this.UpdateLayoutForBlockedPerson(blockedPerson); } }