/// <summary> /// 获取自定义操作的步骤 /// </summary> /// <param name="methodname"></param> /// <returns></returns> private DataTable dsCustomActions(string methodname) { DataTable dt = new DataTable(); ALS.BLL.customactions bllcustom = new ALS.BLL.customactions(); dt = bllcustom.GetList(" methodname='" + methodname + "'", true).Tables[0]; return(dt); }
private DataTable dsCustomActions(string methodname) { DataTable dt = new DataTable(); ALS.BLL.customactions bllcustom = new ALS.BLL.customactions(); dt = bllcustom.GetList(" methodname='" + methodname + "'", true).Tables[0]; dt.Columns.Add("序号", System.Type.GetType("System.String")).SetOrdinal(1); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][1] = (i + 1).ToString(); } return(dt); }
public bool GetCustCmd(string method) { ShowCustomActions(method); ALS.BLL.customactions bllCust = new ALS.BLL.customactions(); m_lstCust = bllCust.GetModelList("methodName='" + method + "'"); if (m_lstCust.Count > 0) { m_queueCustSendCmd = new Queue <Cls.Model_CustomCMD>(); ALS.BLL.actions bllact = new ALS.BLL.actions(); for (int i = 0; i < m_lstCust.Count; i++) { //重新计算时间点 if (i > 0) { m_lstCust[i].timeCount = m_lstCust[i - 1].timeCount + m_lstCust[i - 1].timeSpan; } //读取步骤下相应的动作列表 int customID = (int)m_lstCust[i].ID; List <ALS.Model.actions> lstModAct = bllact.GetModelList("customID='" + customID + "'"); List <Cls.Model_SendCMD> lstActions = new List <Cls.Model_SendCMD>(); if (lstModAct.Count > 0) { lstActions = GetlstActions(lstModAct); } Cls.Model_CustomCMD modCustCmd = new Cls.Model_CustomCMD(); modCustCmd._TimesCount = (int)m_lstCust[i].timeCount; modCustCmd._LstSendCMDs = lstActions; modCustCmd._LastTime = (int)m_lstCust[i].timeSpan; modCustCmd._ActionName = m_lstCust[i].actionName; modCustCmd._Index = m_queueCustSendCmd.Count; //将该动作列表加入步骤里 m_queueCustSendCmd.Enqueue(modCustCmd); } //最后一项提取总时间 int timefull = (int)(m_lstCust[m_lstCust.Count - 1].timeCount + m_lstCust[m_lstCust.Count - 1].timeSpan);// (int)modCust.timeCount + (int)modCust.timeSpan; this.lblFullTime.Text = Cls.utils.SecondsToTime(timefull); return(true); } else { this.lblFullTime.Text = "00:00:00"; return(false); } }
private void dgCustomAction_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { UnEnableControl(); this.lblHourc.Enabled = true; this.lblMinc.Enabled = true; this.lblSecc.Enabled = true; this.tabActions.Enabled = true; this.btnUpdate.Enabled = true; m_customID = Convert.ToInt32(dgvCustomActions.Rows[e.RowIndex].Cells["ID"].Value.ToString()); //获取该步骤信息 ALS.BLL.customactions bllc = new ALS.BLL.customactions(); m_modc = bllc.GetModel(m_customID); if (m_modc != null) { this.cmbAction.Text = m_modc.actionName; this.cmbAction.Text = m_modc.actionName; this.lbltsPump.Text = Cls.utils.SecondsToTime((int)m_modc.timeSpan); int hour = (int)m_modc.timeCount / 3600; int min = (int)(m_modc.timeCount % 3600) / 60; int sec = (int)m_modc.timeCount % 60; this.lblHour.Text = hour.ToString("00"); this.lblMin.Text = (min).ToString("00"); this.lblSec.Text = sec.ToString("00"); int hourc = (int)m_modc.timeSpan / 3600; int minc = (int)(m_modc.timeSpan % 3600) / 60; int secc = (int)(m_modc.timeSpan % 60); this.lblHourc.Text = hourc.ToString("00"); this.lblMinc.Text = minc.ToString("00"); this.lblSecc.Text = secc.ToString("00"); } //获取该时间点作列表 ShowActions(m_customID); } else { m_customID = -1; m_modc = null; this.tabActions.Enabled = false; } }
/// <summary> /// 获取自定义操作的步骤 /// </summary> /// <param name="methodname"></param> /// <returns></returns> private DataTable dsCustomActions(string methodname) { DataTable dt = new DataTable(); ALS.BLL.customactions bllcustom = new ALS.BLL.customactions(); dt.Columns.Add("ID"); dt.Columns.Add("描述"); dt.Columns.Add("timespan"); List <Model.customactions> lstCustomact = bllcustom.GetModelList(" methodname='" + methodname + "'"); //先合并延迟时间为0的步骤 for (int i = 0; i < lstCustomact.Count; i++) { if (lstCustomact[i].timeSpan.Value == 0) { //如果未超过列表项数 if (i + 1 < lstCustomact.Count) { lstCustomact[i + 1].actionName = lstCustomact[i + 1].actionName + " 【" + lstCustomact[i].actionName + "】"; } //如果最后一项是提示 if (i + 1 == lstCustomact.Count) { object[] val = new object[] { lstCustomact[i].ID, lstCustomact[i].actionName, lstCustomact[i].timeSpan }; dt.Rows.Add(val); } } else { object[] val = new object[] { lstCustomact[i].ID, lstCustomact[i].actionName, lstCustomact[i].timeSpan }; dt.Rows.Add(val); } } //DataSet ds = bllcustom.GetList(" methodname='" + methodname + "'", true); //dt = bllcustom.GetList(" methodname='" + methodname + "'", true).Tables[0]; return(dt); }
private void btnUpdate_Click(object sender, EventArgs e) { int hourc = int.Parse(this.lblHourc.Text); int minc = int.Parse(this.lblMinc.Text); int secc = int.Parse(this.lblSecc.Text); int timespan = hourc * 3600 + minc * 60 + secc; if (timespan == 0) { MessageBox.Show("持续时间不能为 0 ", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ALS.BLL.customactions bllcustom = new ALS.BLL.customactions(); ALS.Model.customactions modelcustom = bllcustom.GetModel(this._method, this.cmbAction.Text.Trim()); //CustomActions.BLL.actions bllaction = new CustomActions.BLL.actions(); //DataSet dsaction = bllaction.GetList("customID='"+ modelcustom.ID+"'"); //先查询该时间点是否有重复的 if (modelcustom != null) { //m_modc = new CustomActions.Model.customactions(); modelcustom.timeString = Cls.utils.SecondsToTime(0); modelcustom.actionName = this.cmbAction.Text.Trim(); modelcustom.methodName = _method; modelcustom.timeCount = 0; modelcustom.timeSpan = timespan; modelcustom.timeSpanString = Cls.utils.SecondsToTime(timespan); m_bllc = new ALS.BLL.customactions(); if (m_bllc.Update(modelcustom)) { //刷新列表,sort by timecount ShowCustomActions(_method); UnEnableControl(); } } }
private void btnSave_Click(object sender, EventArgs e) { //int hour = int.Parse(this.lblHour.Text); //int min = int.Parse(this.lblMin.Text); //int sec = int.Parse(this.lblSec.Text); //int timecount = hour * 3600 + min * 60 + sec; int hourc = int.Parse(this.lblHourc.Text); int minc = int.Parse(this.lblMinc.Text); int secc = int.Parse(this.lblSecc.Text); int timespan = hourc * 3600 + minc * 60 + secc; //if (!this.txtAction.Enabled) //{ // MessageBox.Show("请点击'输入步骤'按钮", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} //if (string.IsNullOrEmpty(this.txtAction.Text)) //{ // MessageBox.Show("请输入该步骤描述信息", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (string.IsNullOrEmpty(this.cmbAction.Text)) { MessageBox.Show("请输入该步骤描述信息", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (timespan == 0) { if (DialogResult.OK == MessageBox.Show("持续时间为0,点确定将添加为提示信息!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)) { //添加的是一个提示框 m_modc = new ALS.Model.customactions(); m_modc.timeString = Cls.utils.SecondsToTime(0); m_modc.actionName = this.cmbAction.Text.Trim(); m_modc.methodName = _method; m_modc.timeCount = 0; m_modc.timeSpan = 0; m_modc.timeSpanString = Cls.utils.SecondsToTime(0); m_bllc = new ALS.BLL.customactions(); if (m_bllc.Add(m_modc)) { //刷新列表,sort by timecount ShowCustomActions(_method); m_modc = null; UnEnableControl(); } } else { return; } } ALS.BLL.customactions bllcustom = new ALS.BLL.customactions(); ALS.Model.customactions modelcustom = bllcustom.GetModel(this._method, this.cmbAction.Text.Trim()); //CustomActions.BLL.actions bllaction = new CustomActions.BLL.actions(); //DataSet dsaction = bllaction.GetList("customID='"+ modelcustom.ID+"'"); //先查询该时间点是否有重复的 if (modelcustom != null) { MessageBox.Show("已存在相同的步骤名称,请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { m_modc = new ALS.Model.customactions(); m_modc.timeString = Cls.utils.SecondsToTime(0); m_modc.actionName = this.cmbAction.Text.Trim(); m_modc.methodName = _method; m_modc.timeCount = 0; m_modc.timeSpan = timespan; m_modc.timeSpanString = Cls.utils.SecondsToTime(timespan); m_bllc = new ALS.BLL.customactions(); if (m_bllc.Add(m_modc)) { //刷新列表,sort by timecount ShowCustomActions(_method); m_modc = null; UnEnableControl(); } } }