private void saveBtn_Click(object sender, EventArgs e) { if (!ControlValidation()) { return; } if (MessageBox.Show("Сохранить изменения?", "Сохранение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Item.EndEdit(); if (this.operation == Utils.Operation.Add) { DeficitMaterialsDTO deficitDTO = new DeficitMaterialsDTO { MaterialId = ((DeficitCalcMaterialsDTO)Item).MaterialId, UnitId = ((DeficitCalcMaterialsDTO)Item).UnitId, Rate = ((DeficitCalcMaterialsDTO)Item).Rate }; ((DeficitCalcMaterialsDTO)Item).DeficitMaterialId = deficitMaterialsService.DeficitMaterialCreate(deficitDTO); } else { DeficitMaterialsDTO deficitDTO = new DeficitMaterialsDTO { Id = (int)((DeficitCalcMaterialsDTO)Item).DeficitMaterialId, MaterialId = ((DeficitCalcMaterialsDTO)Item).MaterialId, UnitId = ((DeficitCalcMaterialsDTO)Item).UnitId, Rate = ((DeficitCalcMaterialsDTO)Item).Rate }; deficitMaterialsService.DeficitMaterialUpdate(deficitDTO); } DialogResult = DialogResult.OK; this.Close(); } else { this.Item.CancelEdit(); } }
public bool DeficitMaterialDelete(DeficitMaterialsDTO dmdto) { try { DeficitMaterials.Delete(DeficitMaterials.GetAll().FirstOrDefault(c => c.Id == dmdto.Id)); return(true); } catch (Exception ex) { return(false); } }
public void DeficitMaterialUpdate(DeficitMaterialsDTO dmdto) { var eGroup = DeficitMaterials.GetAll().SingleOrDefault(c => c.Id == dmdto.Id); DeficitMaterials.Update((mapper.Map <DeficitMaterialsDTO, DeficitMaterials>(dmdto, eGroup))); }
public int DeficitMaterialCreate(DeficitMaterialsDTO dmdto) { var createrecord = DeficitMaterials.Create(mapper.Map <DeficitMaterials>(dmdto)); return((int)createrecord.Id); }