/// <summary> /// Converts the input ChequeMaster object to its model object type /// </summary> /// <param name="cheque"></param> /// <returns></returns> private ChequeInwardsModel ConvertToCheque(CHQ_Cheques_Master cheque, int SerialNo) { if (cheque == null) { return(new ChequeInwardsModel()); } StudentBusinessLogic bussiness = new StudentBusinessLogic(); //STUD_Students_Master student = bussiness.GetAllStudents().Where(S => S.Student_ID == cheque.Student_ID).FirstOrDefault(); //GEN_Sections_Lookup sec = bussiness.GetAllSections().Where(S => S.Section_Id == cheque.Section_ID).FirstOrDefault(); ChequeInwardsModel cheq = new ChequeInwardsModel(); cheq.SerialNo = SerialNo; cheq.Student_ID = cheque.Student_ID; cheq.Bank = cheque.Bank; cheq.ChequeNo = cheque.ChequeNo; cheq.Cheque_ID = cheque.Cheque_ID; cheq.ChqAmount = cheque.ChqAmount; cheq.ChqStatus_ID = cheque.ChqStatus_ID; cheq.EnteredBy = cheque.EnteredBy; cheq.EnteredOn = cheque.EnteredOn; cheq.InwardDate = cheque.InwardDate; cheq.IsActive = cheque.IsActive; cheq.Login_ID = cheque.Login_ID; cheq.Remarks = cheque.Remarks; cheq.Section_ID = cheque.Section_ID; cheq.RegNo = CurrentChequeInwardModel.RegNo; cheq.StudentName = CurrentChequeInwardModel.StudentName; cheq.Section = CurrentChequeInwardModel.Section; cheq.User = LoginBusinessLogic.GetUserByID(LoginBusinessLogic.GetUserIdByLoginId((decimal)cheque.Login_ID)).Username; return(cheq); }
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; }