/// <summary> /// 删除按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsBtnDel_Click(object sender, EventArgs e) { //确认删除 if (!Alert.confirm(Const.DEL_CONFIRM_MSG)) { return; } //using (new SessionScope()) //{ var entity = (DayReportHc)gridView1.GetFocusedRow(); var workingFace = WorkingFace.Find(entity.WorkingFace.WorkingFaceId); // 掘进工作面,只有一条巷道 var workingFaceHc = WorkingFaceHc.FindByWorkingFace(workingFace); if (workingFaceHc != null) { DelHcjc(workingFaceHc.TunnelZy.TunnelId, workingFaceHc.TunnelFy.TunnelId, workingFaceHc.TunnelQy.TunnelId, entity.BindingId, workingFace, workingFaceHc.TunnelZy.TunnelWid, workingFaceHc.TunnelFy.TunnelWid); entity.Delete(); RefreshData(); // 向server端发送更新预警数据 var msg = new UpdateWarningDataMsg(entity.WorkingFace.WorkingFaceId, Const.INVALID_ID, DayReportHc.TableName, OPERATION_TYPE.DELETE, DateTime.Now); SocketUtil.SendMsg2Server(msg); } else { Alert.alert("该工作面没有关联主运、辅运、切眼巷道"); } //} }
public static bool JudgeWorkingFaceIsAssociated(WorkingFace workingFace) { using (new SessionScope()) { var workingFaceLazy = WorkingFace.Find(workingFace.WorkingFaceId); var tunnelZy = workingFace.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_ZY); var tunnelFy = workingFace.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_FY); var tunnelQy = workingFace.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_QY); return(tunnelZy != null && tunnelFy != null && tunnelQy != null); } }
private void AddTunnelInfo() { // 验证 if (!Check()) { DialogResult = DialogResult.None; return; } DialogResult = DialogResult.OK; //创建巷道实体 var workingFace = selectWorkingFaceControl1.SelectedWorkingFace; using (new SessionScope()) { workingFace = WorkingFace.Find(workingFace.WorkingFaceId); if (workingFace.Tunnels.FirstOrDefault(u => u.TunnelName == txtTunnelName.Text) != null) { Alert.alert("该工作面下已有同名巷道!"); return; } } var tunnel = new Tunnel { TunnelName = txtTunnelName.Text, TunnelSupportPattern = cboSupportPattern.Text, WorkingFace = selectWorkingFaceControl1.SelectedWorkingFace, Lithology = (Lithology)cboLithology.SelectedItem, TunnelType = (TunnelTypeEnum)cboTunnelType.SelectedValue, CoalOrStone = cboCoalOrStone.Text, CoalSeams = CoalSeams.FindAll().First(), BindingId = IDGenerator.NewBindingID(), TunnelWid = 5 }; //设计长度 if (txtDesignLength.Text != "") { tunnel.TunnelDesignLength = Convert.ToInt32(txtDesignLength.Text); } if (txtDesignArea.Text != "") { tunnel.TunnelDesignArea = Convert.ToInt32(txtDesignLength.Text); } //巷道信息登录 tunnel.Save(); Alert.alert("提交成功!"); }
/// <summary> /// 获取班次中的时间范围,返回值例:起始时间2014-03-18 08:00:00.000,结束时间2014-03-18 16:00:00.000 /// </summary> /// <param name="strWorkTimeName"></param> /// <param name="strDate"></param> /// <returns></returns> //public static string[] GetDateShiftTimes(string strWorkTimeName, string strDate) //{ // //select WORK_TIME_FROM,WORK_TIME_TO from T_WORK_TIME where WORK_TIME_NAME ='早班' // string[] times = null; // StringBuilder strSql = new StringBuilder(); // strSql.Append("SELECT "); // strSql.Append(LibBusiness.WorkTimeDbConstNames.WORK_TIME_FROM + ","); // strSql.Append(LibBusiness.WorkTimeDbConstNames.WORK_TIME_TO); // strSql.Append(" FROM "); // strSql.Append(LibBusiness.WorkTimeDbConstNames.TABLE_NAME); // strSql.Append(" WHERE "); // strSql.Append(LibBusiness.WorkTimeDbConstNames.WORK_TIME_NAME); // strSql.Append(" = "); // strSql.Append("'" + strWorkTimeName + "'"); // DataSet ds = _database.ReturnDSNotOpenAndClose(strSql.ToString()); // if (ds != null) // { // DataTable dt = ds.Tables[0]; // if (dt != null) // { // //2014-03-05 15:43:45.000 // if (dt.Rows.Count > 0) // { // times = new string[2]; // times[0] = strDate + " " + dt.Rows[0][LibBusiness.WorkTimeDbConstNames.WORK_TIME_FROM].ToString(); // times[1] = strDate + " " + dt.Rows[0][LibBusiness.WorkTimeDbConstNames.WORK_TIME_TO].ToString(); // } // } // } // return times; //} /// <summary> /// 根据tunelID,查找巷道名称。若属于回采巷道,返回工作面名称 /// </summary> /// <param name="tunelId"></param> /// <returns></returns> public static string GetTunelNameByTunelID(string tunelId) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(TunnelInfoDbConstNames.TUNNEL_NAME + ","); strSql.Append(TunnelInfoDbConstNames.TUNNEL_TYPE + ","); strSql.Append(TunnelInfoDbConstNames.WORKINGFACE_ID); strSql.Append(" FROM "); strSql.Append(TunnelInfoDbConstNames.TABLE_NAME); strSql.Append(" WHERE "); strSql.Append(TunnelInfoDbConstNames.ID); strSql.Append(" = "); strSql.Append(tunelId); DataTable dt = _database.ReturnDSNotOpenAndClose(strSql.ToString()).Tables[0]; if (dt != null) { if (dt.Rows.Count > 0) { //判断是否属于回采巷道 if (TunnelUtils.IsStoping((TunnelTypeEnum)Convert.ToInt32(dt.Rows[0][LibBusiness.TunnelInfoDbConstNames.TUNNEL_TYPE]))) { //获取工作面名称 int workFaceId; int.TryParse(dt.Rows[0][TunnelInfoDbConstNames.WORKINGFACE_ID].ToString(), out workFaceId); WorkingFace workingFace = WorkingFace.Find(workFaceId); if (workingFace != null) { return(workingFace.WorkingFaceName); } } else { return (dt.Rows[0][LibBusiness.TunnelInfoDbConstNames.TUNNEL_NAME].ToString()); } } } return(""); }
public static WorkingFaceHc FindByWorkingFace(WorkingFace workingFace) { using (new SessionScope()) { var workingFaceLazy = WorkingFace.Find(workingFace.WorkingFaceId); var tunnelZy = workingFaceLazy.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_ZY); var tunnelFy = workingFaceLazy.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_FY); var tunnelQy = workingFaceLazy.Tunnels.FirstOrDefault(u => u.TunnelType == TunnelTypeEnum.STOPING_QY); var tunnelOther = workingFaceLazy.Tunnels.Where(u => u.TunnelType == TunnelTypeEnum.OTHER).ToList(); var result = new WorkingFaceHc { WorkingFace = workingFace, TunnelZy = tunnelZy, TunnelFy = tunnelFy, TunnelQy = tunnelQy, TunnelOther = tunnelOther }; return(result); } }
/// <summary> /// 验证 /// </summary> /// <returns></returns> private bool check() { //巷道是否选择 if (selectWorkingfaceSimple1.SelectedWorkingFace == null) { Alert.alert(Const.MSG_PLEASE_CHOOSE + Const_MS.TUNNEL + Const.SIGN_EXCLAMATION_MARK); return(false); } if (selectWorkingfaceSimple1.SelectedWorkingFace != null) { using (new SessionScope()) { var workingFace = WorkingFace.Find(selectWorkingfaceSimple1.SelectedWorkingFace.WorkingFaceId); if (workingFace.Tunnels.Count != 1) { Alert.alert("您选择的巷道不是掘进巷道"); return(false); } } } //队别为空 if (Validator.IsEmpty(cboTeamName.Text)) { Alert.alert(Const.MSG_PLEASE_TYPE_IN + Const_MS.TEAM_NAME + Const.SIGN_EXCLAMATION_MARK); return(false); } //队别名称是否有特殊字符 if (Validator.checkSpecialCharacters(cboTeamName.Text)) { Alert.alert(Const_MS.TEAM_NAME + Const.MSG_SP_CHAR + Const.SIGN_EXCLAMATION_MARK); return(false); } //填报人是否有特殊字符 if (Validator.checkSpecialCharacters(cboSubmitter.Text)) { Alert.alert(Const_MS.SUBMITTER + Const.MSG_SP_CHAR + Const.SIGN_EXCLAMATION_MARK); return(false); } //datagridview验证 //只有一条数据时 if (dgrdvDayReportJJ.Rows.Count - 1 == 0) { //添加时判断为未录入进尺 if (Text == Const_MS.DAY_REPORT_JJ_ADD) { Alert.alert(Const.MSG_PLEASE_TYPE_IN + Const_MS.JC + Const.SIGN_EXCLAMATION_MARK); return(false); } //修改时 var bResult = false; //为空返回false,不数据时跳出循环 for (var i = 0; i < dgrdvDayReportJJ.ColumnCount; i++) { if (dgrdvDayReportJJ[i, 0].Value == null) { bResult = false; } else { bResult = true; break; } } if (!bResult) { Alert.alert(Const.MSG_PLEASE_TYPE_IN + Const_MS.JC); return(bResult); } } for (var i = 0; i < dgrdvDayReportJJ.RowCount; i++) { // 最后一行为空行时,跳出循环 if (i == dgrdvDayReportJJ.RowCount - 1) { break; } var cell = dgrdvDayReportJJ.Rows[i].Cells[C_WORK_PROGRESS] as DataGridViewTextBoxCell; //进尺为空 if (cell.Value == null) { if (Const_MS.JJ == dgrdvDayReportJJ[C_WORK_PROGRESS, i].Value.ToString()) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const_MS.JC + Const.MSG_NOT_NULL + Const.SIGN_EXCLAMATION_MARK); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; } else { cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; } //进尺不为数字 if (cell.Value != null && !Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const_MS.JC + Const.MSG_MUST_NUMBER + Const.SIGN_EXCLAMATION_MARK); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; cell = dgrdvDayReportJJ.Rows[i].Cells[C_COMMENTS] as DataGridViewTextBoxCell; } //验证成功 return(true); }