public BasicResponse <KJ_AddresstypeInfo> UpdateKJ_Addresstype(KJ_AddresstypeUpdateRequest kJ_AddresstypeRequest) { var _kJ_Addresstype = ObjectConverter.Copy <KJ_AddresstypeInfo, KJ_AddresstypeModel>(kJ_AddresstypeRequest.KJ_AddresstypeInfo); _Repository.UpdateKJ_Addresstype(_kJ_Addresstype); var kJ_Addresstyperesponse = new BasicResponse <KJ_AddresstypeInfo>(); kJ_Addresstyperesponse.Data = ObjectConverter.Copy <KJ_AddresstypeModel, KJ_AddresstypeInfo>(_kJ_Addresstype); return(kJ_Addresstyperesponse); }
/// <summary> /// 添加或修改区域及其规则入数据库 /// </summary> private void AddAddressTypeAndRulesToDB() { KJ_AddresstypeInfo tempAddressType = null; if (type == 0) { //新增 tempAddressType = GetAddressTypeInfoItem(txt_AddressTypeName.Text.Trim()); } else { //修改 tempAddressType = GetAddressTypeByAddressTypeID(AddressTypeid); } List <KJ_AddresstyperuleInfo> AddressTypeRuleInfoList = new List <KJ_AddresstyperuleInfo>(); for (int i = 0; i < gridView1.RowCount; i++) { KJ_AddresstyperuleInfo AddressTypeRuleItem = GetAddressTypeRuleItem( gridView1.GetRowCellValue(i, "ID").ToString() , gridView1.GetRowCellValue(i, "Addresstypeid").ToString() , gridView1.GetRowCellValue(i, "Devid").ToString() , gridView1.GetRowCellValue(i, "UpAlarmValue").ToString() , gridView1.GetRowCellValue(i, "UpPoweroffValue").ToString() , gridView1.GetRowCellValue(i, "LowAlarmValue").ToString() , gridView1.GetRowCellValue(i, "LowPoweroffValue").ToString()); AddressTypeRuleInfoList.Add(AddressTypeRuleItem); } if (type == 0) { KJ_AddresstypeAddRequest AddressTypeAddRequest = new KJ_AddresstypeAddRequest(); AddressTypeAddRequest.KJ_AddresstypeInfo = tempAddressType; addressTypeService.AddKJ_Addresstype(AddressTypeAddRequest); foreach (KJ_AddresstyperuleInfo temp in AddressTypeRuleInfoList) { //增加区域设备定义限制信息 KJ_AddresstyperuleAddRequest AddressTypeUpdateRequest = new KJ_AddresstyperuleAddRequest(); AddressTypeUpdateRequest.KJ_AddresstyperuleInfo = temp; addresstyperuleService.AddKJ_Addresstyperule(AddressTypeUpdateRequest); } } else { //修改 tempAddressType.Addresstypename = txt_AddressTypeName.Text.Trim(); tempAddressType.Createupdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); KJ_AddresstypeUpdateRequest AddressTypeUpdateRequest = new KJ_AddresstypeUpdateRequest(); AddressTypeUpdateRequest.KJ_AddresstypeInfo = tempAddressType; addressTypeService.UpdateKJ_Addresstype(AddressTypeUpdateRequest); //先删除,再添加 todo addresstyperuleService.DeleteKJ_AddresstyperuleByAddressTypeId(new KJ_AddresstyperuleDeleteByAddressTypeIdRequest() { AddressTypeId = AddressTypeid }); foreach (KJ_AddresstyperuleInfo temp in AddressTypeRuleInfoList) { //增加区域设备定义限制信息 KJ_AddresstyperuleAddRequest AddressTypeUpdateRequest1 = new KJ_AddresstyperuleAddRequest(); AddressTypeUpdateRequest1.KJ_AddresstyperuleInfo = temp; addresstyperuleService.AddKJ_Addresstyperule(AddressTypeUpdateRequest1); } } //DeleteAddressTypeRules(tempAddressType.AddressTypeid); //AddressTypeRuleInfo AddressTypeRuleItem; //AddressTypeRuleAddRequest AddressTypeRuleAddRequest; //for (int i = 0; i < gridView1.RowCount; i++) //{ // AddressTypeRuleItem = GetAddressTypeRuleItem(Convert.ToInt32(gridView1.GetRowCellValue(i, "devid").ToString()) // , Convert.ToInt32(gridView1.GetRowCellValue(i, "deviceCount").ToString()) // , float.Parse(gridView1.GetRowCellValue(i, "maxVal").ToString()) // , float.Parse(gridView1.GetRowCellValue(i, "minVal").ToString()) // , tempAddressType.AddressTypeid); // AddressTypeRuleAddRequest = new AddressTypeRuleAddRequest(); // AddressTypeRuleAddRequest.AddressTypeRuleInfo = AddressTypeRuleItem; // AddressTypeRuleService.AddAddressTypeRule(AddressTypeRuleAddRequest); //} }