public ChequeInwardViewModel()
        {
            ChequeBusinessLogic bussiness = new ChequeBusinessLogic();

            AddToChequeList(bussiness.GetAllUnsavedCheques());
            bussiness = null;
        }
        private void ExecuteFindStudentWithGRCommand(object obj)
        {
            if (String.IsNullOrEmpty(SelectedSection.Name))
            {
                WPFCustomMessageBox.CustomMessageBox.ShowOK("Please Select Any Section", "Warning", "OK");
                return;
            }

            S360Model.PromoteStudentModel student = new StudentBusinessLogic().GetStudentWithRegNoAndSection(this.CurrentChequeInwardModel.RegNo, this.SelectedSection.Section_Id);

            if (student == null)
            {
                WPFCustomMessageBox.CustomMessageBox.ShowOK("No Records Found", "Message", "OK");
                this.CurrentChequeInwardModel.RegNo = string.Empty;
                this.CurrentChequeInwardModel       = null;
            }
            else
            {
                CurrentChequeInwardModel.Student_ID  = student.StudentId;
                CurrentChequeInwardModel.StudentName = student.Name + " " + student.SurName + " " + student.Father;
                CurrentChequeInwardModel.RegNo       = student.RegNo;
                CurrentChequeInwardModel.Section_ID  = student.SectionId;
                CurrentChequeInwardModel.Section     = student.Section;
                RaisePropertyChanged("CurrentChequeInwardModel");

                ChequeBusinessLogic business             = new ChequeBusinessLogic();
                IEnumerable <CHQ_Cheques_Master> cheques = business.GetAllCheques().Where(C => C.Student_ID == student.StudentId &&
                                                                                          C.ChqStatus_ID == 1 /*Chq Recieved*/ && C.IsActive == true);
                int serialNo = 1;
                foreach (CHQ_Cheques_Master chq in cheques)
                {
                    this.ChequeList.Add(ConvertToCheque(chq, serialNo++));
                }
            }
        }
        private void ExecuteFindStudent(object sender)
        {
            UC_FindStudentScreen findStuent = new UC_FindStudentScreen();

            findStuent.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            FindStudentViewModel findStudentVM = new FindStudentViewModel();

            findStudentVM.SelectedSection = this._selectedSection;
            findStuent.DataContext        = findStudentVM;
            if (findStuent.ShowDialog() == true)
            {
                findStudentVM = findStuent.DataContext as FindStudentViewModel;
                if (findStudentVM.SelectedStudent != null && findStudentVM.SelectedStudent.StudentId > 0)
                {
                    CurrentChequeInwardModel.Student_ID  = findStudentVM.SelectedStudent.StudentId;
                    CurrentChequeInwardModel.StudentName = findStudentVM.SelectedStudent.Name + " " + findStudentVM.SelectedStudent.SurName + " " + findStudentVM.SelectedStudent.Father;
                    CurrentChequeInwardModel.RegNo       = findStudentVM.SelectedStudent.RegNo;
                    CurrentChequeInwardModel.Section_ID  = findStudentVM.SelectedStudent.SectionId;
                    CurrentChequeInwardModel.Section     = findStudentVM.SelectedStudent.Section;
                    RaisePropertyChanged("CurrentChequeInwardModel");

                    ChequeBusinessLogic business             = new ChequeBusinessLogic();
                    IEnumerable <CHQ_Cheques_Master> cheques = business.GetAllCheques().Where(C => C.Student_ID == findStudentVM.SelectedStudent.StudentId &&
                                                                                              C.ChqStatus_ID == 1 /*Chq Recieved*/ && C.IsActive == true);
                    int serial = 1;
                    foreach (CHQ_Cheques_Master chq in cheques)
                    {
                        this.ChequeList.Add(ConvertToCheque(chq, serial++));
                    }
                }
            }
        }
        private void ExecuteDeleteCQCommand(object sender)
        {
            ChequeBusinessLogic business = new ChequeBusinessLogic();

            business.DeleteTempCheque(ConvertToCheque(SelectedCheque, true) as CHQ_Cheques_Master_Temp);
            ChequeList.Remove(SelectedCheque);
            ChequeList     = ChequeList.Select(S => { S.SerialNo = ChequeList.IndexOf(S) + 1; return(S); }).ToList().ToObservableCollection();
            business       = null;
            SelectedCheque = null;
        }
        private void ExecuteSaveChqCommand(object sender)
        {
            if (ChequeList.Count == 0)
            {
                WPFCustomMessageBox.CustomMessageBox.ShowOK("No records to save", "Info", "OK");
                return;
            }

            ChequeBusinessLogic chequeBussiness = new ChequeBusinessLogic();

            foreach (ChequeInwardsModel cheque in ChequeList)
            {
                chequeBussiness.DeleteTempCheque(ConvertToCheque(cheque, true) as CHQ_Cheques_Master_Temp);
                CHQ_Cheques_Master entity = new CHQ_Cheques_Master()
                {
                    Bank         = cheque.Bank,
                    ChequeNo     = cheque.ChequeNo,
                    Cheque_ID    = cheque.Cheque_ID,
                    ChqAmount    = cheque.ChqAmount,
                    ChqStatus_ID = 1, //Cheque Recieved
                    EnteredBy    = cheque.EnteredBy,
                    EnteredOn    = cheque.EnteredOn,
                    InwardDate   = cheque.InwardDate,
                    IsActive     = true,
                    Login_ID     = S360Model.S360Configuration.Instance.LoginID,
                    Remarks      = cheque.Remarks,
                    Section_ID   = cheque.Section_ID,
                    Student_ID   = cheque.Student_ID
                };
                chequeBussiness.SaveCheque(entity);
            }

            ExecuteClearCommand(null);
            ChequeList.Clear();
            chequeBussiness = null;
            //SelectedSection = null;
            CurrentChequeInwardModel = null;
        }
        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;
            }
        }
Ejemplo n.º 8
0
 private void ExecuteLoadCheques(object sender)
 {
     ChequeBusinessLogic chqBusiness = new ChequeBusinessLogic( );
     //_chequeList = chqBusiness.GetAllCheques().Where(s => s.Section_ID == _sectionId).ToObservableCollection();
 }