Exemplo n.º 1
0
        /// <summary>
        /// 2012.12.18 董平增加
        /// 目的:处理变量复制操作
        /// </summary>
        private void DealWithVarCopy()
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                List <PMSVar> tempvars = new List <PMSVar>();

                for (int i = dataGridView1.SelectedRows.Count - 1; i >= 0; i--)
                {
                    DataGridViewRow tempRow = dataGridView1.SelectedRows[i];
                    if (!tempRow.IsNewRow)
                    {
                        if (tempRow.Cells[0].Value == null && tempRow.Cells[0].Value.ToString() == "")
                        {
                            tempRow.Cells[0].Selected = true;
                            MessageBox.Show("变量名称不能为空!");
                            return;
                        }

                        if (tempRow.Cells[1].Value == null && tempRow.Cells[1].Value.ToString() == "")
                        {
                            tempRow.Cells[1].Selected = true;
                            MessageBox.Show("数据类型不能为空!");
                            return;
                        }

                        PMSVar var1 = new PMSVar();
                        switch (tempRow.Cells[1].Value.ToString())
                        {
                        case "字符串":
                            var1.VarType = MESVarType.MESString;
                            break;

                        case "整型":
                            var1.VarType = MESVarType.MESInt;
                            break;

                        case "时间日期":
                            var1.VarType = MESVarType.MESDateTime;
                            break;

                        case "浮点型":
                            var1.VarType = MESVarType.MESReal;
                            break;

                        case "布尔":
                            var1.VarType = MESVarType.MESBool;
                            break;

                        case "货币":
                            var1.VarType = MESVarType.MESDecimal;
                            break;

                        default:
                            var1.VarType = MESVarType.MESNodefined;
                            break;
                        }
                        var1.VarName = tempRow.Cells[0].Value.ToString();
                        if (tempRow.Cells[2].Value != null)
                        {
                            var1.VarValue = tempRow.Cells[2].Value;
                        }
                        if (tempRow.Cells[3].Value != null)
                        {
                            var1.VarDesc = tempRow.Cells[3].Value.ToString();
                        }

                        tempvars.Add(var1);
                    }
                }
                Clipboard.SetData(DataFormats.Serializable, tempvars);
            }
        }
Exemplo n.º 2
0
 private void AddRow(PMSVar pv)
 {
 }