예제 #1
0
        private void frmAddElementInfo_Load(object sender, EventArgs e)
        {
            try
            {
                StaticValue.LoadLocationElementType(cmbChildLoactionType);
                StaticValue.LocadLocationOpearateType(cmbChildOperateType, false);

                //selectIframe = "1c8dd507-0790-4338-9173-0fe90c3df281";
                //childElementId = "6ca7a031-b933-4af3-8360-a1e48539bb7e";
                //prodefId = "pid-ccce3e0a-89e2-453b-a271-1a9f376f8a9b";
                CreateActionUtil.ReadChildLocationElement(_selectIframeId, locationElementId, prodefId, "", dgvChildElement,
                                                          childProdefId);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
 private void btnDeleteChildElement_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvChildElement.CurrentRow != null)
         {
             if (MessageBox.Show("确定删除当前元素?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
                 DialogResult.OK)
             {
                 String childLocationElementId
                     = dgvChildElement.CurrentRow.Cells["ChildLocationID"].Value.ToString();
                 CreateActionUtil.DeleteChildLocationElement(prodefId, actdefId, _selectIframeId, locationElementId, childLocationElementId, dgvChildElement, childProdefId);
                 btnChildAdd_Click(null, null);
             }
         }
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
예제 #3
0
        private void btnChildSave_Click(object sender, EventArgs e)
        {
            try
            {
                //selectIframe = "1c8dd507-0790-4338-9173-0fe90c3df281";
                //childElementId = "6ca7a031-b933-4af3-8360-a1e48539bb7e";
                //prodefId = "pid-ccce3e0a-89e2-453b-a271-1a9f376f8a9b";
                if (cmbChildLoactionType.SelectedValue == null || cmbChildLoactionType.Text == "")
                {
                    MessageBox.Show("请选择定位方式", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (txtChildLacationPath.Text == "")
                {
                    MessageBox.Show("请输入定位路径", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (cmbChildOperateType.SelectedValue == null || cmbChildOperateType.Text == "")
                {
                    MessageBox.Show("请选择操作方式", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (txtChildLocationOrder.Text.Trim() == "")
                {
                    MessageBox.Show("请输入操作顺序", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (txtChildLocationIntroduce.Text.Trim() == "")
                {
                    MessageBox.Show("请输入操作说明", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (cmbChildOperateType.SelectedValue.ToString().Equals("SENDKEYS") ||
                    cmbChildOperateType.SelectedValue.ToString().Equals("FR") ||
                    cmbChildOperateType.SelectedValue.ToString().Equals("CIRCLESENDKEYS"))
                {
                    if (txtChildLocationDefaultValue.Text == "")
                    {
                        MessageBox.Show("请输入操作默认值", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                else if (cmbChildOperateType.SelectedValue.ToString().Equals("QT"))
                {
                    if (txtChildLocationDefaultValue.Text == "")
                    {
                        MessageBox.Show("请输入操作默认值", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }


                List <DataGridViewRow> dataGridViewRows
                    = dgvChildElement.Rows.ToList <DataGridViewRow>();
                DataGridViewRow rowSelcet =
                    dataGridViewRows.Where(o => o.Cells["ChildOrder"].Value.ToString().Equals(txtChildLocationOrder.Text))
                    .FirstOrDefault();
                if (rowSelcet != null)
                {
                    if (!rowSelcet.Cells["ChildLocationID"].Value.ToString().Equals(lblChildLocationID.Text))
                    {
                        if (
                            MessageBox.Show("当前操作顺序已存在,是否插入添加?", "询问", MessageBoxButtons.OKCancel,
                                            MessageBoxIcon.Question) ==
                            DialogResult.OK)
                        {
                            dataGridViewRows.ForEach(p =>
                            {
                                int order = TypeConvert.ToConvert <object, int>(p.Cells["ChildOrder"].Value, false);
                                if (order >= TypeConvert.ToConvert <object, int>(txtChildLocationOrder.Text))
                                {
                                    p.Cells["ChildOrder"].Value = order + 1;
                                }
                            });

                            CreateActionUtil.UpdateChildElementOrder(dataGridViewRows, prodefId, childProdefId,
                                                                     actdefId, _selectIframeId, locationElementId);
                        }
                        else
                        {
                            return;
                        }
                    }
                }


                if (lblChildLocationID.Text == "")
                {
                    lblChildLocationID.Text = Guid.NewGuid().ToString();
                }
                LocationElementEntity element = new LocationElementEntity();
                element.Id                   = lblChildLocationID.Text;
                element.LocationType         = cmbChildLoactionType.SelectedValue.ToString();
                element.LocationPath         = txtChildLacationPath.Text;
                element.OperateType          = cmbChildOperateType.SelectedValue.ToString();
                element.LocationDefaultValue = txtChildLocationDefaultValue.Text;
                if (txtChildLocationDefaultValue.Tag != null)
                {
                    element.SqlSchemaId = txtChildLocationDefaultValue.Tag.ToString();
                }
                element.Order      = txtChildLocationOrder.Text;
                element.Introduce  = txtChildLocationIntroduce.Text;
                element.IsRanddom  = chkChildLocationRandom.Checked;
                element.WaitSecond = (String.IsNullOrEmpty(txtChildOperateTime.Text))
                    ? 0
                    : Convert.ToInt32(txtChildOperateTime.Text);
                CreateActionUtil.AddChildElementToXML(_selectIframeId, locationElementId, element, prodefId, actdefId,
                                                      dgvChildElement, childProdefId);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
        private void dgvChildElement_DragDrop(object sender, DragEventArgs e)
        {
            // The mouse locations are relative to the screen, so they must be
            // converted to client coordinates.
            Point clientPoint = dgvChildElement.PointToClient(new Point(e.X, e.Y));
            int   t           = rowIndexFromMouseDown;

            // Get the row index of the item the mouse is below.
            rowIndexOfItemUnderMouseToDrop =
                dgvChildElement.HitTest(clientPoint.X, clientPoint.Y).RowIndex;
            if (rowIndexFromMouseDown == rowIndexOfItemUnderMouseToDrop)
            {
                return;
            }
            // If the drag operation was a move then remove and insert the row.
            if (e.Effect == DragDropEffects.Move)
            {
                DataGridViewRow rowToMove = e.Data.GetData(
                    typeof(DataGridViewRow)) as DataGridViewRow;
                String    id       = rowToMove.Cells["ChildLocationID"].Value.ToString();
                DataTable dt       = (DataTable)dgvChildElement.DataSource;
                DataRow   drSelect = dt.AsEnumerable().FirstOrDefault(p => p["ChildLocationID"].ToString().Equals(id));

                DataTable dtNew = dt.Clone();
                try
                {
                    int recCount = dt.Rows.Count;
                    if (rowIndexFromMouseDown < rowIndexOfItemUnderMouseToDrop)
                    {
                        recCount += 1;
                        rowIndexOfItemUnderMouseToDrop += 1;
                    }
                    for (int i = 0; i < recCount; i++)
                    {
                        if (i < dt.Rows.Count)
                        {
                            if (dt.Rows[i]["ChildLocationID"].ToString().Equals(id))
                            {
                                continue;
                            }
                        }
                        if (rowIndexOfItemUnderMouseToDrop == i)
                        {
                            dtNew.ImportRow(drSelect);
                        }
                        if (i < dt.Rows.Count)
                        {
                            dtNew.ImportRow(dt.Rows[i]);
                        }

                        dgvChildElement.DataSource = dtNew;
                        int count = 1;
                        dtNew.AsEnumerable().ToList().ForEach(p =>
                        {
                            p["ChildOrder"] = count;
                            count++;
                        });
                        if (dtNew.Rows.Count > 0)
                        {
                            //默认选中行
                            List <DataGridViewRow> dataGridViewRowList
                                = dgvChildElement.Rows.ToList <DataGridViewRow>();
                            DataGridViewRow dgvSelectRow =
                                dataGridViewRowList
                                .FirstOrDefault(o => o.Cells["ChildLocationID"].Value.ToString().Equals(id));
                            if (dgvSelectRow != null)
                            {
                                dgvSelectRow.Selected       = true;
                                dgvChildElement.CurrentCell = dgvSelectRow.Cells[0];
                                dgvChildElement_CellClick(null, null);
                            }
                            CreateActionUtil.UpdateChildElementOrder(dataGridViewRowList, prodefId, childProdefId, actdefId, _selectIframeId, locationElementId);
                        }
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }