private void btnSave_Click(object sender, EventArgs e) { if (formValid.IsValid) { bool isUpdate = false; if (this.tunnelEntity == null) { this.tunnelEntity = new DASP.Domain.Entitys.TBTunnelEntity(); this.tunnelEntity.TunnelId = Guid.NewGuid(); this.tunnelEntity.TunnelName = txtTunnelName.Text.Trim(); this.tunnelEntity.TunnelStartDate = txtStartDate.Text.Trim(); this.tunnelEntity.TunnelEndDate = txtEndDate.Text.Trim(); this.tunnelEntity.TunnelLeader = txtLeader.Text.Trim(); this.tunnelEntity.Remark = txtRemark.Text.Trim(); this.tunnelEntity.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); this.tunnelEntity.Creator = Global.UserInfoInstance.CurrentLoginUser; this.tunnelEntity.Project = (DASP.Domain.Entitys.TBProjectEntity)cboBoxProject.SelectedItem; isUpdate = false; } else { this.tunnelEntity.TunnelName = txtTunnelName.Text.Trim(); this.tunnelEntity.TunnelStartDate = txtStartDate.Text.Trim(); this.tunnelEntity.TunnelEndDate = txtEndDate.Text.Trim(); this.tunnelEntity.TunnelLeader = txtLeader.Text.Trim(); this.tunnelEntity.Remark = txtRemark.Text.Trim(); this.tunnelEntity.Creator = Global.UserInfoInstance.CurrentLoginUser; this.tunnelEntity.Project = (DASP.Domain.Entitys.TBProjectEntity)cboBoxProject.SelectedItem; isUpdate = true; } this.tunnelEntity.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); try { if (isUpdate) { tunnelManager.Update(this.tunnelEntity); } else { tunnelManager.Save(this.tunnelEntity); } ZMessageBox.Show(this, "保存成功!", "提示", ZMessageBoxIcon.Information, ZMessageBoxButtons.OK); this.Close(); } catch (Exception ex) { ZMessageBox.Show(this, string.Format("保存失败:{0}!", ex.Message), "提示", ZMessageBoxIcon.Information, ZMessageBoxButtons.OK); } } }
private void btnSave_Click(object sender, EventArgs e) { if (formValid.IsValid) { bool isUpdate; if (null != fanPosEntity) { isUpdate = true; } else { fanPosEntity = new DASP.Domain.Entitys.TBFanPositionEntity(); fanPosEntity.PositionId = Guid.NewGuid(); fanPosEntity.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); isUpdate = false; } DASP.Domain.Entitys.TBTunnelEntity tunnel = cboBoxTunnel.SelectedItem as DASP.Domain.Entitys.TBTunnelEntity; fanPosEntity.Tunnel = tunnel; fanPosEntity.LaneWay = byte.Parse(cboBoxLaneWay.SelectedValue.ToString()); fanPosEntity.HoleWay = byte.Parse(cboBoxHoleWay.SelectedValue.ToString()); fanPosEntity.Creator = Global.UserInfoInstance.CurrentLoginUser; fanPosEntity.PositionName = txtFanPosName.Text.Trim(); fanPosEntity.Ramark = txtRemark.Text.Trim(); fanPosEntity.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); try { if (isUpdate) { posManager.Update(fanPosEntity); } else { posManager.Save(fanPosEntity); } ZMessageBox.Show(this, "保存成功!", "提示", ZMessageBoxIcon.Information, ZMessageBoxButtons.OK); this.Close(); } catch (Exception ex) { ZMessageBox.Show(this, string.Format("保存失败:{0}!", ex.Message), "提示", ZMessageBoxIcon.Information, ZMessageBoxButtons.OK); } } }
private void dgvDataSource_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (DataGridViewActionButtonCell.IsModifyButtonClick(sender, e)) { string objectId = dgvDataSource["ColAction", e.RowIndex].Value.ToString(); // 获取所要修改关联对象的主键 DASP.Domain.Entitys.TBTunnelEntity entity = tunnelManager.Get(Guid.Parse(objectId)); EditTunnelFrm editFrm = new EditTunnelFrm(entity); editFrm.FormClosed += new FormClosedEventHandler(editFrm_FormClosed); editFrm.ShowDialog(); } if (DataGridViewActionButtonCell.IsDeleteButtonClick(sender, e)) { string objectId = dgvDataSource["ColAction", e.RowIndex].Value.ToString(); // 获取所要删除关联对象的主键 } }
private void cusValid_Validating(object sender, CommonUtil.Validators.CustomValidator.ValidatingCancelEventArgs e) { if (e.ControlToValidate == cboBoxHoleWay) { ListItem listItem = cboBoxHoleWay.SelectedItem as ListItem; if (listItem.Value.Equals("-1")) { e.Valid = false; } else { e.Valid = true; } } if (e.ControlToValidate == cboBoxLaneWay) { ListItem listItem = cboBoxLaneWay.SelectedItem as ListItem; if (listItem.Value.Equals("-1")) { e.Valid = false; } else { e.Valid = true; } } if (e.ControlToValidate == cboBoxTunnel) { DASP.Domain.Entitys.TBTunnelEntity listItem = cboBoxTunnel.SelectedItem as DASP.Domain.Entitys.TBTunnelEntity; if (listItem.TunnelId == Guid.Empty) { e.Valid = false; } else { e.Valid = true; } } }
public EditTunnelFrm(DASP.Domain.Entitys.TBTunnelEntity entity) : this() { this.Text = "修改隧道"; this.tunnelEntity = entity; }
private void BindData() { List <ListItem> honeWayList = new List <ListItem>() { new ListItem("--请选择--", "-1"), new ListItem("左", "1"), new ListItem("右", "2") }; cboBoxHoleWay.DataSource = honeWayList; cboBoxHoleWay.DisplayMember = "Key"; cboBoxHoleWay.ValueMember = "Value"; List <ListItem> laneWayList = new List <ListItem>() { new ListItem("--请选择--", "-1"), new ListItem("1号", "1"), new ListItem("2号", "2"), new ListItem("3号", "1"), new ListItem("4号", "2") }; cboBoxLaneWay.DataSource = laneWayList; cboBoxLaneWay.DisplayMember = "Key"; cboBoxLaneWay.ValueMember = "Value"; IList <DASP.Domain.Entitys.TBTunnelEntity> tunnelList = tunnelManager.GetAll(); if (null == tunnelList) { tunnelList = new List <DASP.Domain.Entitys.TBTunnelEntity>(); } tunnelList.Insert(0, new DASP.Domain.Entitys.TBTunnelEntity() { TunnelId = Guid.Empty, TunnelName = "--请选择--" }); cboBoxTunnel.DataSource = tunnelList; cboBoxTunnel.DisplayMember = "TunnelName"; cboBoxTunnel.ValueMember = "TunnelId"; if (this.fanPosEntity != null) { txtFanPosName.Text = this.fanPosEntity.PositionName; txtRemark.Text = this.fanPosEntity.Ramark; ListItem laneWaySelectItem = laneWayList.Where(p => p.Value.Equals(fanPosEntity.LaneWay.ToString())).FirstOrDefault(); cboBoxLaneWay.SelectedValue = laneWaySelectItem.Value; ListItem holeWaySelectItem = honeWayList.Where(p => p.Value.Equals(fanPosEntity.HoleWay.ToString())).FirstOrDefault(); cboBoxHoleWay.SelectedValue = holeWaySelectItem.Value; DASP.Domain.Entitys.TBTunnelEntity tunnelSelectItem = tunnelList.Where(p => p.TunnelId.Equals(fanPosEntity.Tunnel.TunnelId)).FirstOrDefault(); cboBoxTunnel.SelectedValue = tunnelSelectItem.TunnelId; } }