コード例 #1
0
        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();
            }
        }
コード例 #2
0
 public bool DeficitMaterialDelete(DeficitMaterialsDTO dmdto)
 {
     try
     {
         DeficitMaterials.Delete(DeficitMaterials.GetAll().FirstOrDefault(c => c.Id == dmdto.Id));
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #3
0
        public void DeficitMaterialUpdate(DeficitMaterialsDTO dmdto)
        {
            var eGroup = DeficitMaterials.GetAll().SingleOrDefault(c => c.Id == dmdto.Id);

            DeficitMaterials.Update((mapper.Map <DeficitMaterialsDTO, DeficitMaterials>(dmdto, eGroup)));
        }
コード例 #4
0
        public int DeficitMaterialCreate(DeficitMaterialsDTO dmdto)
        {
            var createrecord = DeficitMaterials.Create(mapper.Map <DeficitMaterials>(dmdto));

            return((int)createrecord.Id);
        }