public SchemasEditModel AddSchemas(SchemasEditModel newSchemasEditModel) { try { lesson_schemas schemas = new lesson_schemas(); schemas.class_type_id = newSchemasEditModel.TypeId; schemas.lesson_name = newSchemasEditModel.LessonName; schemas.level_name = newSchemasEditModel.LevelName; schemas.sequence_num = newSchemasEditModel.Seq; _unitOfWork.AddAction(schemas, DataActions.Add); _unitOfWork.Save(); newSchemasEditModel.Id = schemas.lesson_schemas_id; return(newSchemasEditModel); } catch (RepositoryException rex) { string msg = rex.Message; string reason = rex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } catch (Exception ex) { string msg = ex.Message; string reason = ex.StackTrace; throw new FaultException <LCFault> (new LCFault(msg), reason); } }
private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { string strErrorMsg = string.Empty; SchemasEditModel schemasEditModel = new SchemasEditModel(); try { classTypeAsyncProxy = await Task.Run(() => ServiceHelper.GetClassTypeService()); int seq = await classTypeAsyncProxy.CallAsync(c => c.GetMaxSeqByClassType(this.classTypeId)); this.numSeq.Value = seq + 1; } catch (TimeoutException timeProblem) { strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; } catch (FaultException <LCFault> af) { strErrorMsg = af.Detail.Message; } catch (FaultException unknownFault) { strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; } catch (CommunicationException commProblem) { strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; } catch (Exception ex) { strErrorMsg = ex.Message; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "初始化界面失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); return; } if (Om == OperationMode.AddMode) { this.Title = "AddSchemas"; //txtName.IsEnabled = true; //BindClassInfo(); } else { this.Title = "EditSchemas"; //txtName.IsEnabled = false; //BindClassInfo(); } }
private IList <SchemasEditModel> BuildModelList(List <lesson_schemas> schemas) { if (schemas == null) { return(null); } else { IList <SchemasEditModel> moduledisplays = new List <SchemasEditModel>(); foreach (lesson_schemas s in schemas) { SchemasEditModel moduledisplay = BuildModel(s); moduledisplays.Add(moduledisplay); } return(moduledisplays); } }
private SchemasEditModel BuildModel(lesson_schemas schemas) { if (schemas == null) { return(null); } else { SchemasEditModel schemasModel = new SchemasEditModel(); schemasModel.TypeId = schemas.class_type_id; schemasModel.Id = schemas.lesson_schemas_id; schemasModel.LessonName = schemas.lesson_name; schemasModel.LevelName = schemas.level_name; schemasModel.Seq = schemas.sequence_num.Value; return(schemasModel); } }
private async void btnOK_Click(object sender, RoutedEventArgs e) { #region 新增 if (Om == OperationMode.AddMode) { string strErrorMsg = string.Empty; try { SchemasEditModel newSchemasModel = new SchemasEditModel(); newSchemasModel.LessonName = txtLesson.Text.Trim(); newSchemasModel.LevelName = txtLevel.Text.Trim(); newSchemasModel.Seq = Convert.ToInt16(numSeq.Value); newSchemasModel.TypeId = this.classTypeId; newSchemasModel = await classTypeAsyncProxy.CallAsync(c => c.AddSchemas(newSchemasModel)); this.ShowAutoCloseDialogOwter(UIResources.MsgInfo, "Add Schemas Sucess!"); this.DialogResult = true; } catch (TimeoutException timeProblem) { strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; } catch (FaultException <LCFault> af) { strErrorMsg = af.Detail.Message; } catch (FaultException unknownFault) { strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; } catch (CommunicationException commProblem) { strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "新增班级失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } } #endregion #region 修改 //else //{ // string strErrorMsg = string.Empty; // try // { // classEditModel.Name = txtName.Text.Trim(); // classEditModel.TypeId = (cmbClassType.SelectedItem as ClassTypeModel).Id; // classEditModel.LastCount = Convert.ToInt16(numLastCount.Value); // classEditModel.StartDate = dateStart.DisplayDate; // classEditModel.EndDate = dateEnd.DisplayDate; // classEditModel = await classesAsyncProxy.CallAsync(c => c.Update(classEditModel)); // this.ShowAutoCloseDialogOwter(UIResources.MsgInfo, "修改班级成功!"); // this.DialogResult = true; // } // catch (TimeoutException timeProblem) // { // strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; // } // catch (FaultException<LCFault> af) // { // strErrorMsg = af.Detail.Message; // } // catch (FaultException unknownFault) // { // strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; // } // catch (CommunicationException commProblem) // { // strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; // } // if (strErrorMsg != string.Empty) // { // await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "修改班级失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); // } //} #endregion }