示例#1
0
        /// <summary>
        /// 保存停机原因
        /// </summary>
        public static void SaveMachineHaltReasons(DataTable data)
        {
            string connectionString = ConnectionStringFactory.NXJCConnectionString;

            ISqlServerDataFactory factory = new SqlServerDataFactory(connectionString);
            Delete delete = new Delete("system_MachineHaltReason");

            factory.Remove(delete);
            Query     query         = new Query("system_MachineHaltReason");
            DataTable m_ReasonTable = factory.Query(query);

            if (query != null)
            {
                data.Columns.Add("OrganizationID", typeof(string));
                foreach (DataColumn Column in m_ReasonTable.Columns)
                {
                    int m_ColumnIndex = Column.Ordinal;
                    data.Columns[Column.ColumnName].SetOrdinal(m_ColumnIndex);
                }
            }

            factory.Save("system_MachineHaltReason", data);
        }
示例#2
0
        /// <summary>
        /// 保存公式
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="data"></param>
        public static void SaveFormulas(Guid groupId, DataTable data)
        {
            string connectionString = ConnectionStringFactory.GetNXJCConnectionString();

            // 删除现存公式
            ISqlServerDataFactory factory = new SqlServerDataFactory(connectionString);
            Delete delete = new Delete("Formula");

            delete.AddCriterions("GroupID", groupId, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
            factory.Remove(delete);

            // 插入所有公式
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = connection.CreateCommand();

                connection.Open();
                foreach (DataRow row in data.Rows)
                {
                    command.CommandText = "INSERT INTO Formula (GroupID, LevelCode, Name, Formula) VALUES ('" + groupId.ToString() + "', '" + row["LevelCode"].ToString() + "','" + row["Name"].ToString() + "','" + row["Formula"].ToString() + "')";
                    command.ExecuteNonQuery();
                }
            }
        }
示例#3
0
        /// <summary>
        /// 保存公式
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="data"></param>
        public static void SaveFormulas(Guid groupId, DataTable data)
        {
            string connectionString = ConnectionStringFactory.GetNXJCConnectionString();

            // 删除现存公式
            ISqlServerDataFactory factory = new SqlServerDataFactory(connectionString);
            Delete delete = new Delete("Formula");
            delete.AddCriterions("GroupID", groupId, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
            factory.Remove(delete);

            // 插入所有公式
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = connection.CreateCommand();

                connection.Open();
                foreach (DataRow row in data.Rows)
                {
                    command.CommandText = "INSERT INTO Formula (GroupID, LevelCode, Name, Formula) VALUES ('" + groupId.ToString() + "', '" + row["LevelCode"].ToString() + "','" + row["Name"].ToString() + "','" + row["Formula"].ToString() + "')";
                    command.ExecuteNonQuery();
                }
            }
        }