示例#1
0
        private void OnCreateChanage(object sender, EventArgs e)
        {
            PDAEntity newEntity = (PDAEntity)sender;

            bindingSource1.Add(newEntity);
            bindingSource1.ResetBindings(false);
        }
示例#2
0
        private bool Save()
        {
            if (!IsFieldValueValid())
            {
                return(false);
            }
            bool success = false;

            try
            {
                PDAEntity editEntity = PrepareSave();
                int       ret        = pdaDal.Save(editEntity, isNew);
                if (ret == -1)
                {
                    MsgBox.Warn("编号已存在,请改为其他的编号。");
                }
                else if (ret == -2)
                {
                    MsgBox.Warn("更新失败,该行已经被其他人删除。");
                }
                else
                {
                    success = true;
                    if (DataSourceChanged != null)
                    {
                        DataSourceChanged(editEntity, null);
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.Warn(ex.Message);
            }
            return(success);
        }
示例#3
0
        /// <summary>
        /// 检查编码是否已存在
        /// </summary>
        /// <param name="dept"></param>
        /// <returns></returns>
        private bool IsCodeExists(PDAEntity entity)
        {
            IMapper map = DatabaseInstance.Instance();
            string  id  = map.ExecuteScalar <string>("SELECT PDA_CODE FROM WM_PDA WHERE PDA_CODE = @COD",
                                                     new { COD = entity.PDACode });

            return(!string.IsNullOrEmpty(id));
        }
示例#4
0
 private void ShowEditInfo(PDAEntity pdaEntity)
 {
     txtCode.Text          = pdaEntity.PDACode;
     txtName.Text          = pdaEntity.PDAName;
     cbWareHouse.EditValue = pdaEntity.WarehouseCode;
     txtIpAddress.Text     = pdaEntity.IpAddress;
     comboBoxEdit1.Text    = pdaEntity.IsActive;
 }
示例#5
0
        /// <summary>
        /// 编辑
        /// </summary>
        private void ShowEditForm()
        {
            PDAEntity editEntity = SelectedRow;

            if (editEntity == null)
            {
                MsgBox.Warn("没有要修改的数据。");
                return;
            }

            FrmPDAEdit frmEdit = new FrmPDAEdit(editEntity);

            frmEdit.DataSourceChanged += OnEditChanage;
            frmEdit.ShowDialog();
        }
示例#6
0
        public PDAEntity PrepareSave()
        {
            PDAEntity editEntity = pdaEntity;

            if (editEntity == null)
            {
                editEntity = new PDAEntity();
            }

            editEntity.PDACode       = txtCode.Text.Trim();
            editEntity.WarehouseCode = ConvertUtil.ToString(cbWareHouse.EditValue);
            editEntity.WarehouseName = cbWareHouse.Text;
            editEntity.PDAName       = txtName.Text.Trim();
            editEntity.IsActive      = comboBoxEdit1.Text;
            editEntity.IpAddress     = txtIpAddress.Text.Trim();

            return(editEntity);
        }
示例#7
0
        public int Delete(PDAEntity removeEntity)
        {
            int result = 0;

            try
            {
                result = hhmDal.Delete(removeEntity.PDACode);
                if (result == 1)
                {
                    RemoveRowFromGrid(removeEntity);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Warn(ex.Message);
            }

            return(result);
        }
示例#8
0
        /// <summary>
        /// 添加或编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="operatorFlag">添加或编辑</param>
        /// <returns></returns>
        public int Save(PDAEntity entity, bool isNew)
        {
            IMapper map = DatabaseInstance.Instance();
            int     ret = -2;

            if (isNew)
            {
                //检查编号是否已经存在
                if (IsCodeExists(entity))
                {
                    return(-1);
                }
                ret = map.Execute("INSERT INTO WM_PDA(PDA_CODE, PDA_NAME, IP_ADDRESS, WH_CODE, IS_ACTIVE) " +
                                  "VALUES(@PDA_CODE, @PDA_NAME, @IP_ADDRESS, @WH_CODE, @IS_ACTIVE)",
                                  new
                {
                    PDA_CODE   = entity.PDACode,
                    PDA_NAME   = entity.PDAName,
                    IP_ADDRESS = entity.IpAddress,
                    WH_CODE    = entity.WarehouseCode,
                    IS_ACTIVE  = entity.IsActive
                });
            }
            else
            {
                //更新
                ret = map.Execute("UPDATE WM_PDA SET PDA_NAME = @PDA_NAME, IP_ADDRESS = @IP_ADDRESS, WH_CODE = @WH_CODE, IS_ACTIVE = @IS_ACTIVE WHERE PDA_CODE = @PDA_CODE",
                                  new
                {
                    PDA_NAME   = entity.PDAName,
                    IP_ADDRESS = entity.IpAddress,
                    WH_CODE    = entity.WarehouseCode,
                    IS_ACTIVE  = entity.IsActive,
                    PDA_CODE   = entity.PDACode
                });
            }
            return(ret);
        }
示例#9
0
        /// <summary>
        /// 删除
        /// </summary>
        private void DoDeleteSelected()
        {
            PDAEntity removeEntity = SelectedRow;

            if (removeEntity == null)
            {
                MsgBox.Warn("没有要删除的数据。");
                return;
            }

            if (MsgBox.AskOK(string.Format("确定要删除编号为“{0}”的手持机吗?", removeEntity.PDACode)) == DialogResult.OK)
            {
                int ret = Delete(removeEntity);
                if (ret == 1)
                {
                    ReLoad();
                }
                else
                {
                    MsgBox.Warn("删除失败。");
                }
            }
        }
示例#10
0
 public void RemoveRowFromGrid(PDAEntity obj)
 {
     bindingSource1.Remove(obj);
 }
示例#11
0
 public FrmPDAEdit(PDAEntity pdaEntity)
     : this()
 {
     this.pdaEntity = pdaEntity;
 }