public static bool ClearAllControls(object ValidationWindow) { dynamic userControl = ValidationWindow as UserControl; ControlValidationStatus ValidationStatus = new ControlValidationStatus(); if (userControl == null) { userControl = ValidationWindow as Window; } foreach (S360TextBox tb in FindVisualChildren <S360TextBox>(userControl)) { tb.Clear(); } foreach (S360ComboBox cb in FindVisualChildren <S360ComboBox>(userControl)) { cb.SelectedIndex = -1; } foreach (S360RichTextBox rtb in FindVisualChildren <S360RichTextBox>(userControl)) { rtb.AppendText(string.Empty); } return(true); }
public static ControlValidationStatus ValidateAllControls(object ValidationWindow) { dynamic userControl = ValidationWindow as UserControl; ControlValidationStatus ValidationStatus = new ControlValidationStatus(); if (userControl == null) { userControl = ValidationWindow as Window; } foreach (S360TextBox tb in FindVisualChildren <S360TextBox>(userControl)) { if (tb.ControlValidation && tb.Text == string.Empty) { tb.Focus(); tb.Background = System.Windows.Media.Brushes.IndianRed; ValidationStatus.isValid = false; ValidationStatus.TextBoxControl = tb; ValidationStatus.ValidationMessage = tb.ControlValidationMessage; return(ValidationStatus); } } foreach (S360ComboBox cb in FindVisualChildren <S360ComboBox>(userControl)) { if (cb.ControlValidation && cb.SelectedIndex == -1) { cb.Focus(); cb.Background = System.Windows.Media.Brushes.IndianRed; ValidationStatus.isValid = false; ValidationStatus.ComboBoxControl = cb; ValidationStatus.ValidationMessage = cb.ControlValidationMessage; return(ValidationStatus); } } ValidationStatus.isValid = true; return(ValidationStatus); }
private void ExecuteSaveCommand(object sender) { try { ControlValidationStatus controlValidationStatus = ValidateControls.ValidateAllControls(sender); if (controlValidationStatus != null && !controlValidationStatus.isValid) { WPFCustomMessageBox.CustomMessageBox.ShowOK(controlValidationStatus.ValidationMessage, "S360 Application", "OK"); return; } STUD_Students_Master studentDetails = new STUD_Students_Master(); if (!string.IsNullOrEmpty(GRNO)) { studentDetails.RegNo = GRNO; } if (!string.IsNullOrEmpty(ReligionText)) { studentDetails.Religion = ReligionText; } if (!string.IsNullOrEmpty(StudentName)) { studentDetails.Name = StudentName; } if (!string.IsNullOrEmpty(FatherName)) { studentDetails.FatherName = FatherName; } if (!string.IsNullOrEmpty(SurName)) { studentDetails.Surname = SurName; } if (!string.IsNullOrEmpty(StudentAddress)) { studentDetails.Address = StudentAddress; } if (!string.IsNullOrEmpty(StudentRemarks)) { studentDetails.Remarks = StudentRemarks; } if (!string.IsNullOrEmpty(MotherTongue)) { studentDetails.MotherTongue = MotherTongue; } if (!string.IsNullOrEmpty(MotherName)) { studentDetails.MotherName = MotherName; } if (!string.IsNullOrEmpty(StudentDivision) && StudentDivision.Length < 3) { studentDetails.CurrentDiv = StudentDivision; } else { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Division", "S360 Application", "OK"); return; } if (DateOfBirth != null) { studentDetails.DOB = DateOfBirth; } if (!string.IsNullOrEmpty(Cast)) { studentDetails.Caste = Cast; } if (!string.IsNullOrEmpty(Mobile1)) { studentDetails.Mobile1 = Mobile1; } if (!string.IsNullOrEmpty(Mobile2)) { studentDetails.Mobile2 = Mobile2; } if (!string.IsNullOrEmpty(Mobile3)) { studentDetails.Mobile3 = Mobile3; } if (!string.IsNullOrEmpty(HomeNo)) { studentDetails.HomePh = HomeNo; } if (!string.IsNullOrEmpty(WorkNo)) { studentDetails.WorkPh = WorkNo; } if (!string.IsNullOrEmpty(Email)) { studentDetails.Email = Email; } if (!string.IsNullOrEmpty(RFID)) { studentDetails.RFIDTag = RFID; } if (!string.IsNullOrEmpty(AadharNo)) { studentDetails.AadharNo = AadharNo; } if (!string.IsNullOrEmpty(Contact1)) { studentDetails.PrimaryContact = Contact1; } if (SelectedCategory != null) { studentDetails.Category_ID = SelectedCategory.Category_Id; } if (SelectedStandard != null) { studentDetails.CurrentStd_ID = SelectedStandard.Standard_Id; } if (SelectedLanguage != null) { studentDetails.Language_ID = SelectedLanguage.Language_Id; } if (!string.IsNullOrEmpty(SelectedGender) && SelectedGender.Length < 2) { studentDetails.Gender = SelectedGender; } if (SelectedReligion != null) { studentDetails.Religion_ID = SelectedReligion.Religion_Id; } studentDetails.CurrentAcaDetail_ID = 1; studentDetails.LastModifiedBy_ID = S360Configuration.Instance.UserID; studentDetails.LastModifiedOn = DateTime.Now; studentDetails.IsActive = true; studentDetails.EnteredBy_ID = S360Configuration.Instance.UserID; studentDetails.EnteredOn = DateTime.Now; STUD_Students_Master studentdetails = studentBusinessLogic.SaveStudent(studentDetails); if (studentdetails != null) { STUD_StudentAcademic_Details AcademicDetails = new STUD_StudentAcademic_Details(); AcademicDetails.Section_ID = SelectedSection.Section_Id; AcademicDetails.AcademicYearStart = S360Configuration.Instance.AcademicYearStart; AcademicDetails.AcademicYearEnd = S360Configuration.Instance.AcademicYearEnd; STUD_StudentAcademic_Details result = studentBusinessLogic.SaveStudentAcademicDetails(studentdetails, AcademicDetails); if (result != null) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Student Saved Sucessfull", "S360 Application", "OK"); bool clearAll = ValidateControls.ClearAllControls(sender); } } } catch (Exception ex) { throw new S360Exception(ex.Message, ex.InnerException); } }
private void ExecuteAddChequeCommand(object sender) { View.Cheque.UC_ChequeInwardScreen uccheque = sender as View.Cheque.UC_ChequeInwardScreen; ChequeBusinessLogic business; try { ControlValidationStatus validation = ValidateControls.ValidateAllControls(sender); if (validation != null && !validation.isValid) { WPFCustomMessageBox.CustomMessageBox.ShowOK(validation.ValidationMessage, "S360 Application", "OK"); return; } decimal chequeNo = 0; decimal Amt = 0; decimal.TryParse(CurrentChequeInwardModel.ChequeNo, out chequeNo); if (string.IsNullOrEmpty(CurrentChequeInwardModel.ChequeNo) || chequeNo <= 0) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Cq. No", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtCqNo").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } if (!decimal.TryParse(CurrentChequeInwardModel.ChqAmount.ToString(), out Amt)) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Amount", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtAmt").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } if (Amt <= 0) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Amount", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtAmt").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } if (this._chequeList == null) { _chequeList = new ObservableCollection <ChequeInwardsModel>(); } CurrentChequeInwardModel.User = LoginBusinessLogic.GetUserByID(S360Configuration.Instance.UserID).Username; CurrentChequeInwardModel.EnteredBy = S360Model.S360Configuration.Instance.UserID; CurrentChequeInwardModel.Login_ID = S360Model.S360Configuration.Instance.LoginID; business = new ChequeBusinessLogic(); CurrentChequeInwardModel = ConvertToCheque(business.SaveChequeTemp(ConvertToCheque(CurrentChequeInwardModel, true) as CHQ_Cheques_Master_Temp), false) as ChequeInwardsModel; CurrentChequeInwardModel.SerialNo = ChequeList.Count + 1; ChequeList.Add(CurrentChequeInwardModel); } catch (Exception ex) { throw new S360Exceptions.S360Exception(ex.Message, ex.InnerException); } CurrentChequeInwardModel = null; business = null; }
private void ExecuteSaveChqCommand(object sender) { View.Cheque.UC_ChequeEditScreen uccheque = sender as View.Cheque.UC_ChequeEditScreen; ChequeBusinessLogic chequeBussiness; try { ControlValidationStatus status = ValidateControls.ValidateAllControls(uccheque); if (status != null && !status.isValid) { WPFCustomMessageBox.CustomMessageBox.ShowOK(status.ValidationMessage, "S360 Application", "OK"); return; } decimal chequeNo = 0; decimal Amt = 0; decimal.TryParse(CurrentChequeInwardModel.ChequeNo, out chequeNo); if (string.IsNullOrEmpty(CurrentChequeInwardModel.ChequeNo) || chequeNo <= 0) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Cq. No", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtCqNo").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } if (!decimal.TryParse(CurrentChequeInwardModel.ChqAmount.ToString(), out Amt)) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Amount", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtAmt").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } if (Amt <= 0) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Invalid Amount", "Warning", "OK"); S360Controlls.BasicControls.S360TextBox txt = FindVisualChildren <S360Controlls.BasicControls.S360TextBox>(uccheque).Where(S => S.Name == "txtAmt").FirstOrDefault(); txt.Text = string.Empty; txt.Focus(); return; } chequeBussiness = new ChequeBusinessLogic(); CHQ_Cheques_Master model = new CHQ_Cheques_Master() { Student_ID = CurrentChequeInwardModel.Student_ID, Bank = CurrentChequeInwardModel.Bank, ChequeNo = CurrentChequeInwardModel.ChequeNo, Cheque_ID = CurrentChequeInwardModel.Cheque_ID, ChqAmount = CurrentChequeInwardModel.ChqAmount, ChqStatus_ID = CurrentChequeInwardModel.ChqStatus_ID, EnteredBy = CurrentChequeInwardModel.EnteredBy, //EnteredBy = S360Configuration.Instance.UserID, EnteredOn = CurrentChequeInwardModel.EnteredOn, InwardDate = CurrentChequeInwardModel.InwardDate, IsActive = CurrentChequeInwardModel.IsActive, Login_ID = S360Configuration.Instance.LoginID, Remarks = CurrentChequeInwardModel.Remarks, Section_ID = CurrentChequeInwardModel.Section_ID }; chequeBussiness.UpdateCheque(model); CurrentChequeInwardModel = new ChequeInwardsModel() { RegNo = SelectedCheque.RegNo, StudentName = SelectedCheque.StudentName, Student_ID = SelectedCheque.Student_ID, Section = SelectedCheque.Section, Section_ID = SelectedCheque.Section_ID }; IEnumerable <CHQ_Cheques_Master> cheques = chequeBussiness.GetAllCheques().Where(C => C.Student_ID == CurrentChequeInwardModel.Student_ID && C.ChqStatus_ID == 1 /*Cheque Recieved*/ && C.IsActive == true); ChequeList.Clear(); int serialNo = 1; foreach (CHQ_Cheques_Master chq in cheques) { this.ChequeList.Add(ConvertToCheque(chq, serialNo++)); } this.SelectedCheque = null; } catch (Exception ex) { throw new S360Exceptions.S360Exception(ex.Message, ex.InnerException); } finally { //ExecuteClearCommand(null); chequeBussiness = null; } }