private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCode.Text))
            {
                MessageBox.Show("Code can not empty,Please enter!");
                return;
            }

            if (string.IsNullOrEmpty(txtCompName.Text))
            {
                MessageBox.Show("Computer Name can not empty, Please enter!");
                return;
            }

            var compAddrInfo = new CompAddrInfo();

            compAddrInfo.AddrCode     = txtCode.Text.Trim();
            compAddrInfo.CompName     = txtCompName.Text.Trim();
            compAddrInfo.CompDateTime = DateTime.Now.ToString();
            compAddrInfo.Remark       = "";

            if (iStatus == 1)
            {
                compAddrInfo.SystemKey = new Guid(Guid.NewGuid().ToString().ToUpper());
                _control.AddEntity(compAddrInfo);
            }
            else //iStatus == 2
            {
                if (dgvAddr.CurrentRow != null)
                {
                    compAddrInfo.SystemKey = new Guid(dgvAddr.CurrentRow.Cells[0].Value.ToString().ToUpper());
                }

                _control.UpdateEntity(compAddrInfo);
            }
            //_control.AddEntity(shiftCodeInfo);
            //_control.SaveOrUpdateEntity(shiftCodeInfo);

            new OnLoadSystemCommonData().GetCompAddr();
            dgvAddr.DataSource = CommonData.CompAddrList;

            txtCode.Enabled     = false;
            txtCompName.Enabled = false;
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtAddrCode.Text))
            {
                CommonTool.ShowMessage("Address Code can not empty!");
                return;
            }

            if (string.IsNullOrEmpty(txtCompName.Text))
            {
                CommonTool.ShowMessage("Computer Name can not empty!");
                return;
            }
            CompAddrInfo compAddrInfo = new CompAddrInfo();

            compAddrInfo.AddrCode = txtAddrCode.Text;
            compAddrInfo.CompName = txtCompName.Text;

            try
            {
                if (isAdd)
                {
                    _control.AddEntity(compAddrInfo);
                }
                else
                {
                    compAddrInfo.ID = Convert.ToInt32(gvCompAddr.GetRowCellValue(gvCompAddr.FocusedRowHandle, "ID"));
                    _control.UpdateEntity(compAddrInfo);
                }
            }
            catch (Exception ex) { LogHelper.Error(this.Name, ex); }


            BindData();

            isAdd = false;

            CommonTool.ShowMessage("Save successful!");
        }