Exemple #1
0
 private void WriteFunctionList_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node.Tag is WriteDataFunctionInfo)
     {
         WriteDataFunctionInfo functionInfo = e.Node.Tag as WriteDataFunctionInfo;
         FunctionDialog.InitDataItems();
         FunctionDialog.InitFunctionInfo(functionInfo);
         FunctionDialog.ShowDialog(this);
     }
 }
Exemple #2
0
        private void Button_DeleteWriteFun_Click(object sender, EventArgs e)
        {
            if (WriteFunctionList.SelectedNode == null)
            {
                return;
            }

            WriteDataFunctionInfo Item = WriteFunctionList.SelectedNode.Tag as WriteDataFunctionInfo;
            string message             = "你确定要删除写数函数‘" + Item.Name + "’吗?";

            if (DialogResult.Yes == MessageBox.Show(message, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
            {
                Boolean Result = DepositoryWriteFunction.Delete(Item);
                if (Result)
                {
                    WriteFunctionList.SelectedNode.Remove();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 获得所有指定表单的写数函数
        /// </summary>
        /// <param name="SheetID"></param>
        /// <returns></returns>
        public List <WriteDataFunctionInfo> InitWriteFunctionByModelIndex(string ModelIndex)
        {
            List <WriteDataFunctionInfo> WriteDataFunctionInfos = new List <WriteDataFunctionInfo>();
            StringBuilder sql_Select = new StringBuilder();

            sql_Select.Append("select ID from sys_writefunction where ModelIndex ='");
            sql_Select.Append(ModelIndex.Trim("[]".ToCharArray()));
            sql_Select.Append("'");

            DataTable Data = GetDataTable(sql_Select.ToString());

            if (Data != null && Data.Rows.Count > 0)
            {
                foreach (DataRow row in Data.Rows)
                {
                    string FunctionIndex = row["ID"].ToString();
                    WriteDataFunctionInfo functionInfo = InitWriteFunctionByFunctionIndex(FunctionIndex);
                    WriteDataFunctionInfos.Add(functionInfo);
                }
            }

            return(WriteDataFunctionInfos);
        }
Exemple #4
0
        private void Button_AppendWriteFun_Click(object sender, EventArgs e)
        {
            if (WriteFunctionList.SelectedNode == null)
            {
                return;
            }

            WriteDataFunctionInfo functionInfo = null;

            if (WriteFunctionList.SelectedNode != null)
            {
                functionInfo = WriteFunctionList.SelectedNode.Tag as WriteDataFunctionInfo;
            }
            else
            {
                functionInfo = new WriteDataFunctionInfo();
            }

            functionInfo.Index = Guid.NewGuid().ToString();
            functionInfo.Name  = "请输入函数名称";
            FunctionDialog.InitFunctionInfo(functionInfo);
            FunctionDialog.ShowDialog(this);
        }
        private static List <ConditionExpression <object> > GetWriteToTableUpdatedColumn(WriteDataFunctionInfo FunctionInfo, DataRow row)
        {
            List <ConditionExpression <object> > UpdatedColumns = new List <ConditionExpression <object> >();

            if (FunctionInfo.Modifications.Count > 0)
            {
                for (int i = 0; i < FunctionInfo.Modifications.Count; i++)
                {
                    ExpressionInfo Info = FunctionInfo.Modifications[i];
                    ConditionExpression <object> UpdatedColumnExpression = new ConditionExpression <object>();

                    UpdatedColumnExpression.ColumnName = Info.DataItem.Name;

                    if (row.Table.Columns.Contains(Info.DataValue.Name))
                    {
                        Type type = row.Table.Columns[Info.DataValue.Name].DataType;
                        if (type.FullName.ToLower().Contains("int") ||
                            type.FullName.ToLower().Contains("decimal"))
                        {
                            float Current = 0f;

                            try
                            {
                                float.TryParse(row[Info.DataValue.Name].ToString(), out Current);
                            }
                            catch
                            { }

                            UpdatedColumnExpression.Value = Current;
                        }
                        else if (type.FullName.ToLower().Contains("datetime"))
                        {
                            try
                            {
                                UpdatedColumnExpression.Value = row[Info.DataValue.Name];
                            }
                            catch
                            {
                                UpdatedColumnExpression.Value = DBNull.Value;
                            }
                        }
                    }

                    switch (Info.Operation)
                    {
                    case "累计加":
                        UpdatedColumnExpression.Operation = "+";
                        break;

                    case "累计减":
                        UpdatedColumnExpression.Operation = "-";
                        break;

                    case "赋值":
                        UpdatedColumnExpression.Operation = "=";
                        break;

                    default:
                        UpdatedColumnExpression.Operation = "+";
                        break;
                    }

                    UpdatedColumns.Add(UpdatedColumnExpression);
                }
            }

            return(UpdatedColumns);
        }
        //将变化的值更新到待写入的数据表
        private static void UpdateWriteToTable(WriteDataFunctionInfo FunctionInfo, List <ConditionExpression <object> > UpdatedConditionExpressions, List <ConditionExpression <string> > ConditionExpressions, object Relation)
        {
            List <string> WriteToTableFilter = new List <string>();

            foreach (ConditionExpression <string> element in ConditionExpressions)
            {
                WriteToTableFilter.Add(element.ColumnName + " " + element.Operation + " " + element.Value);
            }

            if (UpdatedConditionExpressions.Count > 0)
            {
                StringBuilder Sql_Data = new StringBuilder();
                Sql_Data.Append("select ID from ");
                Sql_Data.Append(FunctionInfo.WriteInTableText);
                Sql_Data.Append(" where ");
                Sql_Data.Append("SCPT = '" + Relation + "'");

                DataTable TableData = Agent.CallService("Yqun.BO.LoginBO.dll", "GetDataTable", new object[] { Sql_Data.ToString() }) as DataTable;
                if (TableData != null && TableData.Rows.Count > 0)
                {
                    List <string> UpdateCommands = new List <string>();
                    foreach (DataRow Row in TableData.Rows)
                    {
                        String        ID         = Row["ID"].ToString();
                        StringBuilder Sql_Update = new StringBuilder();
                        Sql_Update.Append("Update ");
                        Sql_Update.Append(FunctionInfo.WriteInTableText);
                        Sql_Update.Append(" Set ");

                        for (int i = 0; i < UpdatedConditionExpressions.Count; i++)
                        {
                            ConditionExpression <object> UpdatedColumn = UpdatedConditionExpressions[i];

                            if (UpdatedColumn.Value == null)
                            {
                                continue;
                            }

                            Sql_Update.Append("[" + UpdatedColumn.ColumnName + "]");
                            Sql_Update.Append("=");

                            if (UpdatedColumn.Operation != "=")
                            {
                                Sql_Update.Append("[" + UpdatedColumn.ColumnName + "]");
                                Sql_Update.Append(UpdatedColumn.Operation);
                            }

                            Sql_Update.Append("(");

                            Type type = UpdatedColumn.Value.GetType();
                            if (type.FullName.ToLower().Contains("int") ||
                                type.FullName.ToLower().Contains("decimal"))
                            {
                                Sql_Update.Append(UpdatedColumn.Value.ToString());
                            }
                            else
                            {
                                Sql_Update.Append("'");
                                Sql_Update.Append(UpdatedColumn.Value.ToString());
                                Sql_Update.Append("'");
                            }

                            Sql_Update.Append(")");
                            if (i + 1 < UpdatedConditionExpressions.Count)
                            {
                                Sql_Update.Append(" , ");
                            }
                        }

                        Sql_Update.Append(" Where ID ='");
                        Sql_Update.Append(ID);
                        Sql_Update.Append("'");

                        UpdateCommands.Add(Sql_Update.ToString());
                    }

                    if (UpdateCommands.Count > 0)
                    {
                        String Update = string.Join(";", UpdateCommands.ToArray());
                        object r      = Agent.CallService("Yqun.BO.LoginBO.dll", "ExcuteCommand", new object[] { Update.ToString() });
                    }
                }
                else
                {
                    List <string> ColumnNameList  = new List <string>();
                    List <object> ColumnValueList = new List <object>();

                    for (int i = 0; i < UpdatedConditionExpressions.Count; i++)
                    {
                        ConditionExpression <object> UpdatedColumn = UpdatedConditionExpressions[i];
                        ColumnNameList.Add("[" + UpdatedColumn.ColumnName + "]");
                        ColumnValueList.Add(UpdatedColumn.Value);
                    }

                    string ColumnNames = string.Join(",", ColumnNameList.ToArray());

                    List <string> Fields      = new List <string>();
                    List <string> FieldValues = new List <string>();
                    String        ID          = Guid.NewGuid().ToString();
                    foreach (ConditionExpression <string> element in ConditionExpressions)
                    {
                        if (!Fields.Contains(element.ColumnName) && !ColumnNameList.Contains("[" + element.ColumnName + "]"))
                        {
                            Fields.Add("[" + element.ColumnName + "]");
                            FieldValues.Add(element.Value);
                        }
                    }

                    StringBuilder Sql_Insert = new StringBuilder();
                    Sql_Insert.Append("Insert into ");
                    Sql_Insert.Append(FunctionInfo.WriteInTableText);
                    Sql_Insert.Append("(ID,SCPT,");

                    Sql_Insert.Append(ColumnNames);

                    if (Fields.Count > 0)
                    {
                        Sql_Insert.Append(",");
                        Sql_Insert.Append(string.Join(",", Fields.ToArray()));
                    }

                    Sql_Insert.Append(") values('");
                    Sql_Insert.Append(ID);
                    Sql_Insert.Append("','");
                    Sql_Insert.Append(Relation);
                    Sql_Insert.Append("',");
                    for (int j = 0; j < ColumnValueList.Count; j++)
                    {
                        object ColumnValue = ColumnValueList[j];
                        Type   type        = ColumnValue.GetType();
                        if (type.FullName.ToLower().Contains("int") ||
                            type.FullName.ToLower().Contains("decimal"))
                        {
                            Sql_Insert.Append(ColumnValue.ToString());
                        }
                        else
                        {
                            Sql_Insert.Append("'");
                            Sql_Insert.Append(ColumnValue.ToString());
                            Sql_Insert.Append("'");
                        }

                        if (j + 1 < ColumnValueList.Count)
                        {
                            Sql_Insert.Append(",");
                        }
                    }

                    if (Fields.Count > 0)
                    {
                        Sql_Insert.Append(",");
                        Sql_Insert.Append(string.Join(",", FieldValues.ToArray()));
                    }

                    Sql_Insert.Append(")");

                    object r = Agent.CallService("Yqun.BO.LoginBO.dll", "ExcuteCommand", new object[] { Sql_Insert.ToString() });
                }
            }
        }
        //获得写入数据表的数据过滤条件
        private static List <ConditionExpression <string> > GetWriteToTableFilter(WriteDataFunctionInfo FunctionInfo, DataRow row)
        {
            List <ConditionExpression <string> > DataFilter = new List <ConditionExpression <string> >();

            foreach (ExpressionInfo Info in FunctionInfo.Conditions)
            {
                if (row.Table.Columns.Contains(Info.DataValue.Name))
                {
                    ConditionExpression <string> ElementFilter = new ConditionExpression <string>();
                    ElementFilter.ColumnName = Info.DataItem.Name;

                    switch (Info.Operation)
                    {
                    case "等于":
                        ElementFilter.Operation = "=";
                        break;

                    case "大于":
                        ElementFilter.Operation = ">";
                        break;

                    case "大于或等于":
                        ElementFilter.Operation = ">=";
                        break;

                    case "小于":
                        ElementFilter.Operation = "<";
                        break;

                    case "小于或等于":
                        ElementFilter.Operation = "<=";
                        break;

                    case "取最大值":
                    case "取最小值":
                        ElementFilter.Operation = "=";
                        break;
                    }

                    String ColValue = "";
                    if (Info.Operation.ToLower() != "取最大值" &&
                        Info.Operation.ToLower() != "取最小值")
                    {
                        if (row.RowState != DataRowState.Deleted)
                        {
                            ColValue = row[Info.DataValue.Name].ToString();
                        }
                        else
                        {
                            ColValue = row[Info.DataValue.Name, DataRowVersion.Original].ToString();
                        }

                        Type type = row.Table.Columns[Info.DataValue.Name].DataType;
                        if (!type.FullName.ToLower().Contains("int") &&
                            !type.FullName.ToLower().Contains("decimal"))
                        {
                            if (type.FullName.ToLower().Contains("datetime"))
                            {
                                DateTime datetime = DateTime.Parse(ColValue);
                                if (Info.Operation.ToLower().Contains("大于"))
                                {
                                    ColValue = datetime.Year.ToString() + "-" +
                                               datetime.Month.ToString("00") + "-" +
                                               datetime.Day.ToString("00") + " 23:59:59";
                                }
                                else if (Info.Operation.ToLower().Contains("小于"))
                                {
                                    ColValue = datetime.Year.ToString() + "-" +
                                               datetime.Month.ToString("00") + "-" +
                                               datetime.Day.ToString("00") + " 00:00:00";
                                }
                            }

                            ColValue = "'" + ColValue + "'";
                        }
                    }
                    else
                    {
                        DataTable Table = row.Table;
                        Object    Object;
                        switch (Info.Operation)
                        {
                        case "取最大值":
                            Object = Agent.CallService("Yqun.BO.LoginBO.dll", "ExcuteScalar", new Object[] { "select max(" + Info.DataValue.Name + ") from " + Table.TableName });
                            if (Object != null)
                            {
                                ColValue = System.Convert.ToString(Object);
                            }
                            break;

                        case "取最小值":
                            Object = Agent.CallService("Yqun.BO.LoginBO.dll", "ExcuteScalar", new Object[] { "select min(" + Info.DataValue.Name + ") from " + Table.TableName });
                            if (Object != null)
                            {
                                ColValue = System.Convert.ToString(Object);
                            }
                            break;
                        }

                        Type type = row.Table.Columns[Info.DataValue.Name].DataType;
                        if (!type.FullName.ToLower().Contains("int") &&
                            !type.FullName.ToLower().Contains("decimal"))
                        {
                            ColValue = "'" + ColValue + "'";
                        }
                    }

                    ElementFilter.Value = ColValue;
                    DataFilter.Add(ElementFilter);
                }
            }

            return(DataFilter);
        }
Exemple #8
0
        public WriteDataFunctionInfo InitWriteFunctionByFunctionIndex(string FunctionIndex)
        {
            WriteDataFunctionInfo functionInfo = new WriteDataFunctionInfo();

            if (!string.IsNullOrEmpty(FunctionIndex))
            {
                StringBuilder Sql_Function = new StringBuilder();
                Sql_Function.Append("select * from sys_writefunction where ID='");
                Sql_Function.Append(FunctionIndex);
                Sql_Function.Append("'");

                DataTable data = GetDataTable(Sql_Function.ToString());
                if (data != null && data.Rows.Count > 0)
                {
                    functionInfo.Index             = data.Rows[0]["ID"].ToString();
                    functionInfo.Name              = data.Rows[0]["FunctionName"].ToString();
                    functionInfo.WriteInTableIndex = data.Rows[0]["SheetIndex"].ToString();
                    functionInfo.WriteInTableText  = data.Rows[0]["SheetName"].ToString();
                    functionInfo.ReadOutTableIndex = data.Rows[0]["ModelIndex"].ToString();

                    String        ConditionList = data.Rows[0]["ConditionList"].ToString();
                    StringBuilder Sql_Condition = new StringBuilder();
                    Sql_Condition.Append("Select * From Sys_WriteFunctionCondition where ID in ('");
                    Sql_Condition.Append(ConditionList.Replace(",", "','"));
                    Sql_Condition.Append("')");

                    String        ModifyList = data.Rows[0]["ModifyList"].ToString();
                    StringBuilder Sql_Modify = new StringBuilder();
                    Sql_Modify.Append("Select * From Sys_WriteFunctionModify where ID in ('");
                    Sql_Modify.Append(ModifyList.Replace(",", "','"));
                    Sql_Modify.Append("')");

                    List <string> sql_Commands = new List <string>();
                    sql_Commands.Add(Sql_Condition.ToString());
                    sql_Commands.Add(Sql_Modify.ToString());

                    DataSet dataset = GetDataSet(sql_Commands.ToArray());
                    if (dataset != null)
                    {
                        DataTable TableCondition = dataset.Tables["Sys_WriteFunctionCondition"];
                        DataTable TableModify    = dataset.Tables["Sys_WriteFunctionModify"];

                        foreach (DataRow row in TableCondition.Rows)
                        {
                            ExpressionInfo expressionInfo = new ExpressionInfo();
                            expressionInfo.Index          = row["ID"].ToString();
                            expressionInfo.DataItem.Name  = row["ColName"].ToString();
                            expressionInfo.DataItem.Text  = row["ColDescription"].ToString();
                            expressionInfo.DataValue.Name = row["ConditionColName"].ToString();
                            expressionInfo.DataValue.Text = row["ConditionColDescription"].ToString();
                            expressionInfo.Operation      = row["ConditionType"].ToString();

                            functionInfo.Conditions.Add(expressionInfo);
                        }

                        foreach (DataRow row in TableModify.Rows)
                        {
                            ExpressionInfo expressionInfo = new ExpressionInfo();
                            expressionInfo.Index          = row["ID"].ToString();
                            expressionInfo.DataItem.Name  = row["ColName"].ToString();
                            expressionInfo.DataItem.Text  = row["ColDescription"].ToString();
                            expressionInfo.DataValue.Name = row["ModifyColName"].ToString();
                            expressionInfo.DataValue.Text = row["ModifyColDescription"].ToString();
                            expressionInfo.Operation      = row["ModifyType"].ToString();

                            functionInfo.Modifications.Add(expressionInfo);
                        }
                    }
                }
            }

            return(functionInfo);
        }
Exemple #9
0
        public Boolean DeleteWriteFunctionInfo(WriteDataFunctionInfo FunctionInfo)
        {
            String        ModifyList     = FunctionInfo.ModificationIDs;
            StringBuilder Sql_ModifyList = new StringBuilder();

            Sql_ModifyList.Append("Delete From sys_writefunctionmodify where ID in ('");
            Sql_ModifyList.Append(ModifyList.Replace(",", "','"));
            Sql_ModifyList.Append("')");

            String        ConditionList     = FunctionInfo.ConditionIDs;
            StringBuilder Sql_ConditionList = new StringBuilder();

            Sql_ConditionList.Append("Delete From sys_writefunctioncondition where ID in ('");
            Sql_ConditionList.Append(ConditionList.Replace(",", "','"));
            Sql_ConditionList.Append("')");

            StringBuilder Sql_Delete = new StringBuilder();

            Sql_Delete.Append("Delete From sys_writefunction where ID in ('");
            Sql_Delete.Append(FunctionInfo.Index);
            Sql_Delete.Append("')");

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_ModifyList.ToString());
            sql_Commands.Add(Sql_ConditionList.ToString());
            sql_Commands.Add(Sql_Delete.ToString());

            Boolean Result = true;

            IDbConnection Connection  = GetConntion();
            Transaction   Transaction = new Transaction(Connection);

            try
            {
                object r    = ExcuteCommands(sql_Commands.ToArray(), Transaction);
                int[]  ints = (int[])r;
                for (int i = 0; i < ints.Length; i++)
                {
                    if (i != 0)
                    {
                        Result = Result & (Convert.ToInt32(ints[i]) == 1);
                    }
                    else
                    {
                        Result = (Convert.ToInt32(ints[i]) == 1);
                    }
                }

                if (Result)
                {
                    Transaction.Commit();
                }
                else
                {
                    Transaction.Rollback();
                }
            }
            catch
            {
                Transaction.Rollback();
            }

            return(Result);
        }
Exemple #10
0
        public bool SaveWriteFunctionInfo(WriteDataFunctionInfo FunctionInfo)
        {
            Boolean Result = true;

            StringBuilder Sql_Function = new StringBuilder();

            Sql_Function.Append("Select ID,FunctionName,SheetID,SheetName,ParentID,ConditionList,ModifyList From Sys_WriteFunction Where ID = '");
            Sql_Function.Append(FunctionInfo.Index);
            Sql_Function.Append("'");

            StringBuilder Sql_ModifyList = new StringBuilder();

            Sql_ModifyList.Append("Select ID,ColName,ColDescription,ModifyType,ModifyColName,ModifyColDescription From Sys_WriteFunctionModify where ID in ('");
            Sql_ModifyList.Append(FunctionInfo.ModificationIDs.Replace(",", "','"));
            Sql_ModifyList.Append("')");

            StringBuilder Sql_ConditionList = new StringBuilder();

            Sql_ConditionList.Append("Select ID,ColName,ColDescription,ConditionType,ConditionColName,ConditionColDescription From Sys_WriteFunctionCondition where ID in ('");
            Sql_ConditionList.Append(FunctionInfo.ConditionIDs.Replace(",", "','"));
            Sql_ConditionList.Append("')");

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_Function.ToString());
            sql_Commands.Add(Sql_ModifyList.ToString());
            sql_Commands.Add(Sql_ConditionList.ToString());

            DataSet dataset = GetDataSet(sql_Commands.ToArray());

            if (dataset != null)
            {
                DataTable TableFunction     = dataset.Tables["Sys_WriteFunction"];
                DataTable ConditionFunction = dataset.Tables["Sys_WriteFunctionCondition"];
                DataTable ModifyFunction    = dataset.Tables["Sys_WriteFunctionModify"];

                if (TableFunction != null)
                {
                    if (TableFunction.Rows.Count > 0)
                    {
                        DataRow Row = TableFunction.Rows[0];
                        Row["FunctionName"]  = FunctionInfo.Name;
                        Row["SheetIndex"]    = FunctionInfo.WriteInTableIndex;
                        Row["SheetName"]     = FunctionInfo.WriteInTableText;
                        Row["ModelIndex"]    = FunctionInfo.ReadOutTableIndex;
                        Row["ConditionList"] = FunctionInfo.ConditionIDs;
                        Row["ModifyList"]    = FunctionInfo.ModificationIDs;
                    }
                    else
                    {
                        DataRow Row = TableFunction.NewRow();
                        Row["ID"]            = FunctionInfo.Index;
                        Row["FunctionName"]  = FunctionInfo.Name;
                        Row["SheetIndex"]    = FunctionInfo.WriteInTableIndex;
                        Row["SheetName"]     = FunctionInfo.WriteInTableText;
                        Row["ModelIndex"]    = FunctionInfo.ReadOutTableIndex;
                        Row["ConditionList"] = FunctionInfo.ConditionIDs;
                        Row["ModifyList"]    = FunctionInfo.ModificationIDs;
                        TableFunction.Rows.Add(Row);
                    }

                    foreach (ExpressionInfo Info in FunctionInfo.Modifications)
                    {
                        DataRow[] Rows = ModifyFunction.Select("ID = '" + Info.Index + "'");
                        if (Rows != null && Rows.Length > 0)
                        {
                            DataRow Row = Rows[0];
                            Row["ID"]                   = Info.Index;
                            Row["ColName"]              = Info.DataItem.Name;
                            Row["ColDescription"]       = Info.DataItem.Text;
                            Row["ModifyType"]           = Info.Operation;
                            Row["ModifyColName"]        = Info.DataValue.Name;
                            Row["ModifyColDescription"] = Info.DataValue.Text;
                        }
                        else
                        {
                            DataRow Row = ModifyFunction.NewRow();
                            Row["ID"]                   = Info.Index;
                            Row["ColName"]              = Info.DataItem.Name;
                            Row["ColDescription"]       = Info.DataItem.Text;
                            Row["ModifyType"]           = Info.Operation;
                            Row["ModifyColName"]        = Info.DataValue.Name;
                            Row["ModifyColDescription"] = Info.DataValue.Text;
                            ModifyFunction.Rows.Add(Row);
                        }
                    }

                    foreach (ExpressionInfo Info in FunctionInfo.Conditions)
                    {
                        DataRow[] Rows = ConditionFunction.Select("ID = '" + Info.Index + "'");
                        if (Rows != null && Rows.Length > 0)
                        {
                            DataRow Row = Rows[0];
                            Row["ID"]                      = Info.Index;
                            Row["ColName"]                 = Info.DataItem.Name;
                            Row["ColDescription"]          = Info.DataItem.Text;
                            Row["ConditionType"]           = Info.Operation;
                            Row["ConditionColName"]        = Info.DataValue.Name;
                            Row["ConditionColDescription"] = Info.DataValue.Text;
                        }
                        else
                        {
                            DataRow Row = ConditionFunction.NewRow();
                            Row["ID"]                      = Info.Index;
                            Row["ColName"]                 = Info.DataItem.Name;
                            Row["ColDescription"]          = Info.DataItem.Text;
                            Row["ConditionType"]           = Info.Operation;
                            Row["ConditionColName"]        = Info.DataValue.Name;
                            Row["ConditionColDescription"] = Info.DataValue.Text;
                            ConditionFunction.Rows.Add(Row);
                        }
                    }
                }

                IDbConnection Connection  = GetConntion();
                Transaction   Transaction = new Transaction(Connection);

                try
                {
                    object r = Update(dataset, Transaction);
                    Result = Result & (Convert.ToInt32(r) > 0);

                    if (Result)
                    {
                        Transaction.Commit();
                    }
                    else
                    {
                        Transaction.Rollback();
                    }
                }
                catch
                {
                    Transaction.Rollback();
                }
            }

            return(Result);
        }
        public static Boolean Delete(WriteDataFunctionInfo FunctionInfo)
        {
            Boolean Result = Convert.ToBoolean(Agent.CallService("Yqun.BO.BusinessManager.dll", "DeleteWriteFunctionInfo", new object[] { FunctionInfo }));

            return(Result);
        }
        public static WriteDataFunctionInfo InitByFunctionIndex(string FunctionIndex)
        {
            WriteDataFunctionInfo functionInfo = Agent.CallService("Yqun.BO.BusinessManager.dll", "InitWriteFunctionByFunctionIndex", new object[] { FunctionIndex }) as WriteDataFunctionInfo;;

            return(functionInfo);
        }
Exemple #13
0
        /// <summary>
        /// 初始化写数函数
        /// </summary>
        /// <param name="FunctionInfo"></param>
        public void InitFunctionInfo(WriteDataFunctionInfo FunctionInfo)
        {
            this.FunctionInfo = FunctionInfo;
            //显示写数函数的名称
            TextBox_FunctionName.Text = FunctionInfo.Name;
            ReadFromTableName         = FunctionInfo.ReadOutTableIndex;

            //显示写数函数的写入数据的数据表
            if (!string.IsNullOrEmpty(FunctionInfo.WriteInTableIndex))
            {
                TreeNode[] Nodes = SheetList.Nodes.Find(FunctionInfo.WriteInTableIndex, true);
                if (Nodes.Length > 0)
                {
                    SheetList.SelectedNode = Nodes[0];
                    InitFields(Nodes[0]);
                }
            }

            //显示写数函数的过滤条件

            //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument”
            if (ConditionList.ActiveSheet.Rows.Count > 0)
            {
                ConditionList.ShowRow(ConditionList.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);
            }

            ConditionList.ActiveSheet.Rows.Count = 0;
            ConditionList.ActiveSheet.Rows.Count = 600;
            foreach (ExpressionInfo Info in FunctionInfo.Conditions)
            {
                ConditionList.ActiveSheet.Rows.Add(0, 1);
                ConditionList.ActiveSheet.Rows[0].Tag = Info;

                foreach (FieldInfo fieldInfo in WriteToTable_DataItem_Editor.Items)
                {
                    if (fieldInfo.Name == Info.DataItem.Name)
                    {
                        ConditionList.ActiveSheet.Cells[0, 0].Value = fieldInfo;
                        break;
                    }
                }

                TreeNode[] dropDownNodes = WriteToTable_Value_Editor.DropDownControl.Nodes.Find(Info.DataValue.Name, true);
                if (dropDownNodes.Length > 0)
                {
                    WriteToTable_Value_Editor.DropDownControl.SelectedNode = dropDownNodes[0];
                    ConditionList.ActiveSheet.Cells[0, 2].Value            = dropDownNodes[0].Tag as FieldInfo;
                }

                ConditionList.ActiveSheet.Cells[0, 1].Value = Info.Operation;
            }

            //显示写数函数的修改数据项

            //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument”
            if (ModificationList.ActiveSheet.Rows.Count > 0)
            {
                ModificationList.ShowRow(ModificationList.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);
            }

            ModificationList.ActiveSheet.Rows.Count = 0;
            ModificationList.ActiveSheet.Rows.Count = 600;
            foreach (ExpressionInfo Info in FunctionInfo.Modifications)
            {
                ModificationList.ActiveSheet.Rows.Add(0, 1);
                ModificationList.ActiveSheet.Rows[0].Tag = Info;

                foreach (FieldInfo fieldInfo in Modification_DataItem_Editor.Items)
                {
                    if (fieldInfo.Name == Info.DataItem.Name)
                    {
                        ModificationList.ActiveSheet.Cells[0, 0].Value = fieldInfo;
                        break;
                    }
                }

                TreeNode[] dropDownNodes = ModificationValue_Editor.DropDownControl.Nodes.Find(Info.DataValue.Name, true);
                if (dropDownNodes.Length > 0)
                {
                    ModificationValue_Editor.DropDownControl.SelectedNode = dropDownNodes[0];
                    ModificationList.ActiveSheet.Cells[0, 2].Value        = dropDownNodes[0].Tag as FieldInfo;
                }

                ModificationList.ActiveSheet.Cells[0, 1].Value = Info.Operation;
            }
        }