Пример #1
0
        private void Save(object sender, EventArgs e)
        {
            #region 保存设备档案

            Grid.EndEdit();
            model.dtOperations.Rows[Grid.CurrentRow.Index].EndEdit();

            if (string.IsNullOrEmpty(model.cEQCode))
            {
                throw new Exception("设备编码不能为空!");
            }
            else if (string.IsNullOrEmpty(model.cEQName))
            {
                throw new Exception("设备名称不能为空!");
            }
            else if (model.EQCId == 0)
            {
                throw new Exception("设备分类不能为空!");
            }
            //else if (model.operationId == 0)
            //{
            //    throw new Exception("工序不能为空!");
            //}

            foreach (DataRow r in model.dtOperations.Rows)
            {
                if (r["cycleTime"].ToString() == "" || Convert.ToDecimal(r["cycleTime"]) <= 0)
                {
                    throw new Exception("节拍不能为空,不能小等于0!");
                }
            }

            if (opState == OpState.Add)
            {
                if (dal.Exists(model.cEQCode))
                {
                    throw new Exception("已存在设备编码: " + model.cEQCode);
                }
                var id = dal.Add(model);
            }
            else if (opState == OpState.Update)
            {
                if (model.cEQCode != oldEQCode && dal.Exists(model.cEQCode))
                {
                    throw new Exception("已存在设备编码: " + model.cEQCode);
                }
                dal.Update(model);
            }

            this.DialogResult = DialogResult.OK;

            #endregion
        }
Пример #2
0
 public int Update(DataEntiry.Equipment _model)
 {
     return(dal.Update(_model, "ID"));
 }